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 += delta;
@@ -144,23 +144,23 @@
       if (table[id].rc == 0)
         stats->change (stat_pid_entries, -1);
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 void
-resolve_pid (PID_INDEX id, PeerIdentity * pid)
+resolve_pid (PID_INDEX id, GNUNET_PeerIdentity * pid)
 {
   if (id == 0)
     {
-      memset (pid, 0, sizeof (PeerIdentity));
+      memset (pid, 0, sizeof (GNUNET_PeerIdentity));
       GE_BREAK (ectx, 0);
       return;
     }
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   GE_ASSERT (ectx, id < size);
   GE_ASSERT (ectx, table[id].rc > 0);
   pid->hashPubKey = table[id].id;
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 
@@ -180,16 +180,16 @@
         create (gettext_noop
                 ("# total RC of interned peer IDs in pid table"));
     }
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
 }
 
 
 void
 done_pid_table ()
 {
-  GROW (table, size, 0);
+  GNUNET_array_grow (table, size, 0);
   stats = NULL;
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   lock = NULL;
   ectx = NULL;
 }

Modified: GNUnet/src/applications/gap/pid_table.h
===================================================================
--- GNUnet/src/applications/gap/pid_table.h     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/gap/pid_table.h     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -33,10 +33,10 @@
 
 typedef unsigned int PID_INDEX;
 
-PID_INDEX intern_pid (const PeerIdentity * pid);
+PID_INDEX intern_pid (const GNUNET_PeerIdentity * pid);
 
 void change_pid_rc (PID_INDEX id, int delta);
 
 void decrement_pid_rcs (const PID_INDEX * ids, unsigned int count);
 
-void resolve_pid (PID_INDEX id, PeerIdentity * pid);
+void resolve_pid (PID_INDEX id, GNUNET_PeerIdentity * pid);

Modified: GNUnet/src/applications/getoption/Makefile.am
===================================================================
--- GNUnet/src/applications/getoption/Makefile.am       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/getoption/Makefile.am       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -12,8 +12,7 @@
 libgnunetgetoption_api_la_SOURCES = \
   clientapi.c 
 libgnunetgetoption_api_la_LIBADD = \
-  $(top_builddir)/src/util/libgnunetutil.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la
+  $(top_builddir)/src/util/libgnunetutil.la 
 
 libgnunetmodule_getoption_la_SOURCES = \
   getoption.c getoption.h

Modified: GNUnet/src/applications/getoption/clientapi.c
===================================================================
--- GNUnet/src/applications/getoption/clientapi.c       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/getoption/clientapi.c       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -38,7 +38,7 @@
  * @return NULL on error (for both option not set and internal errors)
  */
 char *
-getConfigurationOptionValue (struct ClientServerConnection *sock,
+GNUNET_get_daemon_configuration_value (struct GNUNET_ClientServerConnection 
*sock,
                              const char *section, const char *option)
 {
   CS_getoption_request_MESSAGE req;
@@ -54,18 +54,20 @@
     return NULL;
   strcpy (&req.section[0], section);
   strcpy (&req.option[0], option);
-  res = connection_write (sock, &req.header);
-  if (res != OK)
+  res = GNUNET_client_connection_write (sock, &req.header);
+  if (res != GNUNET_OK)
     return NULL;
   reply = NULL;
-  res = connection_read (sock, (MESSAGE_HEADER **) & reply);
-  if (res != OK)
+  res =
+    GNUNET_client_connection_read (sock, (GNUNET_MessageHeader **) & reply);
+  if (res != GNUNET_OK)
     return NULL;
-  ret = MALLOC (ntohs (reply->header.size) - sizeof (MESSAGE_HEADER) + 1);
-  memcpy (ret,
-          &reply->value[0],
-          ntohs (reply->header.size) - sizeof (MESSAGE_HEADER));
-  ret[ntohs (reply->header.size) - sizeof (MESSAGE_HEADER)] = '\0';
-  FREE (reply);
+  ret =
+    GNUNET_malloc (ntohs (reply->header.size) -
+                   sizeof (GNUNET_MessageHeader) + 1);
+  memcpy (ret, &reply->value[0],
+          ntohs (reply->header.size) - sizeof (GNUNET_MessageHeader));
+  ret[ntohs (reply->header.size) - sizeof (GNUNET_MessageHeader)] = '\0';
+  GNUNET_free (reply);
   return ret;
 }

Modified: GNUnet/src/applications/getoption/getoption.c
===================================================================
--- GNUnet/src/applications/getoption/getoption.c       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/getoption/getoption.c       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -34,7 +34,8 @@
 static CoreAPIForApplication *coreAPI;
 
 static int
-handleGetOption (struct ClientHandle *sock, const MESSAGE_HEADER * message)
+handleGetOption (struct ClientHandle *sock,
+                 const GNUNET_MessageHeader * message)
 {
   CS_getoption_request_MESSAGE *req;
   CS_getoption_reply_MESSAGE *rep;
@@ -42,27 +43,27 @@
   int ret;
 
   if (ntohs (message->size) != sizeof (CS_getoption_request_MESSAGE))
-    return SYSERR;
+    return GNUNET_SYSERR;
   req = (CS_getoption_request_MESSAGE *) message;
   req->section[CS_getoption_request_MESSAGE_OPT_LEN - 1] = '\0';
   req->option[CS_getoption_request_MESSAGE_OPT_LEN - 1] = '\0';
   val = NULL;
-  if (NO == GC_have_configuration_value (coreAPI->cfg,
-                                         req->section, req->option))
-    return SYSERR;              /* signal error: option not set */
+  if (GNUNET_NO == GC_have_configuration_value (coreAPI->cfg,
+                                                req->section, req->option))
+    return GNUNET_SYSERR;       /* signal error: option not set */
   if ((0 != GC_get_configuration_value_string (coreAPI->cfg,
                                                req->section,
                                                req->option,
                                                NULL, &val)) || (val == NULL))
-    return SYSERR;              /* signal error: option not set */
+    return GNUNET_SYSERR;       /* signal error: option not set */
 
-  rep = MALLOC (sizeof (MESSAGE_HEADER) + strlen (val) + 1);
-  rep->header.size = htons (sizeof (MESSAGE_HEADER) + strlen (val) + 1);
+  rep = GNUNET_malloc (sizeof (GNUNET_MessageHeader) + strlen (val) + 1);
+  rep->header.size = htons (sizeof (GNUNET_MessageHeader) + strlen (val) + 1);
   memcpy (rep->value, val, strlen (val) + 1);
   rep->header.type = htons (CS_PROTO_GET_OPTION_REPLY);
-  ret = coreAPI->sendToClient (sock, &rep->header, YES);
-  FREE (rep);
-  FREE (val);
+  ret = coreAPI->sendToClient (sock, &rep->header, GNUNET_YES);
+  GNUNET_free (rep);
+  GNUNET_free (val);
   return ret;
 }
 
@@ -83,7 +84,7 @@
                                                      _
                                                      ("allows clients to 
determine gnunetd's"
                                                       " configuration")));
-  return OK;
+  return GNUNET_OK;
 }
 
 void

Modified: GNUnet/src/applications/getoption/getoption.h
===================================================================
--- GNUnet/src/applications/getoption/getoption.h       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/getoption/getoption.h       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -28,7 +28,7 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
   char section[CS_getoption_request_MESSAGE_OPT_LEN];
   char option[CS_getoption_request_MESSAGE_OPT_LEN];
 } CS_getoption_request_MESSAGE;
@@ -39,7 +39,7 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
   char value[1];
 } CS_getoption_reply_MESSAGE;
 

Modified: GNUnet/src/applications/identity/Makefile.am
===================================================================
--- GNUnet/src/applications/identity/Makefile.am        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/identity/Makefile.am        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -15,9 +15,7 @@
   identity.c identity.h \
   hostkey.c hostkey.h
 libgnunetmodule_identity_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_identity_la_LDFLAGS = \
   -export-dynamic -avoid-version -module
 
@@ -25,9 +23,7 @@
 libgnunetidentity_api_la_SOURCES = \
   clientapi.c 
 libgnunetidentity_api_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/util/libgnunetutil.la 
 
 
 check_PROGRAMS = \
@@ -40,6 +36,5 @@
  identitytest.c 
 identitytest_LDADD = \
  $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
  $(top_builddir)/src/applications/identity/libgnunetidentity_api.la \
  $(top_builddir)/src/server/libgnunetcore.la  

Modified: GNUnet/src/applications/identity/clientapi.c
===================================================================
--- GNUnet/src/applications/identity/clientapi.c        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/identity/clientapi.c        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -33,76 +33,78 @@
  * Inform gnunetd about another peer.
  *
  * @param sock socket to talk to gnunetd over
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-gnunet_identity_peer_add (struct ClientServerConnection *sock,
-                          const P2P_hello_MESSAGE * hello)
+GNUNET_IDENTITY_peer_add (struct GNUNET_ClientServerConnection *sock,
+                          const GNUNET_MessageHello * hello)
 {
-  P2P_hello_MESSAGE *msg;
+  GNUNET_MessageHello *msg;
 
-  msg = MALLOC (P2P_hello_MESSAGE_size (hello));
-  memcpy (msg, hello, P2P_hello_MESSAGE_size (hello));
+  msg = GNUNET_malloc (GNUNET_sizeof_hello (hello));
+  memcpy (msg, hello, GNUNET_sizeof_hello (hello));
   msg->header.type = htons (CS_PROTO_identity_HELLO);
   /* check that signature is valid -- internal
      sanity check... */
-  if (SYSERR == verifySig (&msg->senderIdentity,
-                           P2P_hello_MESSAGE_size (msg)
-                           - sizeof (Signature)
-                           - sizeof (PublicKey)
-                           - sizeof (MESSAGE_HEADER),
-                           &msg->signature, &msg->publicKey))
+  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))
     {
       GE_BREAK (NULL, 0);
-      FREE (msg);
-      return SYSERR;
+      GNUNET_free (msg);
+      return GNUNET_SYSERR;
     }
-  if (SYSERR == connection_write (sock, &msg->header))
+  if (GNUNET_SYSERR == GNUNET_client_connection_write (sock, &msg->header))
     {
-      FREE (msg);
-      return SYSERR;
+      GNUNET_free (msg);
+      return GNUNET_SYSERR;
     }
-  FREE (msg);
-  return OK;
+  GNUNET_free (msg);
+  return GNUNET_OK;
 }
 
 
 /**
- * Function to request the peer to sign something
+ * Function to request the peer to GNUNET_RSA_sign something
  * with the private key of the peer.
  */
 int
-gnunet_identity_sign_function (struct ClientServerConnection *sock,
+GNUNET_IDENTITY_sign_function (struct GNUNET_ClientServerConnection *sock,
                                unsigned short size,
-                               const void *data, Signature * result)
+                               const void *data,
+                               GNUNET_RSA_Signature * result)
 {
-  MESSAGE_HEADER *req;
+  GNUNET_MessageHeader *req;
   CS_identity_signature_MESSAGE *reply;
 
-  req = MALLOC (sizeof (MESSAGE_HEADER) + size);
-  req->size = htons (sizeof (MESSAGE_HEADER) + size);
+  req = GNUNET_malloc (sizeof (GNUNET_MessageHeader) + size);
+  req->size = htons (sizeof (GNUNET_MessageHeader) + size);
   req->type = htons (CS_PROTO_identity_request_SIGN);
   memcpy (&req[1], data, size);
-  if (SYSERR == connection_write (sock, req))
+  if (GNUNET_SYSERR == GNUNET_client_connection_write (sock, req))
     {
-      FREE (req);
-      return SYSERR;
+      GNUNET_free (req);
+      return GNUNET_SYSERR;
     }
-  FREE (req);
-  if (OK != connection_read (sock, (MESSAGE_HEADER **) & reply))
+  GNUNET_free (req);
+  if (GNUNET_OK !=
+      GNUNET_client_connection_read (sock, (GNUNET_MessageHeader **) & reply))
     {
-      connection_close_temporarily (sock);
-      return SYSERR;
+      GNUNET_client_connection_close_temporarily (sock);
+      return GNUNET_SYSERR;
     }
   if ((ntohs (reply->header.size) != sizeof (CS_identity_signature_MESSAGE))
       || (ntohs (reply->header.type) != CS_PROTO_identity_SIGNATURE))
     {
-      FREE (reply);
-      return SYSERR;
+      GNUNET_free (reply);
+      return GNUNET_SYSERR;
     }
   *result = reply->sig;
-  FREE (reply);
-  return OK;
+  GNUNET_free (reply);
+  return GNUNET_OK;
 }
 
 /**
@@ -110,45 +112,46 @@
  * (that is, external addresses).
  * Except for the "sock" argument, all arguments are
  * set by the function.
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 int
-gnunet_identity_get_self (struct ClientServerConnection *sock,
-                          P2P_hello_MESSAGE ** msg)
+GNUNET_IDENTITY_get_self (struct GNUNET_ClientServerConnection *sock,
+                          GNUNET_MessageHello ** msg)
 {
-  MESSAGE_HEADER req;
-  P2P_hello_MESSAGE *reply;
+  GNUNET_MessageHeader req;
+  GNUNET_MessageHello *reply;
 
-  req.size = htons (sizeof (MESSAGE_HEADER));
+  req.size = htons (sizeof (GNUNET_MessageHeader));
   req.type = htons (CS_PROTO_identity_request_HELLO);
-  if (SYSERR == connection_write (sock, &req))
-    return SYSERR;
-  if (OK != connection_read (sock, (MESSAGE_HEADER **) & reply))
+  if (GNUNET_SYSERR == GNUNET_client_connection_write (sock, &req))
+    return GNUNET_SYSERR;
+  if (GNUNET_OK !=
+      GNUNET_client_connection_read (sock, (GNUNET_MessageHeader **) & reply))
     {
-      connection_close_temporarily (sock);
-      return SYSERR;
+      GNUNET_client_connection_close_temporarily (sock);
+      return GNUNET_SYSERR;
     }
-  if ((ntohs (reply->header.size) < sizeof (P2P_hello_MESSAGE)) ||
+  if ((ntohs (reply->header.size) < sizeof (GNUNET_MessageHello)) ||
       (ntohs (reply->header.type) != CS_PROTO_identity_HELLO) ||
-      (ntohs (reply->header.size) != P2P_hello_MESSAGE_size (reply)))
+      (ntohs (reply->header.size) != GNUNET_sizeof_hello (reply)))
     {
-      FREE (reply);
-      return SYSERR;
+      GNUNET_free (reply);
+      return GNUNET_SYSERR;
     }
   reply->header.type = htons (p2p_PROTO_hello);
   *msg = reply;
-  return OK;
+  return GNUNET_OK;
 }
 
 
 /**
  * Request the peer to connect to another peer
- * @return SYSERR on error, YES if connection is now there
- *         NO if connection is not yet present
+ * @return GNUNET_SYSERR on error, GNUNET_YES if connection is now there
+ *         GNUNET_NO if connection is not yet present
  */
 int
-gnunet_identity_request_connect (struct ClientServerConnection *sock,
-                                 const PeerIdentity * peer)
+GNUNET_IDENTITY_request_connect (struct GNUNET_ClientServerConnection *sock,
+                                 const GNUNET_PeerIdentity * peer)
 {
 
   CS_identity_connect_MESSAGE msg;
@@ -157,45 +160,46 @@
   msg.header.type = htons (CS_PROTO_identity_CONNECT);
   msg.header.size = htons (sizeof (CS_identity_connect_MESSAGE));
   msg.other = *peer;
-  if (SYSERR == connection_write (sock, &msg.header))
-    return SYSERR;
-  if (SYSERR == connection_read_result (sock, &result))
-    return SYSERR;
+  if (GNUNET_SYSERR == GNUNET_client_connection_write (sock, &msg.header))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR == GNUNET_client_connection_read_result (sock, &result))
+    return GNUNET_SYSERR;
   return result;
 }
 
 /**
  * Request information about all known peers
  *
- * @return SYSERR if iteration was aborted,
+ * @return GNUNET_SYSERR if iteration was aborted,
  *         otherwise number of peers known
  */
 int
-gnunet_identity_request_peer_infos (struct ClientServerConnection *sock,
-                                    GNUnetIdentityPeerInfoCallback callback,
+GNUNET_IDENTITY_request_peer_infos (struct GNUNET_ClientServerConnection
+                                    *sock,
+                                    GNUNET_IDENTITY_PeerInfoCallback callback,
                                     void *cls)
 {
-  MESSAGE_HEADER req;
-  MESSAGE_HEADER *reply;
+  GNUNET_MessageHeader req;
+  GNUNET_MessageHeader *reply;
   CS_identity_peer_info_MESSAGE *info;
   unsigned int count;
 
-  req.size = htons (sizeof (MESSAGE_HEADER));
+  req.size = htons (sizeof (GNUNET_MessageHeader));
   req.type = htons (CS_PROTO_identity_request_INFO);
-  if (SYSERR == connection_write (sock, &req))
-    return SYSERR;
+  if (GNUNET_SYSERR == GNUNET_client_connection_write (sock, &req))
+    return GNUNET_SYSERR;
   count = 0;
-  while (OK == connection_read (sock, &reply))
+  while (GNUNET_OK == GNUNET_client_connection_read (sock, &reply))
     {
-      if (ntohs (reply->size) < sizeof (MESSAGE_HEADER))
+      if (ntohs (reply->size) < sizeof (GNUNET_MessageHeader))
         {
           GE_BREAK (NULL, 0);
-          FREE (reply);
-          return SYSERR;
+          GNUNET_free (reply);
+          return GNUNET_SYSERR;
         }
       if (ntohs (reply->type) == CS_PROTO_RETURN_VALUE)
         {
-          FREE (reply);
+          GNUNET_free (reply);
           return count;
         }
       count++;
@@ -203,27 +207,27 @@
           (ntohs (reply->size) < sizeof (CS_identity_peer_info_MESSAGE)))
         {
           GE_BREAK (NULL, 0);
-          FREE (reply);
-          return SYSERR;
+          GNUNET_free (reply);
+          return GNUNET_SYSERR;
         }
       if (callback != NULL)
         {
           info = (CS_identity_peer_info_MESSAGE *) reply;
-          if (OK != callback (cls,
-                              &info->peer,
-                              &info[1],
-                              ntohs (reply->size) -
-                              sizeof (CS_identity_peer_info_MESSAGE),
-                              ntohll (info->last_message),
-                              ntohl (info->trust), ntohl (info->bpm)))
+          if (GNUNET_OK != callback (cls,
+                                     &info->peer,
+                                     &info[1],
+                                     ntohs (reply->size) -
+                                     sizeof (CS_identity_peer_info_MESSAGE),
+                                     GNUNET_ntohll (info->last_message),
+                                     ntohl (info->trust), ntohl (info->bpm)))
             {
-              FREE (reply);
-              return SYSERR;
+              GNUNET_free (reply);
+              return GNUNET_SYSERR;
             }
         }
-      FREE (reply);
+      GNUNET_free (reply);
     }
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 

Modified: GNUnet/src/applications/identity/hostkey.c
===================================================================
--- GNUnet/src/applications/identity/hostkey.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/identity/hostkey.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -40,19 +40,19 @@
  * The SECRET hostkey.  Keep local, never export outside of this
  * module!
  */
-static struct PrivateKey *hostkey;
+static struct GNUNET_RSA_PrivateKey *hostkey;
 
 /**
  * The public hostkey
  */
-static PublicKey publicKey;
+static GNUNET_RSA_PublicKey publicKey;
 
 /**
  * Get the public key of the host
  *
  * @return reference to the public key. Do not free it!
  */
-const PublicKey *
+const GNUNET_RSA_PublicKey *
 getPublicPrivateKey ()
 {
   return &publicKey;
@@ -61,18 +61,21 @@
 /**
  * Sign arbitrary data. ALWAYS use only on data we generated
  * entirely!
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 int
-signData (const void *data, unsigned short size, Signature * result)
+signData (const void *data, unsigned short size,
+          GNUNET_RSA_Signature * result)
 {
   int ret;
 
-  ret = sign (hostkey, size, data, result);
+  ret = GNUNET_RSA_sign (hostkey, size, data, result);
 #if EXTRA_CHECKS
-  if (ret == OK)
+  if (ret == GNUNET_OK)
     {
-      GE_ASSERT (NULL, OK == verifySig (data, size, result, &publicKey));
+      GE_ASSERT (NULL,
+                 GNUNET_OK == GNUNET_RSA_verify (data, size, result,
+                                                 &publicKey));
     }
 #endif
   return ret;
@@ -88,9 +91,10 @@
  * @returns the size of the decrypted block, -1 on error
  */
 int
-decryptData (const RSAEncryptedData * block, void *result, unsigned int max)
+decryptData (const GNUNET_RSA_EncryptedData * block, void *result,
+             unsigned int max)
 {
-  return decryptPrivateKey (hostkey, block, result, max);
+  return GNUNET_RSA_decrypt (hostkey, block, result, max);
 }
 
 void
@@ -98,7 +102,7 @@
 {
   char *gnHome;
   char *hostkeyfile;
-  PrivateKeyEncoded *encPrivateKey;
+  GNUNET_RSA_PrivateKeyEncoded *encPrivateKey;
   unsigned short len;
   int res;
 
@@ -108,8 +112,8 @@
                                                         "GNUNETD_HOME",
                                                         VAR_DAEMON_DIRECTORY,
                                                         &gnHome));
-  disk_directory_create (ectx, gnHome);
-  if (YES != disk_directory_test (ectx, gnHome))
+  GNUNET_disk_directory_create (ectx, gnHome);
+  if (GNUNET_YES != GNUNET_disk_directory_test (ectx, gnHome))
     {
       GE_LOG (ectx,
               GE_FATAL | GE_ADMIN | GE_USER | GE_IMMEDIATE,
@@ -118,25 +122,29 @@
     }
 
   /* read or create public key */
-  hostkeyfile = MALLOC (strlen (gnHome) + strlen (HOSTKEYFILE) + 2);
+  hostkeyfile = GNUNET_malloc (strlen (gnHome) + strlen (HOSTKEYFILE) + 2);
   strcpy (hostkeyfile, gnHome);
-  FREE (gnHome);
+  GNUNET_free (gnHome);
   if (hostkeyfile[strlen (hostkeyfile) - 1] != DIR_SEPARATOR)
     strcat (hostkeyfile, DIR_SEPARATOR_STR);
   strcat (hostkeyfile, HOSTKEYFILE);
   res = 0;
-  if (YES == disk_file_test (ectx, hostkeyfile))
+  if (GNUNET_YES == GNUNET_disk_file_test (ectx, hostkeyfile))
     {
-      res = disk_file_read (ectx, hostkeyfile, sizeof (unsigned short), &len);
+      res =
+        GNUNET_disk_file_read (ectx, hostkeyfile, sizeof (unsigned short),
+                               &len);
     }
   encPrivateKey = NULL;
   if (res == sizeof (unsigned short))
     {
-      encPrivateKey = (PrivateKeyEncoded *) MALLOC (ntohs (len));
+      encPrivateKey =
+        (GNUNET_RSA_PrivateKeyEncoded *) GNUNET_malloc (ntohs (len));
       if (ntohs (len) !=
-          disk_file_read (ectx, hostkeyfile, ntohs (len), encPrivateKey))
+          GNUNET_disk_file_read (ectx, hostkeyfile, ntohs (len),
+                                 encPrivateKey))
         {
-          FREE (encPrivateKey);
+          GNUNET_free (encPrivateKey);
           GE_LOG (ectx,
                   GE_WARNING | GE_USER | GE_IMMEDIATE | GE_ADMIN,
                   _
@@ -150,25 +158,26 @@
       GE_LOG (ectx,
               GE_INFO | GE_USER | GE_BULK,
               _("Creating new hostkey (this may take a while).\n"));
-      hostkey = makePrivateKey ();
+      hostkey = GNUNET_RSA_create_key ();
       GE_ASSERT (ectx, hostkey != NULL);
-      encPrivateKey = encodePrivateKey (hostkey);
+      encPrivateKey = GNUNET_RSA_encode_key (hostkey);
       GE_ASSERT (ectx, encPrivateKey != NULL);
-      disk_file_write (ectx,
-                       hostkeyfile,
-                       encPrivateKey, ntohs (encPrivateKey->len), "600");
-      FREE (encPrivateKey);
+      GNUNET_disk_file_write (ectx,
+                              hostkeyfile,
+                              encPrivateKey, ntohs (encPrivateKey->len),
+                              "600");
+      GNUNET_free (encPrivateKey);
       GE_LOG (ectx,
               GE_INFO | GE_USER | GE_BULK, _("Done creating hostkey.\n"));
     }
   else
     {
-      hostkey = decodePrivateKey (encPrivateKey);
-      FREE (encPrivateKey);
+      hostkey = GNUNET_RSA_decode_key (encPrivateKey);
+      GNUNET_free (encPrivateKey);
     }
-  FREE (hostkeyfile);
+  GNUNET_free (hostkeyfile);
   GE_ASSERT (ectx, hostkey != NULL);
-  getPublicKey (hostkey, &publicKey);
+  GNUNET_RSA_get_public_key (hostkey, &publicKey);
 }
 
 
@@ -176,7 +185,7 @@
 donePrivateKey ()
 {
   GE_ASSERT (NULL, hostkey != NULL);
-  freePrivateKey (hostkey);
+  GNUNET_RSA_free_key (hostkey);
   hostkey = NULL;
 }
 

Modified: GNUnet/src/applications/identity/hostkey.h
===================================================================
--- GNUnet/src/applications/identity/hostkey.h  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/identity/hostkey.h  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -35,14 +35,15 @@
  * Get the public key of the host
  * @return reference to the public key. Do not free it!
  */
-const PublicKey *getPublicPrivateKey (void);
+const GNUNET_RSA_PublicKey *getPublicPrivateKey (void);
 
 /**
  * Sign arbitrary data. ALWAYS use only on data we generated
  * entirely!
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
-int signData (const void *data, unsigned short size, Signature * result);
+int signData (const void *data, unsigned short size,
+              GNUNET_RSA_Signature * result);
 
 /**
  * Decrypt a given block with the hostkey.
@@ -52,7 +53,7 @@
  *        the decrypted block is bigger, an error is returned
  * @returns the size of the decrypted block, -1 on error
  */
-int decryptData (const RSAEncryptedData * block,
+int decryptData (const GNUNET_RSA_EncryptedData * block,
                  void *result, unsigned int max);
 
 

Modified: GNUnet/src/applications/identity/identity.c
===================================================================
--- GNUnet/src/applications/identity/identity.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/identity/identity.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -40,7 +40,7 @@
 #include "identity.h"
 #include "hostkey.h"
 
-#define DEBUG_IDENTITY NO
+#define DEBUG_IDENTITY GNUNET_NO
 
 #define MAX_TEMP_HOSTS 32
 
@@ -55,35 +55,35 @@
 
 #define TRUST_ACTUAL_MASK  0x7FFFFFFF
 
-#define MAX_DATA_HOST_FREQ (5 * cronMINUTES)
+#define MAX_DATA_HOST_FREQ (5 * GNUNET_CRON_MINUTES)
 
-#define CRON_DATA_HOST_FREQ (15 * cronMINUTES)
+#define CRON_DATA_HOST_FREQ (15 * GNUNET_CRON_MINUTES)
 
-#define CRON_TRUST_FLUSH_FREQ (5 * cronMINUTES)
+#define CRON_TRUST_FLUSH_FREQ (5 * GNUNET_CRON_MINUTES)
 
-#define CRON_DISCARD_HOSTS_INTERVAL (cronDAYS)
+#define CRON_DISCARD_HOSTS_INTERVAL (GNUNET_CRON_DAYS)
 
-#define CRON_DISCARDS_HOSTS_AFTER (3 * cronMONTHS)
+#define CRON_DISCARDS_HOSTS_AFTER (3 * GNUNET_CRON_MONTHS)
 
 typedef struct
 {
 
-  PeerIdentity identity;
+  GNUNET_PeerIdentity identity;
 
   /**
    * How long is this host blacklisted? (if at all)
    */
-  cron_t until;
+  GNUNET_CronTime until;
 
   /**
    * what would be the next increment for blacklisting?
    */
-  cron_t delta;
+  GNUNET_CronTime delta;
 
   /**
    * hellos for the peer (maybe NULL)!
    */
-  P2P_hello_MESSAGE **hellos;
+  GNUNET_MessageHello **hellos;
 
   unsigned int helloCount;
 
@@ -95,7 +95,7 @@
   unsigned int protocolCount;
 
   /**
-   * should we also reject incoming messages? (YES/NO)
+   * should we also reject incoming messages? (GNUNET_YES/GNUNET_NO)
    */
   int strict;
 
@@ -124,7 +124,7 @@
 /**
  * A lock for accessing knownHosts
  */
-static struct MUTEX *lock_;
+static struct GNUNET_Mutex *lock_;
 
 /**
  * Directory where the hellos are stored in (data/hosts)
@@ -141,28 +141,29 @@
  */
 static HostEntry tempHosts[MAX_TEMP_HOSTS];
 
-static PeerIdentity myIdentity;
+static GNUNET_PeerIdentity myIdentity;
 
 static struct GE_Context *ectx;
 
 static CoreAPIForApplication *coreAPI;
 
 /**
- * Get the filename under which we would store the P2P_hello_MESSAGE
+ * Get the filename under which we would store the GNUNET_MessageHello
  * for the given host and protocol.
  * @return filename of the form DIRECTORY/HOSTID.PROTOCOL
  */
 static char *
-getHostFileName (const PeerIdentity * id, unsigned short protocol)
+getHostFileName (const GNUNET_PeerIdentity * id, unsigned short protocol)
 {
-  EncName fil;
+  GNUNET_EncName fil;
   char *fn;
   size_t n;
 
-  hash2enc (&id->hashPubKey, &fil);
-  n = strlen (networkIdDirectory) + sizeof (EncName) + 1 + 5 + 1;
-  fn = MALLOC (n);
-  SNPRINTF (fn, n, "%s%s.%u", networkIdDirectory, (char *) &fil, protocol);
+  GNUNET_hash_to_enc (&id->hashPubKey, &fil);
+  n = strlen (networkIdDirectory) + sizeof (GNUNET_EncName) + 1 + 5 + 1;
+  fn = GNUNET_malloc (n);
+  GNUNET_snprintf (fn, n, "%s%s.%u", networkIdDirectory, (char *) &fil,
+                   protocol);
   return fn;
 }
 
@@ -172,13 +173,14 @@
  * @return NULL if not found
  */
 static HostEntry *
-findHost (const PeerIdentity * id)
+findHost (const GNUNET_PeerIdentity * id)
 {
   int i;
 
   GE_ASSERT (ectx, numberOfHosts_ <= sizeOfHosts_);
   for (i = 0; i < numberOfHosts_; i++)
-    if ((0 == memcmp (id, &hosts_[i]->identity, sizeof (PeerIdentity))))
+    if ((0 ==
+         memcmp (id, &hosts_[i]->identity, sizeof (GNUNET_PeerIdentity))))
       return hosts_[i];
   return NULL;
 }
@@ -190,37 +192,38 @@
  * @param protocol the protocol for the host
  */
 static void
-addHostToKnown (const PeerIdentity * identity, unsigned short protocol)
+addHostToKnown (const GNUNET_PeerIdentity * identity, unsigned short protocol)
 {
   HostEntry *entry;
   int i;
-  EncName fil;
+  GNUNET_EncName fil;
   char *fn;
   unsigned int trust;
 
   GE_ASSERT (ectx, numberOfHosts_ <= sizeOfHosts_);
-  MUTEX_LOCK (lock_);
+  GNUNET_mutex_lock (lock_);
   entry = findHost (identity);
   if (entry == NULL)
     {
-      entry = MALLOC (sizeof (HostEntry));
+      entry = GNUNET_malloc (sizeof (HostEntry));
 
       entry->identity = *identity;
       entry->until = 0;
-      entry->delta = 30 * cronSECONDS;
+      entry->delta = 30 * GNUNET_CRON_SECONDS;
       entry->protocols = NULL;
       entry->protocolCount = 0;
-      entry->strict = NO;
+      entry->strict = GNUNET_NO;
       entry->hellos = NULL;
       entry->helloCount = 0;
-      hash2enc (&identity->hashPubKey, &fil);
-      fn = MALLOC (strlen (trustDirectory) + sizeof (EncName) + 1);
+      GNUNET_hash_to_enc (&identity->hashPubKey, &fil);
+      fn =
+        GNUNET_malloc (strlen (trustDirectory) + sizeof (GNUNET_EncName) + 1);
       strcpy (fn, trustDirectory);
       strcat (fn, (char *) &fil);
-      if ((disk_file_test (ectx,
-                           fn) == YES) &&
+      if ((GNUNET_disk_file_test (ectx,
+                                  fn) == GNUNET_YES) &&
           (sizeof (unsigned int) ==
-           disk_file_read (ectx, fn, sizeof (unsigned int), &trust)))
+           GNUNET_disk_file_read (ectx, fn, sizeof (unsigned int), &trust)))
         {
           entry->trust = ntohl (trust);
         }
@@ -228,23 +231,24 @@
         {
           entry->trust = 0;
         }
-      FREE (fn);
+      GNUNET_free (fn);
 
       if (numberOfHosts_ == sizeOfHosts_)
-        GROW (hosts_, sizeOfHosts_, sizeOfHosts_ + 32);
+        GNUNET_array_grow (hosts_, sizeOfHosts_, sizeOfHosts_ + 32);
       hosts_[numberOfHosts_++] = entry;
     }
   for (i = 0; i < entry->protocolCount; i++)
     {
       if (entry->protocols[i] == protocol)
         {
-          MUTEX_UNLOCK (lock_);
+          GNUNET_mutex_unlock (lock_);
           return;               /* already there */
         }
     }
-  GROW (entry->protocols, entry->protocolCount, entry->protocolCount + 1);
+  GNUNET_array_grow (entry->protocols, entry->protocolCount,
+                     entry->protocolCount + 1);
   entry->protocols[entry->protocolCount - 1] = protocol;
-  MUTEX_UNLOCK (lock_);
+  GNUNET_mutex_unlock (lock_);
 }
 
 /**
@@ -256,14 +260,14 @@
  * @returns the actual change in trust (positive or negative)
  */
 static int
-changeHostTrust (const PeerIdentity * hostId, int value)
+changeHostTrust (const GNUNET_PeerIdentity * hostId, int value)
 {
   HostEntry *host;
 
   if (value == 0)
     return 0;
 
-  MUTEX_LOCK (lock_);
+  GNUNET_mutex_lock (lock_);
   host = findHost (hostId);
   if (host == NULL)
     {
@@ -272,7 +276,7 @@
       if (host == NULL)
         {
           GE_BREAK (ectx, 0);
-          MUTEX_UNLOCK (lock_);
+          GNUNET_mutex_unlock (lock_);
           return 0;
         }
     }
@@ -286,7 +290,7 @@
       host->trust = ((host->trust & TRUST_ACTUAL_MASK) + value)
         | TRUST_REFRESH_MASK;
     }
-  MUTEX_UNLOCK (lock_);
+  GNUNET_mutex_unlock (lock_);
   return value;
 }
 
@@ -297,18 +301,18 @@
  * @return the amount of trust we currently have in that peer
  */
 static unsigned int
-getHostTrust (const PeerIdentity * hostId)
+getHostTrust (const GNUNET_PeerIdentity * hostId)
 {
   HostEntry *host;
   unsigned int trust;
 
-  MUTEX_LOCK (lock_);
+  GNUNET_mutex_lock (lock_);
   host = findHost (hostId);
   if (host == NULL)
     trust = 0;
   else
     trust = host->trust & TRUST_ACTUAL_MASK;
-  MUTEX_UNLOCK (lock_);
+  GNUNET_mutex_unlock (lock_);
   return trust;
 }
 
@@ -316,27 +320,29 @@
 static int
 cronHelper (const char *filename, const char *dirname, void *unused)
 {
-  PeerIdentity identity;
-  EncName id;
+  GNUNET_PeerIdentity identity;
+  GNUNET_EncName id;
   unsigned int protoNumber;
   char *fullname;
 
   GE_ASSERT (ectx, numberOfHosts_ <= sizeOfHosts_);
-  GE_ASSERT (ectx, sizeof (EncName) == 104);
+  GE_ASSERT (ectx, sizeof (GNUNET_EncName) == 104);
   if (2 == sscanf (filename, "%103c.%u", (char *) &id, &protoNumber))
     {
-      id.encoding[sizeof (EncName) - 1] = '\0';
-      if (OK == enc2hash ((char *) &id, &identity.hashPubKey))
+      id.encoding[sizeof (GNUNET_EncName) - 1] = '\0';
+      if (GNUNET_OK ==
+          GNUNET_enc_to_hash ((char *) &id, &identity.hashPubKey))
         {
           addHostToKnown (&identity, (unsigned short) protoNumber);
-          return OK;
+          return GNUNET_OK;
         }
     }
 
-  fullname = MALLOC (strlen (filename) + strlen (networkIdDirectory) + 1);
+  fullname =
+    GNUNET_malloc (strlen (filename) + strlen (networkIdDirectory) + 1);
   strcpy (fullname, networkIdDirectory);
   strcat (fullname, filename);
-  if (disk_file_test (ectx, fullname) == YES)
+  if (GNUNET_disk_file_test (ectx, fullname) == GNUNET_YES)
     {
       if (0 == UNLINK (fullname))
         GE_LOG (ectx,
@@ -349,7 +355,7 @@
                               GE_ERROR | GE_USER | GE_BULK,
                               "unlink", fullname);
     }
-  else if (disk_directory_test (ectx, fullname) == YES)
+  else if (GNUNET_disk_directory_test (ectx, fullname) == GNUNET_YES)
     {
       if (0 == RMDIR (fullname))
         GE_LOG (ectx,
@@ -362,8 +368,8 @@
                               GE_ERROR | GE_USER | GE_BULK,
                               "rmdir", fullname);
     }
-  FREE (fullname);
-  return OK;
+  GNUNET_free (fullname);
+  return GNUNET_OK;
 }
 
 /**
@@ -372,17 +378,18 @@
 static void
 cronScanDirectoryDataHosts (void *unused)
 {
-  static cron_t lastRun;
+  static GNUNET_CronTime lastRun;
   static int retries;
   int count;
-  cron_t now;
+  GNUNET_CronTime now;
 
-  now = get_time ();
+  now = GNUNET_get_time ();
   if (lastRun + MAX_DATA_HOST_FREQ > now)
     return;                     /* prevent scanning more than
                                    once every 5 min */
   lastRun = now;
-  count = disk_directory_scan (ectx, networkIdDirectory, &cronHelper, NULL);
+  count =
+    GNUNET_disk_directory_scan (ectx, networkIdDirectory, &cronHelper, NULL);
   if (count <= 0)
     {
       retries++;
@@ -403,15 +410,17 @@
  * @param result address where to write the identity of the node
  */
 static void
-getPeerIdentity (const PublicKey * pubKey, PeerIdentity * result)
+getPeerIdentity (const GNUNET_RSA_PublicKey * pubKey,
+                 GNUNET_PeerIdentity * result)
 {
   if (pubKey == NULL)
     {
-      memset (&result, 0, sizeof (PeerIdentity));
+      memset (&result, 0, sizeof (GNUNET_PeerIdentity));
     }
   else
     {
-      hash (pubKey, sizeof (PublicKey), &result->hashPubKey);
+      GNUNET_hash (pubKey, sizeof (GNUNET_RSA_PublicKey),
+                   &result->hashPubKey);
     }
 }
 
@@ -419,34 +428,34 @@
  * Add a host to the temporary list.
  */
 static void
-addHostTemporarily (const P2P_hello_MESSAGE * tmp)
+addHostTemporarily (const GNUNET_MessageHello * tmp)
 {
   static int tempHostsNextSlot;
-  P2P_hello_MESSAGE *msg;
+  GNUNET_MessageHello *msg;
   HostEntry *entry;
   int i;
   int slot;
-  PeerIdentity have;
+  GNUNET_PeerIdentity have;
 
   getPeerIdentity (&tmp->publicKey, &have);
-  if (0 != memcmp (&have, &tmp->senderIdentity, sizeof (PeerIdentity)))
+  if (0 != memcmp (&have, &tmp->senderIdentity, sizeof (GNUNET_PeerIdentity)))
     {
       GE_BREAK (NULL, 0);
       return;
     }
-  MUTEX_LOCK (lock_);
+  GNUNET_mutex_lock (lock_);
   entry = findHost (&tmp->senderIdentity);
   if ((entry != NULL) && (entry->helloCount > 0))
     {
-      MUTEX_UNLOCK (lock_);
+      GNUNET_mutex_unlock (lock_);
       return;
     }
-  msg = MALLOC (P2P_hello_MESSAGE_size (tmp));
-  memcpy (msg, tmp, P2P_hello_MESSAGE_size (tmp));
+  msg = GNUNET_malloc (GNUNET_sizeof_hello (tmp));
+  memcpy (msg, tmp, GNUNET_sizeof_hello (tmp));
   slot = tempHostsNextSlot;
   for (i = 0; i < MAX_TEMP_HOSTS; i++)
     if (0 == memcmp (&tmp->senderIdentity,
-                     &tempHosts[i].identity, sizeof (PeerIdentity)))
+                     &tempHosts[i].identity, sizeof (GNUNET_PeerIdentity)))
       slot = i;
   if (slot == tempHostsNextSlot)
     {
@@ -459,21 +468,22 @@
   entry->until = 0;
   entry->delta = 0;
   for (i = 0; i < entry->helloCount; i++)
-    FREE (entry->hellos[i]);
-  GROW (entry->hellos, entry->helloCount, 1);
-  GROW (entry->protocols, entry->protocolCount, 1);
+    GNUNET_free (entry->hellos[i]);
+  GNUNET_array_grow (entry->hellos, entry->helloCount, 1);
+  GNUNET_array_grow (entry->protocols, entry->protocolCount, 1);
   entry->hellos[0] = msg;
   entry->protocols[0] = ntohs (msg->protocol);
-  entry->strict = NO;
+  entry->strict = GNUNET_NO;
   entry->trust = 0;
-  MUTEX_UNLOCK (lock_);
+  GNUNET_mutex_unlock (lock_);
 }
 
 /**
  * Delete a host from the list.
  */
 static void
-delHostFromKnown (const PeerIdentity * identity, unsigned short protocol)
+delHostFromKnown (const GNUNET_PeerIdentity * identity,
+                  unsigned short protocol)
 {
   HostEntry *entry;
   char *fn;
@@ -482,11 +492,11 @@
 
   GE_ASSERT (ectx, numberOfHosts_ <= sizeOfHosts_);
   GE_ASSERT (ectx, protocol != ANY_PROTOCOL_NUMBER);
-  MUTEX_LOCK (lock_);
+  GNUNET_mutex_lock (lock_);
   for (i = 0; i < numberOfHosts_; i++)
     {
       if ((0 == memcmp (identity,
-                        &hosts_[i]->identity, sizeof (PeerIdentity))))
+                        &hosts_[i]->identity, sizeof (GNUNET_PeerIdentity))))
         {
           entry = hosts_[i];
           for (j = 0; j < entry->protocolCount; j++)
@@ -495,18 +505,20 @@
                 {
                   entry->protocols[j]
                     = entry->protocols[entry->protocolCount - 1];
-                  GROW (entry->protocols,
-                        entry->protocolCount, entry->protocolCount - 1);
+                  GNUNET_array_grow (entry->protocols,
+                                     entry->protocolCount,
+                                     entry->protocolCount - 1);
                 }
             }
           for (j = 0; j < entry->helloCount; j++)
             {
               if (protocol == ntohs (entry->hellos[j]->protocol))
                 {
-                  FREE (entry->hellos[j]);
+                  GNUNET_free (entry->hellos[j]);
                   entry->hellos[j] = entry->hellos[entry->helloCount - 1];
-                  GROW (entry->hellos,
-                        entry->helloCount, entry->helloCount - 1);
+                  GNUNET_array_grow (entry->hellos,
+                                     entry->helloCount,
+                                     entry->helloCount - 1);
                 }
             }
           /* also remove hello file itself */
@@ -515,25 +527,25 @@
             GE_LOG_STRERROR_FILE (ectx,
                                   GE_WARNING | GE_USER | GE_BULK,
                                   "unlink", fn);
-          FREE (fn);
+          GNUNET_free (fn);
 
           if (entry->protocolCount == 0)
             {
               if (entry->helloCount > 0)
                 {
                   for (j = 0; j < entry->helloCount; j++)
-                    FREE (entry->hellos[j]);
-                  GROW (entry->hellos, entry->helloCount, 0);
+                    GNUNET_free (entry->hellos[j]);
+                  GNUNET_array_grow (entry->hellos, entry->helloCount, 0);
                 }
               hosts_[i] = hosts_[--numberOfHosts_];
-              FREE (entry);
+              GNUNET_free (entry);
             }
-          MUTEX_UNLOCK (lock_);
+          GNUNET_mutex_unlock (lock_);
           GE_ASSERT (ectx, numberOfHosts_ <= sizeOfHosts_);
           return;               /* deleted */
         }
     }
-  MUTEX_UNLOCK (lock_);
+  GNUNET_mutex_unlock (lock_);
 }
 
 /**
@@ -541,18 +553,18 @@
  * @param msg the verified (!) hello message
  */
 static void
-bindAddress (const P2P_hello_MESSAGE * msg)
+bindAddress (const GNUNET_MessageHello * msg)
 {
   char *fn;
   char *buffer;
-  P2P_hello_MESSAGE *oldMsg;
+  GNUNET_MessageHello *oldMsg;
   int size;
   HostEntry *host;
   int i;
-  PeerIdentity have;
+  GNUNET_PeerIdentity have;
 
   getPeerIdentity (&msg->publicKey, &have);
-  if (0 != memcmp (&have, &msg->senderIdentity, sizeof (PeerIdentity)))
+  if (0 != memcmp (&have, &msg->senderIdentity, sizeof (GNUNET_PeerIdentity)))
     {
       GE_BREAK (NULL, 0);
       return;
@@ -560,30 +572,30 @@
   GE_ASSERT (ectx, numberOfHosts_ <= sizeOfHosts_);
   GE_ASSERT (ectx, msg != NULL);
   fn = getHostFileName (&msg->senderIdentity, ntohs (msg->protocol));
-  buffer = MALLOC (MAX_BUFFER_SIZE);
-  if (disk_file_test (ectx, fn) == YES)
+  buffer = GNUNET_malloc (GNUNET_MAX_BUFFER_SIZE);
+  if (GNUNET_disk_file_test (ectx, fn) == GNUNET_YES)
     {
-      size = disk_file_read (ectx, fn, MAX_BUFFER_SIZE, buffer);
-      if (size >= sizeof (P2P_hello_MESSAGE))
+      size = GNUNET_disk_file_read (ectx, fn, GNUNET_MAX_BUFFER_SIZE, buffer);
+      if (size >= sizeof (GNUNET_MessageHello))
         {
-          oldMsg = (P2P_hello_MESSAGE *) buffer;
-          if ((unsigned int) size == P2P_hello_MESSAGE_size (oldMsg))
+          oldMsg = (GNUNET_MessageHello *) buffer;
+          if ((unsigned int) size == GNUNET_sizeof_hello (oldMsg))
             {
               if (ntohl (oldMsg->expirationTime) >
                   ntohl (msg->expirationTime))
                 {
-                  FREE (fn);
-                  FREE (buffer);
+                  GNUNET_free (fn);
+                  GNUNET_free (buffer);
                   return;       /* have more recent hello in stock */
                 }
             }
         }
     }
-  disk_file_write (ectx, fn, msg, P2P_hello_MESSAGE_size (msg), "644");
-  FREE (fn);
-  FREE (buffer);
+  GNUNET_disk_file_write (ectx, fn, msg, GNUNET_sizeof_hello (msg), "644");
+  GNUNET_free (fn);
+  GNUNET_free (buffer);
 
-  MUTEX_LOCK (lock_);
+  GNUNET_mutex_lock (lock_);
   addHostToKnown (&msg->senderIdentity, ntohs (msg->protocol));
   host = findHost (&msg->senderIdentity);
   GE_ASSERT (ectx, host != NULL);
@@ -592,16 +604,16 @@
     {
       if (msg->protocol == host->hellos[i]->protocol)
         {
-          FREE (host->hellos[i]);
+          GNUNET_free (host->hellos[i]);
           host->hellos[i] = NULL;
           break;
         }
     }
   if (i == host->helloCount)
-    GROW (host->hellos, host->helloCount, host->helloCount + 1);
-  host->hellos[i] = MALLOC (P2P_hello_MESSAGE_size (msg));
-  memcpy (host->hellos[i], msg, P2P_hello_MESSAGE_size (msg));
-  MUTEX_UNLOCK (lock_);
+    GNUNET_array_grow (host->hellos, host->helloCount, host->helloCount + 1);
+  host->hellos[i] = GNUNET_malloc (GNUNET_sizeof_hello (msg));
+  memcpy (host->hellos[i], msg, GNUNET_sizeof_hello (msg));
+  GNUNET_mutex_unlock (lock_);
   GE_ASSERT (ectx, numberOfHosts_ <= sizeOfHosts_);
 }
 
@@ -615,24 +627,24 @@
  *        ANY_PROTOCOL_NUMBER if we do not care which protocol
  * @param tryTemporaryList is it ok to check the unverified hellos?
  * @param result where to store the result
- * @returns SYSERR on failure, OK on success
+ * @returns GNUNET_SYSERR on failure, GNUNET_OK on success
  */
-static P2P_hello_MESSAGE *
-identity2Hello (const PeerIdentity * hostId,
+static GNUNET_MessageHello *
+identity2Hello (const GNUNET_PeerIdentity * hostId,
                 unsigned short protocol, int tryTemporaryList)
 {
-  P2P_hello_MESSAGE *result;
+  GNUNET_MessageHello *result;
   HostEntry *host;
   char *fn;
-  P2P_hello_MESSAGE buffer;
-  PeerIdentity have;
+  GNUNET_MessageHello buffer;
+  GNUNET_PeerIdentity have;
   int size;
   int i;
   int j;
 
   GE_ASSERT (ectx, numberOfHosts_ <= sizeOfHosts_);
-  MUTEX_LOCK (lock_);
-  if (YES == tryTemporaryList)
+  GNUNET_mutex_lock (lock_);
+  if (GNUNET_YES == tryTemporaryList)
     {
       /* ok, then first try temporary hosts
          (in memory, cheapest!) */
@@ -640,11 +652,15 @@
         {
           host = &tempHosts[i];
           if ((host->helloCount > 0) &&
-              (0 == memcmp (hostId, &host->identity, sizeof (PeerIdentity))))
+              (0 ==
+               memcmp (hostId, &host->identity,
+                       sizeof (GNUNET_PeerIdentity))))
             {
               if (protocol == ANY_PROTOCOL_NUMBER)
                 {
-                  j = weak_randomi (host->helloCount);
+                  j =
+                    GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+                                       host->helloCount);
                 }
               else
                 {
@@ -656,14 +672,13 @@
               if (j == host->helloCount)
                 {
                   /* not found */
-                  MUTEX_UNLOCK (lock_);
+                  GNUNET_mutex_unlock (lock_);
                   return NULL;
                 }
-              result = MALLOC (P2P_hello_MESSAGE_size (host->hellos[j]));
-              memcpy (result,
-                      host->hellos[j],
-                      P2P_hello_MESSAGE_size (host->hellos[j]));
-              MUTEX_UNLOCK (lock_);
+              result = GNUNET_malloc (GNUNET_sizeof_hello (host->hellos[j]));
+              memcpy (result, host->hellos[j],
+                      GNUNET_sizeof_hello (host->hellos[j]));
+              GNUNET_mutex_unlock (lock_);
               return result;
             }
         }
@@ -672,35 +687,39 @@
   host = findHost (hostId);
   if ((host == NULL) || (host->protocolCount == 0))
     {
-      MUTEX_UNLOCK (lock_);
+      GNUNET_mutex_unlock (lock_);
       return NULL;
     }
 
   if (protocol == ANY_PROTOCOL_NUMBER)
-    protocol = host->protocols[weak_randomi (host->protocolCount)];
+    protocol =
+      host->
+      protocols[GNUNET_random_u32
+                (GNUNET_RANDOM_QUALITY_WEAK, host->protocolCount)];
 
   for (i = 0; i < host->helloCount; i++)
     {
       if (ntohs (host->hellos[i]->protocol) == protocol)
         {
-          result = MALLOC (P2P_hello_MESSAGE_size (host->hellos[i]));
+          result = GNUNET_malloc (GNUNET_sizeof_hello (host->hellos[i]));
           memcpy (result,
-                  host->hellos[i], P2P_hello_MESSAGE_size (host->hellos[i]));
-          MUTEX_UNLOCK (lock_);
+                  host->hellos[i], GNUNET_sizeof_hello (host->hellos[i]));
+          GNUNET_mutex_unlock (lock_);
           return result;
         }
     }
 
   /* do direct read */
   fn = getHostFileName (hostId, protocol);
-  if (1 != disk_file_test (ectx, fn))
+  if (1 != GNUNET_disk_file_test (ectx, fn))
     {
-      FREE (fn);
-      MUTEX_UNLOCK (lock_);
+      GNUNET_free (fn);
+      GNUNET_mutex_unlock (lock_);
       return NULL;
     }
-  size = disk_file_read (ectx, fn, sizeof (P2P_hello_MESSAGE), &buffer);
-  if (size != sizeof (P2P_hello_MESSAGE))
+  size =
+    GNUNET_disk_file_read (ectx, fn, sizeof (GNUNET_MessageHello), &buffer);
+  if (size != sizeof (GNUNET_MessageHello))
     {
       if (0 == UNLINK (fn))
         GE_LOG (ectx,
@@ -710,18 +729,20 @@
         GE_LOG_STRERROR_FILE (ectx,
                               GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
                               "unlink", fn);
-      FREE (fn);
-      MUTEX_UNLOCK (lock_);
+      GNUNET_free (fn);
+      GNUNET_mutex_unlock (lock_);
       return NULL;
     }
-  result = MALLOC (P2P_hello_MESSAGE_size (&buffer));
-  size = disk_file_read (ectx, fn, P2P_hello_MESSAGE_size (&buffer), result);
+  result = GNUNET_malloc (GNUNET_sizeof_hello (&buffer));
+  size =
+    GNUNET_disk_file_read (ectx, fn, GNUNET_sizeof_hello (&buffer), result);
   getPeerIdentity (&result->publicKey, &have);
-  if (((unsigned int) size != P2P_hello_MESSAGE_size (&buffer)) ||
+  if (((unsigned int) size != GNUNET_sizeof_hello (&buffer)) ||
       (0 != memcmp (&have,
                     hostId,
-                    sizeof (PeerIdentity))) ||
-      (0 != memcmp (&have, &result->senderIdentity, sizeof (PeerIdentity))))
+                    sizeof (GNUNET_PeerIdentity))) ||
+      (0 !=
+       memcmp (&have, &result->senderIdentity, sizeof (GNUNET_PeerIdentity))))
     {
       if (0 == UNLINK (fn))
         GE_LOG (ectx,
@@ -731,18 +752,18 @@
         GE_LOG_STRERROR_FILE (ectx,
                               GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
                               "unlink", fn);
-      FREE (fn);
-      FREE (result);
-      MUTEX_UNLOCK (lock_);
+      GNUNET_free (fn);
+      GNUNET_free (result);
+      GNUNET_mutex_unlock (lock_);
       return NULL;
     }
-  FREE (fn);
-  GROW (host->hellos, host->helloCount, host->helloCount + 1);
+  GNUNET_free (fn);
+  GNUNET_array_grow (host->hellos, host->helloCount, host->helloCount + 1);
   host->hellos[host->helloCount - 1]
-    = MALLOC (P2P_hello_MESSAGE_size (&buffer));
+    = GNUNET_malloc (GNUNET_sizeof_hello (&buffer));
   memcpy (host->hellos[host->helloCount - 1],
-          result, P2P_hello_MESSAGE_size (&buffer));
-  MUTEX_UNLOCK (lock_);
+          result, GNUNET_sizeof_hello (&buffer));
+  GNUNET_mutex_unlock (lock_);
   return result;
 }
 
@@ -753,37 +774,38 @@
  * @param message the signed message
  * @param size the size of the message
  * @param sig the signature
- * @return OK on success, SYSERR on error (verification failed)
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error (verification failed)
  */
 static int
-verifyPeerSignature (const PeerIdentity * signer,
-                     const void *message, int size, const Signature * sig)
+verifyPeerSignature (const GNUNET_PeerIdentity * signer,
+                     const void *message, int size,
+                     const GNUNET_RSA_Signature * sig)
 {
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
   int res;
 
-  hello = identity2Hello (signer, ANY_PROTOCOL_NUMBER, YES);
+  hello = identity2Hello (signer, ANY_PROTOCOL_NUMBER, GNUNET_YES);
   if (hello == NULL)
     {
 #if DEBUG_IDENTITY
-      EncName enc;
+      GNUNET_EncName enc;
 
       IF_GELOG (ectx,
                 GE_INFO | GE_USER | GE_BULK,
-                hash2enc (&signer->hashPubKey, &enc));
+                GNUNET_hash_to_enc (&signer->hashPubKey, &enc));
       GE_LOG (ectx,
               GE_INFO | GE_USER | GE_BULK,
               _("Signature failed verification: peer `%s' not known.\n"),
               &enc);
 #endif
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  res = verifySig (message, size, sig, &hello->publicKey);
-  if (res == SYSERR)
+  res = GNUNET_RSA_verify (message, size, sig, &hello->publicKey);
+  if (res == GNUNET_SYSERR)
     GE_LOG (ectx,
             GE_ERROR | GE_REQUEST | GE_DEVELOPER | GE_USER,
             _("Signature failed verification: signature invalid.\n"));
-  FREE (hello);
+  GNUNET_free (hello);
   return res;
 }
 
@@ -794,26 +816,27 @@
  * @param identity the ID of the peer to blacklist
  * @param desperation how desperate are we to connect? [0,MAXHOSTS]
  * @param strict should we reject incoming connection attempts as well?
- * @return OK on success SYSERR on error
+ * @return GNUNET_OK on success GNUNET_SYSERR on error
  */
 static int
-blacklistHost (const PeerIdentity * identity,
+blacklistHost (const GNUNET_PeerIdentity * identity,
                unsigned int desperation, int strict)
 {
-  EncName hn;
+  GNUNET_EncName hn;
   HostEntry *entry;
   int i;
-  cron_t now;
+  GNUNET_CronTime now;
 
   GE_ASSERT (ectx, numberOfHosts_ <= sizeOfHosts_);
-  MUTEX_LOCK (lock_);
+  GNUNET_mutex_lock (lock_);
   entry = findHost (identity);
   if (entry == NULL)
     {
       for (i = 0; i < MAX_TEMP_HOSTS; i++)
         {
           if (0 == memcmp (identity,
-                           &tempHosts[i].identity, sizeof (PeerIdentity)))
+                           &tempHosts[i].identity,
+                           sizeof (GNUNET_PeerIdentity)))
             {
               entry = &tempHosts[i];
               break;
@@ -822,85 +845,90 @@
     }
   if (entry == NULL)
     {
-      MUTEX_UNLOCK (lock_);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock_);
+      return GNUNET_SYSERR;
     }
-  now = get_time ();
-  if ((entry->strict == YES) && (strict == NO))
+  now = GNUNET_get_time ();
+  if ((entry->strict == GNUNET_YES) && (strict == GNUNET_NO))
     {
       /* stronger blacklisting in place! */
-      MUTEX_UNLOCK (lock_);
-      return OK;
+      GNUNET_mutex_unlock (lock_);
+      return GNUNET_OK;
     }
   if (strict)
     {
-      entry->delta = desperation * cronSECONDS;
+      entry->delta = desperation * GNUNET_CRON_SECONDS;
     }
   else
     {
       if (entry->until < now)
-        entry->delta = weak_randomi (1 + desperation * cronSECONDS);
+        entry->delta =
+          GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+                             1 + desperation * GNUNET_CRON_SECONDS);
       else
-        entry->delta += weak_randomi (1 + desperation * cronSECONDS);
+        entry->delta +=
+          GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+                             1 + desperation * GNUNET_CRON_SECONDS);
     }
-  if (entry->delta > 4 * cronHOURS)
-    entry->delta = 4 * cronHOURS;
+  if (entry->delta > 4 * GNUNET_CRON_HOURS)
+    entry->delta = 4 * GNUNET_CRON_HOURS;
   entry->until = now + entry->delta;
   entry->strict = strict;
-  hash2enc (&identity->hashPubKey, &hn);
+  GNUNET_hash_to_enc (&identity->hashPubKey, &hn);
 #if DEBUG_IDENTITY
   GE_LOG (ectx,
           GE_INFO | GE_REQUEST | GE_DEVELOPER,
           "Blacklisting host `%s' for %llu seconds"
           " until %llu (strict=%d).\n",
-          &hn, entry->delta / cronSECONDS, entry->until, strict);
+          &hn, entry->delta / GNUNET_CRON_SECONDS, entry->until, strict);
 #endif
-  MUTEX_UNLOCK (lock_);
-  return OK;
+  GNUNET_mutex_unlock (lock_);
+  return GNUNET_OK;
 }
 
 /**
  * Is the host currently blacklisted (i.e. we refuse to talk)?
  *
  * @param identity host to check
- * @return YES if true, else NO
+ * @return GNUNET_YES if true, else GNUNET_NO
  */
 static int
-isBlacklisted (const PeerIdentity * identity, int strict)
+isBlacklisted (const GNUNET_PeerIdentity * identity, int strict)
 {
-  cron_t now;
+  GNUNET_CronTime now;
   HostEntry *entry;
 
   GE_ASSERT (ectx, numberOfHosts_ <= sizeOfHosts_);
-  MUTEX_LOCK (lock_);
+  GNUNET_mutex_lock (lock_);
   entry = findHost (identity);
   if (entry == NULL)
     {
-      MUTEX_UNLOCK (lock_);
-      return NO;
+      GNUNET_mutex_unlock (lock_);
+      return GNUNET_NO;
     }
-  now = get_time ();
-  if ((now < entry->until) && ((entry->strict == YES) || (strict == NO)))
+  now = GNUNET_get_time ();
+  if ((now < entry->until)
+      && ((entry->strict == GNUNET_YES) || (strict == GNUNET_NO)))
     {
 #if DEBUG_IDENTITY
-      EncName enc;
+      GNUNET_EncName enc;
 
       IF_GELOG (ectx,
                 GE_INFO | GE_USER | GE_BULK,
-                hash2enc (&identity->hashPubKey, &enc));
+                GNUNET_hash_to_enc (&identity->hashPubKey, &enc));
       GE_LOG (ectx,
               GE_INFO | GE_USER | GE_BULK,
               _
               ("Peer `%s' is currently strictly blacklisted (for another 
%llums).\n"),
               &enc, entry->until - now);
 #endif
-      MUTEX_UNLOCK (lock_);
-      return YES;
+      GNUNET_mutex_unlock (lock_);
+      return GNUNET_YES;
     }
   else
     {
-      MUTEX_UNLOCK (lock_);
-      return NO;
+      GNUNET_mutex_unlock (lock_);
+      return GNUNET_NO;
     }
 }
 
@@ -908,23 +936,24 @@
  * Whitelist a host. This method is called if a host
  * successfully established a connection. It typically
  * resets the exponential backoff to the smallest value.
- * @return OK on success SYSERR on error
+ * @return GNUNET_OK on success GNUNET_SYSERR on error
  */
 static int
-whitelistHost (const PeerIdentity * identity)
+whitelistHost (const GNUNET_PeerIdentity * identity)
 {
   HostEntry *entry;
   int i;
 
   GE_ASSERT (ectx, numberOfHosts_ <= sizeOfHosts_);
-  MUTEX_LOCK (lock_);
+  GNUNET_mutex_lock (lock_);
   entry = findHost (identity);
   if (entry == NULL)
     {
       for (i = 0; i < MAX_TEMP_HOSTS; i++)
         {
           if (0 == memcmp (identity,
-                           &tempHosts[i].identity, sizeof (PeerIdentity)))
+                           &tempHosts[i].identity,
+                           sizeof (GNUNET_PeerIdentity)))
             {
               entry = &tempHosts[i];
               break;
@@ -933,14 +962,14 @@
     }
   if (entry == NULL)
     {
-      MUTEX_UNLOCK (lock_);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock_);
+      return GNUNET_SYSERR;
     }
-  entry->delta = 30 * cronSECONDS;
+  entry->delta = 30 * GNUNET_CRON_SECONDS;
   entry->until = 0;
-  entry->strict = NO;
-  MUTEX_UNLOCK (lock_);
-  return OK;
+  entry->strict = GNUNET_NO;
+  GNUNET_mutex_unlock (lock_);
+  return GNUNET_OK;
 }
 
 /**
@@ -954,24 +983,26 @@
  * @return the number of hosts matching
  */
 static int
-forEachHost (cron_t now, HostIterator callback, void *data)
+forEachHost (GNUNET_CronTime now, HostIterator callback, void *data)
 {
   int i;
   int j;
   int count;
-  PeerIdentity hi;
+  GNUNET_PeerIdentity hi;
   unsigned short proto;
   HostEntry *entry;
   int ret;
 
-  ret = OK;
+  ret = GNUNET_OK;
   GE_ASSERT (ectx, numberOfHosts_ <= sizeOfHosts_);
   count = 0;
-  MUTEX_LOCK (lock_);
+  GNUNET_mutex_lock (lock_);
   for (i = 0; i < numberOfHosts_; i++)
     {
       entry = hosts_[i];
-      if (0 == memcmp (&entry->identity, &myIdentity, sizeof (PeerIdentity)))
+      if (0 ==
+          memcmp (&entry->identity, &myIdentity,
+                  sizeof (GNUNET_PeerIdentity)))
         continue;
       if ((now == 0) || (now >= entry->until))
         {
@@ -982,10 +1013,10 @@
               for (j = 0; j < entry->protocolCount; j++)
                 {
                   proto = entry->protocols[j];
-                  MUTEX_UNLOCK (lock_);
-                  ret = callback (&hi, proto, YES, data);
-                  MUTEX_LOCK (lock_);
-                  if (ret != OK)
+                  GNUNET_mutex_unlock (lock_);
+                  ret = callback (&hi, proto, GNUNET_YES, data);
+                  GNUNET_mutex_lock (lock_);
+                  if (ret != GNUNET_OK)
                     break;
                   /* we gave up the lock,
                      need to re-acquire entry (if possible)! */
@@ -993,7 +1024,7 @@
                     break;
                   entry = hosts_[i];
                   if (0 == memcmp (&entry->identity,
-                                   &myIdentity, sizeof (PeerIdentity)))
+                                   &myIdentity, sizeof (GNUNET_PeerIdentity)))
                     break;
                 }
             }
@@ -1002,11 +1033,11 @@
         {
 #if 0
 #if DEBUG_IDENTITY
-          EncName enc;
+          GNUNET_EncName enc;
 
           IF_GELOG (ectx,
                     GE_INFO | GE_USER | GE_BULK,
-                    hash2enc (&entry->identity.hashPubKey, &enc));
+                    GNUNET_hash_to_enc (&entry->identity.hashPubKey, &enc));
           GE_LOG (ectx,
                   GE_INFO | GE_USER | GE_BULK,
                   entry->strict ?
@@ -1019,13 +1050,13 @@
 #endif
 #endif
         }
-      if (ret != OK)
+      if (ret != GNUNET_OK)
         break;
 
     }
   for (i = 0; i < MAX_TEMP_HOSTS; i++)
     {
-      if (ret != OK)
+      if (ret != GNUNET_OK)
         break;
       entry = &tempHosts[i];
       if (entry->helloCount == 0)
@@ -1037,13 +1068,13 @@
             {
               hi = entry->identity;
               proto = entry->protocols[0];
-              MUTEX_UNLOCK (lock_);
-              ret = callback (&hi, proto, YES, data);
-              MUTEX_LOCK (lock_);
+              GNUNET_mutex_unlock (lock_);
+              ret = callback (&hi, proto, GNUNET_YES, data);
+              GNUNET_mutex_lock (lock_);
             }
         }
     }
-  MUTEX_UNLOCK (lock_);
+  GNUNET_mutex_unlock (lock_);
   return count;
 }
 
@@ -1054,15 +1085,15 @@
 static void
 flushHostCredit (HostEntry * host)
 {
-  EncName fil;
+  GNUNET_EncName fil;
   char *fn;
   unsigned int trust;
 
   if ((host->trust & TRUST_REFRESH_MASK) == 0)
     return;                     /* unchanged */
   host->trust = host->trust & TRUST_ACTUAL_MASK;
-  hash2enc (&host->identity.hashPubKey, &fil);
-  fn = MALLOC (strlen (trustDirectory) + sizeof (EncName) + 1);
+  GNUNET_hash_to_enc (&host->identity.hashPubKey, &fil);
+  fn = GNUNET_malloc (strlen (trustDirectory) + sizeof (GNUNET_EncName) + 1);
   strcpy (fn, trustDirectory);
   strcat (fn, (char *) &fil);
   if (host->trust == 0)
@@ -1074,9 +1105,9 @@
   else
     {
       trust = htonl (host->trust);
-      disk_file_write (ectx, fn, &trust, sizeof (unsigned int), "644");
+      GNUNET_disk_file_write (ectx, fn, &trust, sizeof (unsigned int), "644");
     }
-  FREE (fn);
+  GNUNET_free (fn);
 }
 
 /**
@@ -1086,10 +1117,10 @@
 cronFlushTrustBuffer (void *unused)
 {
   int i;
-  MUTEX_LOCK (lock_);
+  GNUNET_mutex_lock (lock_);
   for (i = 0; i < numberOfHosts_; i++)
     flushHostCredit (hosts_[i]);
-  MUTEX_UNLOCK (lock_);
+  GNUNET_mutex_unlock (lock_);
 }
 
 /**
@@ -1102,23 +1133,24 @@
   struct stat hostStat;
   int hostFile;
 
-  fn = MALLOC (strlen (filename) + strlen (dirname) + 2);
+  fn = GNUNET_malloc (strlen (filename) + strlen (dirname) + 2);
   sprintf (fn, "%s%s%s", dirname, DIR_SEPARATOR_STR, filename);
-  hostFile = disk_file_open (ectx, fn, O_WRONLY);
+  hostFile = GNUNET_disk_file_open (ectx, fn, O_WRONLY);
   if (hostFile != -1)
     {
       if (FSTAT (hostFile, &hostStat) == 0)
         {
           CLOSE (hostFile);
 
-          if (hostStat.st_mtime + (CRON_DISCARDS_HOSTS_AFTER / cronSECONDS) <
+          if (hostStat.st_mtime +
+              (CRON_DISCARDS_HOSTS_AFTER / GNUNET_CRON_SECONDS) <
               *((time_t *) now))
             UNLINK (fn);
         }
     }
-  FREE (fn);
+  GNUNET_free (fn);
 
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -1130,58 +1162,60 @@
   time_t timeNow;
 
   timeNow = time (NULL);
-  disk_directory_scan (ectx,
-                       networkIdDirectory,
-                       &discardHostsHelper, (void *) &timeNow);
+  GNUNET_disk_directory_scan (ectx,
+                              networkIdDirectory,
+                              &discardHostsHelper, (void *) &timeNow);
 }
 
 
 static int
 identityRequestConnectHandler (struct ClientHandle *sock,
-                               const MESSAGE_HEADER * message)
+                               const GNUNET_MessageHeader * message)
 {
   const CS_identity_connect_MESSAGE *msg;
   int ret;
 
   if (sizeof (CS_identity_connect_MESSAGE) != ntohs (message->size))
-    return SYSERR;
+    return GNUNET_SYSERR;
   msg = (const CS_identity_connect_MESSAGE *) message;
   coreAPI->unicast (&msg->other, NULL, 0, 0);
   ret = coreAPI->queryPeerStatus (&msg->other, NULL, NULL);
-  return coreAPI->sendValueToClient (sock, ret != OK ? NO : YES);
+  return coreAPI->sendValueToClient (sock,
+                                     ret !=
+                                     GNUNET_OK ? GNUNET_NO : GNUNET_YES);
 }
 
 static int
 identityHelloHandler (struct ClientHandle *sock,
-                      const MESSAGE_HEADER * message)
+                      const GNUNET_MessageHeader * message)
 {
-  const P2P_hello_MESSAGE *msg;
-  P2P_hello_MESSAGE *hello;
+  const GNUNET_MessageHello *msg;
+  GNUNET_MessageHello *hello;
 
-  if (sizeof (P2P_hello_MESSAGE) > ntohs (message->size))
+  if (sizeof (GNUNET_MessageHello) > ntohs (message->size))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  msg = (const P2P_hello_MESSAGE *) message;
-  if (P2P_hello_MESSAGE_size (msg) != ntohs (message->size))
+  msg = (const GNUNET_MessageHello *) message;
+  if (GNUNET_sizeof_hello (msg) != ntohs (message->size))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  hello = MALLOC (ntohs (msg->header.size));
+  hello = GNUNET_malloc (ntohs (msg->header.size));
   memcpy (hello, msg, ntohs (msg->header.size));
   hello->header.type = htons (p2p_PROTO_hello);
   coreAPI->injectMessage (NULL,
                           (const char *) hello,
-                          ntohs (msg->header.size), NO, NULL);
-  FREE (hello);
-  return OK;
+                          ntohs (msg->header.size), GNUNET_NO, NULL);
+  GNUNET_free (hello);
+  return GNUNET_OK;
 }
 
 static int
 identityRequestHelloHandler (struct ClientHandle *sock,
-                             const MESSAGE_HEADER * message)
+                             const GNUNET_MessageHeader * message)
 {
   /* transport types in order of preference
      for location URIs (by best guess at what
@@ -1197,7 +1231,7 @@
     0,
   };
   Transport_ServiceAPI *tapi;
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
   int pos;
   int ret;
 
@@ -1206,99 +1240,99 @@
      however, we can request it briefly here */
   tapi = coreAPI->requestService ("transport");
   if (tapi == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   hello = NULL;
   pos = 0;
   while ((hello == NULL) && (types[pos] != 0))
     hello = tapi->createhello (types[pos++]);
   coreAPI->releaseService (tapi);
   if (hello == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   hello->header.type = htons (CS_PROTO_identity_HELLO);
-  ret = coreAPI->sendToClient (sock, &hello->header, YES);
-  FREE (hello);
+  ret = coreAPI->sendToClient (sock, &hello->header, GNUNET_YES);
+  GNUNET_free (hello);
   return ret;
 }
 
 static int
 identityRequestSignatureHandler (struct ClientHandle *sock,
-                                 const MESSAGE_HEADER * message)
+                                 const GNUNET_MessageHeader * message)
 {
   CS_identity_signature_MESSAGE reply;
 
-  if (ntohs (message->size) <= sizeof (MESSAGE_HEADER))
-    return SYSERR;
+  if (ntohs (message->size) <= sizeof (GNUNET_MessageHeader))
+    return GNUNET_SYSERR;
   reply.header.size = htons (sizeof (CS_identity_signature_MESSAGE));
   reply.header.type = htons (CS_PROTO_identity_SIGNATURE);
-  if (OK != signData (&message[1],
-                      ntohs (message->size) - sizeof (MESSAGE_HEADER),
-                      &reply.sig))
-    return SYSERR;
-  return coreAPI->sendToClient (sock, &reply.header, YES);
+  if (GNUNET_OK != signData (&message[1],
+                             ntohs (message->size) -
+                             sizeof (GNUNET_MessageHeader), &reply.sig))
+    return GNUNET_SYSERR;
+  return coreAPI->sendToClient (sock, &reply.header, GNUNET_YES);
 }
 
 static int
-hostInfoIterator (const PeerIdentity * identity,
+hostInfoIterator (const GNUNET_PeerIdentity * identity,
                   unsigned short protocol, int confirmed, void *data)
 {
   struct ClientHandle *sock = data;
   Transport_ServiceAPI *transport;
   CS_identity_peer_info_MESSAGE *reply;
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
   void *address;
   int ret;
   unsigned int len;
   unsigned int bpm;
-  cron_t last;
+  GNUNET_CronTime last;
 
-  if (confirmed == NO)
-    return OK;
-  hello = identity2Hello (identity, protocol, YES);
+  if (confirmed == GNUNET_NO)
+    return GNUNET_OK;
+  hello = identity2Hello (identity, protocol, GNUNET_YES);
   if (hello == NULL)
-    return OK;                  /* ignore -- happens if HELLO just expired */
+    return GNUNET_OK;           /* ignore -- happens if HELLO just expired */
   transport = coreAPI->requestService ("transport");
   if (transport == NULL)
     {
-      FREE (hello);
-      return OK;
+      GNUNET_free (hello);
+      return GNUNET_OK;
     }
 
   len = 0;
   address = NULL;
   transport->helloToAddress (hello, &address, &len);
-  FREE (hello);
+  GNUNET_free (hello);
   coreAPI->releaseService (transport);
-  if (len >= MAX_BUFFER_SIZE - sizeof (CS_identity_peer_info_MESSAGE))
+  if (len >= GNUNET_MAX_BUFFER_SIZE - sizeof (CS_identity_peer_info_MESSAGE))
     {
-      FREE (address);
+      GNUNET_free (address);
       address = NULL;
       len = 0;
     }
-  if (OK != coreAPI->queryPeerStatus (identity, &bpm, &last))
+  if (GNUNET_OK != coreAPI->queryPeerStatus (identity, &bpm, &last))
     {
       last = 0;
       bpm = 0;
     }
-  reply = MALLOC (sizeof (CS_identity_peer_info_MESSAGE) + len);
+  reply = GNUNET_malloc (sizeof (CS_identity_peer_info_MESSAGE) + len);
   reply->header.size = htons (sizeof (CS_identity_peer_info_MESSAGE) + len);
   reply->header.type = htons (CS_PROTO_identity_INFO);
   reply->peer = *identity;
-  reply->last_message = htonll (last);
+  reply->last_message = GNUNET_htonll (last);
   reply->trust = htonl (getHostTrust (identity));
   reply->bpm = htonl (bpm);
   memcpy (&reply[1], address, len);
-  FREENONNULL (address);
-  ret = coreAPI->sendToClient (sock, &reply->header, YES);
-  FREE (reply);
+  GNUNET_free_non_null (address);
+  ret = coreAPI->sendToClient (sock, &reply->header, GNUNET_YES);
+  GNUNET_free (reply);
   return ret;
 }
 
 static int
 identityRequestInfoHandler (struct ClientHandle *sock,
-                            const MESSAGE_HEADER * message)
+                            const GNUNET_MessageHeader * message)
 {
   forEachHost (0, &hostInfoIterator, sock);
-  return coreAPI->sendValueToClient (sock, OK);
+  return coreAPI->sendValueToClient (sock, GNUNET_OK);
 }
 
 
@@ -1347,8 +1381,8 @@
                                                         &gnHome));
   if (gnHome == NULL)
     return NULL;
-  disk_directory_create (ectx, gnHome);
-  tmp = MALLOC (strlen (gnHome) + strlen (HOST_DIR) + 2);
+  GNUNET_disk_directory_create (ectx, gnHome);
+  tmp = GNUNET_malloc (strlen (gnHome) + strlen (HOST_DIR) + 2);
   strcpy (tmp, gnHome);
   strcat (tmp, DIR_SEPARATOR_STR);
   strcat (tmp, HOST_DIR);
@@ -1359,27 +1393,28 @@
                                                         "HOSTS",
                                                         tmp,
                                                         &networkIdDirectory));
-  FREE (tmp);
-  disk_directory_create (ectx, networkIdDirectory);
-  trustDirectory = MALLOC (strlen (gnHome) + strlen (TRUSTDIR) + 2);
+  GNUNET_free (tmp);
+  GNUNET_disk_directory_create (ectx, networkIdDirectory);
+  trustDirectory = GNUNET_malloc (strlen (gnHome) + strlen (TRUSTDIR) + 2);
   strcpy (trustDirectory, gnHome);
   strcat (trustDirectory, DIR_SEPARATOR_STR);
   strcat (trustDirectory, TRUSTDIR);
-  disk_directory_create (ectx, trustDirectory);
-  FREE (gnHome);
+  GNUNET_disk_directory_create (ectx, trustDirectory);
+  GNUNET_free (gnHome);
 
-  lock_ = MUTEX_CREATE (YES);
+  lock_ = GNUNET_mutex_create (GNUNET_YES);
   initPrivateKey (capi->ectx, capi->cfg);
   getPeerIdentity (getPublicPrivateKey (), &myIdentity);
   cronScanDirectoryDataHosts (NULL);
-  cron_add_job (coreAPI->cron,
-                &cronScanDirectoryDataHosts,
-                CRON_DATA_HOST_FREQ, CRON_DATA_HOST_FREQ, NULL);
-  cron_add_job (coreAPI->cron,
-                &cronFlushTrustBuffer,
-                CRON_TRUST_FLUSH_FREQ, CRON_TRUST_FLUSH_FREQ, NULL);
-  cron_add_job (coreAPI->cron,
-                &cronDiscardHosts, 0, CRON_DISCARD_HOSTS_INTERVAL, NULL);
+  GNUNET_cron_add_job (coreAPI->cron,
+                       &cronScanDirectoryDataHosts,
+                       CRON_DATA_HOST_FREQ, CRON_DATA_HOST_FREQ, NULL);
+  GNUNET_cron_add_job (coreAPI->cron,
+                       &cronFlushTrustBuffer,
+                       CRON_TRUST_FLUSH_FREQ, CRON_TRUST_FLUSH_FREQ, NULL);
+  GNUNET_cron_add_job (coreAPI->cron,
+                       &cronDiscardHosts, 0, CRON_DISCARD_HOSTS_INTERVAL,
+                       NULL);
   coreAPI->registerClientHandler (CS_PROTO_identity_CONNECT,
                                   &identityRequestConnectHandler);
   coreAPI->registerClientHandler (CS_PROTO_identity_HELLO,
@@ -1417,34 +1452,35 @@
     {
       entry = &tempHosts[i];
       for (j = 0; j < entry->helloCount; j++)
-        FREE (entry->hellos[j]);
-      GROW (entry->hellos, entry->helloCount, 0);
-      GROW (entry->protocols, entry->protocolCount, 0);
+        GNUNET_free (entry->hellos[j]);
+      GNUNET_array_grow (entry->hellos, entry->helloCount, 0);
+      GNUNET_array_grow (entry->protocols, entry->protocolCount, 0);
     }
-  cron_del_job (coreAPI->cron,
-                &cronScanDirectoryDataHosts, CRON_DATA_HOST_FREQ, NULL);
-  cron_del_job (coreAPI->cron,
-                &cronFlushTrustBuffer, CRON_TRUST_FLUSH_FREQ, NULL);
-  cron_del_job (coreAPI->cron,
-                &cronDiscardHosts, CRON_DISCARD_HOSTS_INTERVAL, NULL);
+  GNUNET_cron_del_job (coreAPI->cron,
+                       &cronScanDirectoryDataHosts, CRON_DATA_HOST_FREQ,
+                       NULL);
+  GNUNET_cron_del_job (coreAPI->cron, &cronFlushTrustBuffer,
+                       CRON_TRUST_FLUSH_FREQ, NULL);
+  GNUNET_cron_del_job (coreAPI->cron, &cronDiscardHosts,
+                       CRON_DISCARD_HOSTS_INTERVAL, NULL);
   cronFlushTrustBuffer (NULL);
-  MUTEX_DESTROY (lock_);
+  GNUNET_mutex_destroy (lock_);
   lock_ = NULL;
   for (i = 0; i < numberOfHosts_; i++)
     {
       entry = hosts_[i];
       for (j = 0; j < entry->helloCount; j++)
-        FREE (entry->hellos[j]);
-      GROW (entry->hellos, entry->helloCount, 0);
-      GROW (entry->protocols, entry->protocolCount, 0);
-      FREE (entry);
+        GNUNET_free (entry->hellos[j]);
+      GNUNET_array_grow (entry->hellos, entry->helloCount, 0);
+      GNUNET_array_grow (entry->protocols, entry->protocolCount, 0);
+      GNUNET_free (entry);
     }
-  GROW (hosts_, sizeOfHosts_, 0);
+  GNUNET_array_grow (hosts_, sizeOfHosts_, 0);
   numberOfHosts_ = 0;
 
-  FREE (networkIdDirectory);
+  GNUNET_free (networkIdDirectory);
   networkIdDirectory = NULL;
-  FREE (trustDirectory);
+  GNUNET_free (trustDirectory);
   trustDirectory = NULL;
   donePrivateKey ();
 }

Modified: GNUnet/src/applications/identity/identity.h
===================================================================
--- GNUnet/src/applications/identity/identity.h 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/identity/identity.h 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -31,9 +31,9 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
-  Signature sig;
+  GNUNET_RSA_Signature sig;
 } CS_identity_signature_MESSAGE;
 
 /**
@@ -41,9 +41,9 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
-  PeerIdentity other;
+  GNUNET_PeerIdentity other;
 } CS_identity_connect_MESSAGE;
 
 /**
@@ -55,13 +55,13 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   unsigned int trust;
 
-  PeerIdentity peer;
+  GNUNET_PeerIdentity peer;
 
-  cron_t last_message;
+  GNUNET_CronTime last_message;
 
   unsigned int bpm;
 } CS_identity_peer_info_MESSAGE;

Modified: GNUnet/src/applications/identity/identitytest.c
===================================================================
--- GNUnet/src/applications/identity/identitytest.c     2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/identity/identitytest.c     2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -35,7 +35,7 @@
 #include "gnunet_util_network_client.h"
 #include "core.h"
 
-static struct CronManager *cron;
+static struct GNUNET_CronManager *cron;
 
 static struct GC_Configuration *cfg;
 
@@ -44,10 +44,10 @@
   if (!cond) { \
    printf("Assertion failed at %s:%d\n", \
           __FILE__, __LINE__); \
-   cron_stop(cron); \
+   GNUNET_cron_stop(cron); \
    releaseService(identity); \
    releaseService(transport); \
-   return SYSERR; \
+   return GNUNET_SYSERR; \
   } \
 } while (0)
 
@@ -56,28 +56,28 @@
 {
   Identity_ServiceAPI *identity;
   Transport_ServiceAPI *transport;
-  PeerIdentity pid;
-  const PublicKey *pkey;
-  Signature sig;
-  P2P_hello_MESSAGE *hello;
+  GNUNET_PeerIdentity pid;
+  const GNUNET_RSA_PublicKey *pkey;
+  GNUNET_RSA_Signature sig;
+  GNUNET_MessageHello *hello;
 
   transport = requestService ("transport");
   identity = requestService ("identity");
-  cron_start (cron);
+  GNUNET_cron_start (cron);
   /* give cron job chance to run */
-  PTHREAD_SLEEP (5 * cronSECONDS);
+  GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);
   hello = transport->createhello (ANY_PROTOCOL_NUMBER);
   if (NULL == hello)
     {
       printf ("Cannot run test, failed to create any hello.\n");
-      cron_stop (cron);
+      GNUNET_cron_stop (cron);
       releaseService (identity);
       releaseService (transport);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   identity->addHost (hello);
   pid = hello->senderIdentity;
-  FREE (hello);
+  GNUNET_free (hello);
 
   identity->changeHostTrust (&pid, -identity->getHostTrust (&pid));
   ASSERT (4 == identity->changeHostTrust (&pid, 4));
@@ -94,39 +94,40 @@
   ASSERT (0 == identity->getHostTrust (&pid));
 
   pkey = identity->getPublicPrivateKey ();
-  ASSERT (OK == identity->signData ("TestData", 8, &sig));
-  ASSERT (OK == verifySig ("TestData", 8, &sig, pkey));
+  ASSERT (GNUNET_OK == identity->signData ("TestData", 8, &sig));
+  ASSERT (GNUNET_OK == GNUNET_RSA_verify ("TestData", 8, &sig, pkey));
 
   /* to test:
      hello verification, temporary storage,
      permanent storage, blacklisting, etc. */
-  cron_stop (cron);
+  GNUNET_cron_stop (cron);
   releaseService (identity);
   releaseService (transport);
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
 hcb (void *data,
-     const PeerIdentity * identity,
+     const GNUNET_PeerIdentity * identity,
      const void *address,
      unsigned int addr_len,
-     cron_t last_message, unsigned int trust, unsigned int bpmFromPeer)
+     GNUNET_CronTime last_message, unsigned int trust,
+     unsigned int bpmFromPeer)
 {
   /* TODO: do something meaningful */
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
 runClientTest ()
 {
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   int ret;
 
-  ret = OK;
-  sock = client_connection_create (NULL, cfg);
-  gnunet_identity_request_peer_infos (sock, &hcb, &ret);
-  connection_destroy (sock);
+  ret = GNUNET_OK;
+  sock = GNUNET_client_connection_create (NULL, cfg);
+  GNUNET_IDENTITY_request_peer_infos (sock, &hcb, &ret);
+  GNUNET_client_connection_destroy (sock);
   return ret;
 }
 
@@ -135,7 +136,7 @@
 {
   int err;
 
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
@@ -144,12 +145,12 @@
   cron = cron_create (NULL);
   initCore (NULL, cfg, cron, NULL);
   err = 0;
-  if (OK != runTest ())
+  if (GNUNET_OK != runTest ())
     err = 1;
-  if (OK != runClientTest ())
+  if (GNUNET_OK != runClientTest ())
     err = 1;
   doneCore ();
-  cron_destroy (cron);
+  GNUNET_cron_destroy (cron);
   GC_free (cfg);
   return err;
 }

Modified: GNUnet/src/applications/kvstore_sqlite/Makefile.am
===================================================================
--- GNUnet/src/applications/kvstore_sqlite/Makefile.am  2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/kvstore_sqlite/Makefile.am  2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -30,5 +30,4 @@
  kv_sqlitetest.c 
 kv_sqlitetest_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/kvstore_sqlite/kv_sqlite.c
===================================================================
--- GNUnet/src/applications/kvstore_sqlite/kv_sqlite.c  2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/kvstore_sqlite/kv_sqlite.c  2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -34,7 +34,7 @@
 #include "gnunet_kvstore_service.h"
 #include <sqlite3.h>
 
-#define DEBUG_SQLITE NO
+#define DEBUG_SQLITE GNUNET_NO
 
 /**
  * Die with an error message that indicates
@@ -64,7 +64,7 @@
   /**
    * Thread ID owning this handle
    */
-  struct PTHREAD *tid;
+  struct GNUNET_ThreadHandle *tid;
 
 } sqliteHandle;
 
@@ -111,7 +111,7 @@
 
 static sqliteDatabase **dbs;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 /**
  * @brief Encode a binary buffer "in" of size n bytes so that it contains
@@ -205,11 +205,11 @@
                                        "DIR",
                                        VAR_DAEMON_DIRECTORY "/kvstore/",
                                        &dir);
-  disk_directory_create (ectx, dir);
+  GNUNET_disk_directory_create (ectx, dir);
   mem = strlen (dir) + strlen (name) + 6;
-  fn = MALLOC (mem);
-  SNPRINTF (fn, mem, "%s/%s.dat", dir, name);
-  FREE (dir);
+  fn = GNUNET_malloc (mem);
+  GNUNET_snprintf (fn, mem, "%s/%s.dat", dir, name);
+  GNUNET_free (dir);
   return fn;
 }
 
@@ -226,11 +226,11 @@
   for (idx = 0; idx < databases; idx++)
     if (0 == strcmp (dbs[idx]->name, name))
       return dbs[idx];
-  db = MALLOC (sizeof (sqliteDatabase));
+  db = GNUNET_malloc (sizeof (sqliteDatabase));
   memset (db, 0, sizeof (sqliteDatabase));
   db->fn = getDBFileName (name);
-  db->name = STRDUP (name);
-  APPEND (dbs, databases, db);
+  db->name = GNUNET_strdup (name);
+  GNUNET_array_append (dbs, databases, db);
   return db;
 }
 
@@ -248,34 +248,34 @@
   sqliteHandle *dbh;
   sqliteDatabase *db;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   db = getDB (name);
   for (idx = 0; idx < db->handle_count; idx++)
-    if (PTHREAD_TEST_SELF (db->handles[idx]->tid))
+    if (GNUNET_thread_test_self (db->handles[idx]->tid))
       {
         sqliteHandle *ret = db->handles[idx];
-        MUTEX_UNLOCK (lock);
+        GNUNET_mutex_unlock (lock);
         return ret;
       }
   /* we haven't opened the DB for this thread yet */
-  dbh = MALLOC (sizeof (sqliteHandle));
-  dbh->tid = PTHREAD_GET_SELF ();
+  dbh = GNUNET_malloc (sizeof (sqliteHandle));
+  dbh->tid = GNUNET_thread_get_self ();
   if (sqlite3_open (db->fn, &dbh->dbh) != SQLITE_OK)
     {
       printf ("FN: %s\n", db->fn);
       LOG_SQLITE (dbh->dbh, GE_ERROR | GE_BULK | GE_USER, "sqlite3_open");
       sqlite3_close (dbh->dbh);
-      MUTEX_UNLOCK (lock);
-      PTHREAD_REL_SELF (dbh->tid);
-      FREE (dbh);
+      GNUNET_mutex_unlock (lock);
+      GNUNET_thread_release_self (dbh->tid);
+      GNUNET_free (dbh);
       return NULL;
     }
-  APPEND (db->handles, db->handle_count, dbh);
+  GNUNET_array_append (db->handles, db->handle_count, dbh);
   sqlite3_exec (dbh->dbh, "PRAGMA temp_store=MEMORY", NULL, NULL, NULL);
   sqlite3_exec (dbh->dbh, "PRAGMA synchronous=OFF", NULL, NULL, NULL);
   sqlite3_exec (dbh->dbh, "PRAGMA count_changes=OFF", NULL, NULL, NULL);
   sqlite3_exec (dbh->dbh, "PRAGMA page_size=4096", NULL, NULL, NULL);
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return dbh;
 }
 
@@ -287,15 +287,15 @@
   for (idx = 0; idx < db->handle_count; idx++)
     {
       sqliteHandle *dbh = db->handles[idx];
-      PTHREAD_REL_SELF (dbh->tid);
+      GNUNET_thread_release_self (dbh->tid);
       if (sqlite3_close (dbh->dbh) != SQLITE_OK)
         LOG_SQLITE (dbh->dbh, LOG_ERROR, "sqlite_close");
-      FREE (dbh);
+      GNUNET_free (dbh);
     }
-  GROW (db->handles, db->handle_count, 0);
-  FREE (db->fn);
-  FREE (db->name);
-  FREE (db);
+  GNUNET_array_grow (db->handles, db->handle_count, 0);
+  GNUNET_free (db->fn);
+  GNUNET_free (db->name);
+  GNUNET_free (db);
 }
 
 /**
@@ -308,7 +308,7 @@
   unsigned int idx;
   char *fn;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (idx = 0; idx < databases; idx++)
     {
       if (0 == strcmp (dbs[idx]->name, name))
@@ -316,14 +316,14 @@
           db = dbs[idx];
           close_database (db);
           dbs[idx] = dbs[databases - 1];
-          GROW (dbs, databases, databases - 1);
+          GNUNET_array_grow (dbs, databases, databases - 1);
           break;
         }
     }
   fn = getDBFileName (name);
   UNLINK (fn);
-  FREE (fn);
-  MUTEX_UNLOCK (lock);
+  GNUNET_free (fn);
+  GNUNET_mutex_unlock (lock);
 }
 
 /**
@@ -348,7 +348,7 @@
   sqlite3_bind_text (stmt, 1, table, len, SQLITE_STATIC);
   if (sqlite3_step (stmt) == SQLITE_DONE)
     {
-      char *create = MALLOC (len + 58);
+      char *create = GNUNET_malloc (len + 58);
 
       sprintf (create,
                "CREATE TABLE %s (gn_key BLOB, gn_val BLOB, gn_age BIGINT)",
@@ -358,22 +358,22 @@
         {
           LOG_SQLITE (dbh->dbh, LOG_ERROR, "sqlite_create");
           sqlite3_finalize (stmt);
-          FREE (create);
+          GNUNET_free (create);
           return NULL;
         }
 
-      FREE (create);
+      GNUNET_free (create);
     }
   sqlite3_finalize (stmt);
 
   /* FIXME: more indexes */
-  idx = MALLOC (len + 34);
+  idx = GNUNET_malloc (len + 34);
   sprintf (idx, "CREATE INDEX idx_key ON %s (gn_key)", table);
   sqlite3_exec (dbh->dbh, idx, NULL, NULL, NULL);
-  FREE (idx);
-  ret = MALLOC (sizeof (KVHandle));
-  ret->table = STRDUP (table);
-  ret->db = STRDUP (database);
+  GNUNET_free (idx);
+  ret = GNUNET_malloc (sizeof (KVHandle));
+  ret->table = GNUNET_strdup (table);
+  ret->db = GNUNET_strdup (database);
 
   return ret;
 }
@@ -409,12 +409,12 @@
   ret_dec = NULL;
 
   len = strlen (kv->table);
-  sel = MALLOC (len + 45);
+  sel = GNUNET_malloc (len + 45);
 
   if (key)
     {
       where = "WHERE gn_key = ?";
-      key_enc = MALLOC (keylen * 2 + 1);
+      key_enc = GNUNET_malloc (keylen * 2 + 1);
       enclen = sqlite_encode_binary (key, keylen, key_enc);
     }
   else
@@ -456,25 +456,25 @@
 
       /* free previous result, only the last in the result set
          is returned to the caller */
-      FREENONNULL (ret_dec);
+      GNUNET_free_non_null (ret_dec);
 
-      ret_dec = MALLOC (retlen);
+      ret_dec = GNUNET_malloc (retlen);
       retlen = sqlite_decode_binary_n (ret, ret_dec, retlen);
 
       if (handler)
-        if (handler (closure, ret, retlen) != OK)
+        if (handler (closure, ret, retlen) != GNUNET_OK)
           {
-            FREE (sel);
-            FREENONNULL (key_enc);
-            FREE (ret_dec);
+            GNUNET_free (sel);
+            GNUNET_free_non_null (key_enc);
+            GNUNET_free (ret_dec);
             sqlite3_finalize (stmt);
 
             return ret;
           }
     }
   sqlite3_finalize (stmt);
-  FREE (sel);
-  FREENONNULL (key_enc);
+  GNUNET_free (sel);
+  GNUNET_free_non_null (key_enc);
   return ret_dec;
 }
 
@@ -486,7 +486,7 @@
  * @param val value of the pair
  * @param vallen length of the value (int because of SQLite!)
  * @param optional creation time
- * @return OK on success, SYSERR otherwise
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
  */
 static int
 put (KVHandle * kv, void *key, int keylen, void *val, int vallen,
@@ -501,18 +501,18 @@
 
   dbh = getDBHandle (kv->db);
   if (dbh == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   len = strlen (kv->table);
-  ins = MALLOC (len + 68);
+  ins = GNUNET_malloc (len + 68);
 
   sprintf (ins,
            "INSERT INTO %s(gn_key, gn_val, gn_age) values (?, ?, ?)",
            kv->table);
 
-  key_enc = MALLOC (keylen * 2);
+  key_enc = GNUNET_malloc (keylen * 2);
   keyenc_len = sqlite_encode_binary (key, keylen, key_enc);
 
-  val_enc = MALLOC (vallen * 2);
+  val_enc = GNUNET_malloc (vallen * 2);
   valenc_len = sqlite_encode_binary (val, vallen, val_enc);
 
   sq_prepare (dbh, ins, &stmt);
@@ -521,19 +521,19 @@
   sqlite3_bind_int64 (stmt, 3, age);
   if (sqlite3_step (stmt) != SQLITE_DONE)
     {
-      FREE (ins);
-      FREE (key_enc);
-      FREE (val_enc);
+      GNUNET_free (ins);
+      GNUNET_free (key_enc);
+      GNUNET_free (val_enc);
       LOG_SQLITE (dbh->dbh, LOG_ERROR, "put");
       sqlite3_finalize (stmt);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   sqlite3_finalize (stmt);
-  FREE (ins);
-  FREE (key_enc);
-  FREE (val_enc);
+  GNUNET_free (ins);
+  GNUNET_free (key_enc);
+  GNUNET_free (val_enc);
 
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -541,7 +541,7 @@
  * @param key key to delete (may be NULL)
  * @param keylen length of the key
  * @param age age of the items to delete (may be 0)
- * @return OK on success, SYSERR otherwise
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
  */
 static int
 del (KVHandle * kv, void *key, int keylen, unsigned long long age)
@@ -556,10 +556,10 @@
 
   dbh = getDBHandle (kv->db);
   if (dbh == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
 
   len = strlen (kv->table);
-  del = MALLOC (len + 52);
+  del = GNUNET_malloc (len + 52);
   bind = 1;
 
   if (key)
@@ -579,7 +579,7 @@
   sq_prepare (dbh, del, &stmt);
   if (key)
     {
-      keyenc = MALLOC (keylen * 2);
+      keyenc = GNUNET_malloc (keylen * 2);
       keyenc_len = sqlite_encode_binary (key, keylen, keyenc);
       sqlite3_bind_blob (stmt, 1, keyenc, keyenc_len, SQLITE_STATIC);
       bind++;
@@ -594,18 +594,18 @@
 
   if (sqlite3_step (stmt) != SQLITE_DONE)
     {
-      FREE (del);
-      FREENONNULL (keyenc);
+      GNUNET_free (del);
+      GNUNET_free_non_null (keyenc);
       LOG_SQLITE (dbh->dbh, LOG_ERROR, "delete");
       sqlite3_finalize (stmt);
 
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   sqlite3_finalize (stmt);
-  FREE (del);
-  FREENONNULL (keyenc);
+  GNUNET_free (del);
+  GNUNET_free_non_null (keyenc);
 
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -615,14 +615,14 @@
 static void
 closeTable (KVHandle * kv)
 {
-  FREE (kv->table);
-  FREE (kv->db);
+  GNUNET_free (kv->table);
+  GNUNET_free (kv->db);
 }
 
 /**
  * @brief Drop a Key/Value-Table
  * @param the handle to the table
- * @return OK on success, SYSERR otherwise
+ * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
  */
 static int
 dropTable (KVHandle * kv)
@@ -633,21 +633,21 @@
 
   dbh = getDBHandle (kv->db);
   if (dbh == NULL)
-    return SYSERR;
-  drop = MALLOC (12 + strlen (kv->table));
+    return GNUNET_SYSERR;
+  drop = GNUNET_malloc (12 + strlen (kv->table));
   sprintf (drop, "DROP TABLE %s", kv->table);
   sq_prepare (dbh, drop, &stmt);
   if (sqlite3_step (stmt) != SQLITE_DONE)
     {
-      FREE (drop);
+      GNUNET_free (drop);
       LOG_SQLITE (dbh->dbh, LOG_ERROR, "drop");
       sqlite3_finalize (stmt);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   sqlite3_finalize (stmt);
-  FREE (drop);
+  GNUNET_free (drop);
   closeTable (kv);
-  return OK;
+  return GNUNET_OK;
 }
 
 KVstore_ServiceAPI *
@@ -662,7 +662,7 @@
           "KV-SQLite: initializing database\n");
 #endif
 
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
   coreAPI = capi;
   api.closeTable = &closeTable;
   api.del = &del;
@@ -684,7 +684,7 @@
 
   for (idx = 0; idx < databases; idx++)
     close_database (dbs[idx]);
-  GROW (dbs, databases, 0);
+  GNUNET_array_grow (dbs, databases, 0);
 
 #if DEBUG_SQLITE
   GE_LOG (ectx,
@@ -692,7 +692,7 @@
           "SQLite KVStore: database shutdown\n");
 #endif
 
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   coreAPI = NULL;
 }
 

Modified: GNUnet/src/applications/kvstore_sqlite/kv_sqlitetest.c
===================================================================
--- GNUnet/src/applications/kvstore_sqlite/kv_sqlitetest.c      2007-11-23 
11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/kvstore_sqlite/kv_sqlitetest.c      2007-11-23 
11:51:54 UTC (rev 5742)
@@ -41,36 +41,36 @@
 test (KVstore_ServiceAPI * api)
 {
   KVHandle *kv;
-  HashCode512 k, v;
-  HashCode512 *r;
+  GNUNET_HashCode k, v;
+  GNUNET_HashCode *r;
 
-  cron_t timeStmp;
+  GNUNET_CronTime timeStmp;
 
   kv = api->getTable ("TEST", "KV");
   ASSERT (kv != NULL);
 
-  timeStmp = get_time ();
+  timeStmp = GNUNET_get_time ();
   ASSERT (api->put (kv, (void *) &k, sizeof (k), (void *) &v, sizeof (v),
-                    timeStmp) == OK);
+                    timeStmp) == GNUNET_OK);
 
   r = api->get (kv, (void *) &k, sizeof (k), 0, 0, NULL, NULL);
   ASSERT (r != NULL);
   ASSERT (memcmp (&v, r, sizeof (v)) == 0);
-  FREE (r);
+  GNUNET_free (r);
 
-  ASSERT (api->del (kv, (void *) &k, sizeof (k), 0) == OK);
+  ASSERT (api->del (kv, (void *) &k, sizeof (k), 0) == GNUNET_OK);
 
   ASSERT (api->get (kv, (void *) &k, sizeof (k), 0, 0, NULL, NULL) == NULL);
 
-  ASSERT (api->dropTable (kv) == OK);
+  ASSERT (api->dropTable (kv) == GNUNET_OK);
 
   api->dropDatabase ("TEST");
 
-  return OK;
+  return GNUNET_OK;
 
 FAILURE:
   api->dropDatabase ("TEST");
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 #define TEST_DB "/tmp/GNUnet_sqstore_test/"
@@ -81,9 +81,9 @@
   KVstore_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);
@@ -98,9 +98,9 @@
       releaseService (api);
     }
   else
-    ok = SYSERR;
+    ok = GNUNET_SYSERR;
   doneCore ();
-  if (ok == SYSERR)
+  if (ok == GNUNET_SYSERR)
     return 1;
   return 0;
 }

Modified: GNUnet/src/applications/pingpong/pingpong.c
===================================================================
--- GNUnet/src/applications/pingpong/pingpong.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/pingpong/pingpong.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -51,14 +51,14 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * Which peer is the target of the ping? This is important since for
    * plaintext-pings, we need to catch faulty advertisements that
    * advertise a correct address but with the wrong public key.
    */
-  PeerIdentity receiver;
+  GNUNET_PeerIdentity receiver;
 
   /**
    * The challenge is a (pseudo) random number that an adversary that
@@ -70,23 +70,23 @@
 
 } P2P_pingpong_MESSAGE;
 
-#define DEBUG_PINGPONG NO
+#define DEBUG_PINGPONG GNUNET_NO
 
 #define MAX_PING_PONG 256
 
 typedef struct
 {
-  PeerIdentity receiverIdentity;
+  GNUNET_PeerIdentity receiverIdentity;
   int challenge;
   int plaintext;
-  CronJob method;
+  GNUNET_CronJob method;
   void *data;
-  TIME_T sendTime;
+  GNUNET_Int32Time sendTime;
 } PingPongEntry;
 
 static PingPongEntry *pingPongs;
 
-static struct MUTEX *pingPongLock;
+static struct GNUNET_Mutex *pingPongLock;
 
 static CoreAPIForApplication *coreAPI;
 
@@ -120,7 +120,8 @@
  * We received a PING message, send the PONG reply.
  */
 static int
-pingReceived (const PeerIdentity * sender, const MESSAGE_HEADER * msg)
+pingReceived (const GNUNET_PeerIdentity * sender,
+              const GNUNET_MessageHeader * msg)
 {
   const P2P_pingpong_MESSAGE *pmsg;
   P2P_pingpong_MESSAGE pong;
@@ -130,24 +131,24 @@
       GE_LOG (ectx,
               GE_WARNING | GE_BULK | GE_USER | GE_DEVELOPER,
               _("Received malformed `%s' message. Dropping.\n"), "ping");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (stats != NULL)
     stats->change (stat_pingReceived, 1);
   pmsg = (const P2P_pingpong_MESSAGE *) msg;
   if (0 != memcmp (coreAPI->myIdentity,
-                   &pmsg->receiver, sizeof (PeerIdentity)))
+                   &pmsg->receiver, sizeof (GNUNET_PeerIdentity)))
     {
       GE_LOG (ectx,
               GE_WARNING | GE_BULK | GE_ADMIN,
               _("Received ping for another peer. Dropping.\n"));
-      return SYSERR;            /* not for us */
+      return GNUNET_SYSERR;     /* not for us */
     }
 
 #if DEBUG_PINGPONG
-  EncName enc;
+  GNUNET_EncName enc;
 
-  hash2enc (&sender->hashPubKey, &enc);
+  GNUNET_hash_to_enc (&sender->hashPubKey, &enc);
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Received ping from peer %s.\n", &enc);
@@ -159,18 +160,19 @@
   coreAPI->unicast (sender, &pong.header, EXTREME_PRIORITY, 0); /* send now! */
   if (stats != NULL)
     stats->change (stat_pongSent, 1);
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
-sendPlaintext (const PeerIdentity * peer, const P2P_pingpong_MESSAGE * msg)
+sendPlaintext (const GNUNET_PeerIdentity * peer,
+               const P2P_pingpong_MESSAGE * msg)
 {
   TSession *mytsession;
   int ret;
 
-  mytsession = transport->connectFreely (peer, YES, __FILE__);
+  mytsession = transport->connectFreely (peer, GNUNET_YES, __FILE__);
   if (mytsession == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   ret = coreAPI->sendPlaintext (mytsession,
                                 (char *) msg, sizeof (P2P_pingpong_MESSAGE));
   transport->disconnect (mytsession, __FILE__);
@@ -182,11 +184,11 @@
  * connection module that the session is still life.
  */
 static int
-plaintextPingReceived (const PeerIdentity * sender,
-                       const MESSAGE_HEADER * hmsg, TSession * tsession)
+plaintextPingReceived (const GNUNET_PeerIdentity * sender,
+                       const GNUNET_MessageHeader * hmsg, TSession * tsession)
 {
 #if DEBUG_PINGPONG
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
   const P2P_pingpong_MESSAGE *pmsg;
   P2P_pingpong_MESSAGE pong;
@@ -198,21 +200,21 @@
               GE_WARNING | GE_BULK | GE_USER | GE_DEVELOPER,
               _("Received malformed `%s' message. Dropping.\n"), "ping");
       GE_BREAK_OP (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   pmsg = (const P2P_pingpong_MESSAGE *) hmsg;
   if (0 != memcmp (coreAPI->myIdentity,
-                   &pmsg->receiver, sizeof (PeerIdentity)))
+                   &pmsg->receiver, sizeof (GNUNET_PeerIdentity)))
     {
       GE_LOG (ectx,
               GE_INFO | GE_REQUEST | GE_ADMIN,
               _("Received PING not destined for us!\n"));
       GE_BREAK_OP (NULL, 0);
-      return SYSERR;            /* not for us */
+      return GNUNET_SYSERR;     /* not for us */
     }
 
 #if DEBUG_PINGPONG
-  hash2enc (&sender->hashPubKey, &enc);
+  GNUNET_hash_to_enc (&sender->hashPubKey, &enc);
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Received plaintext ping from peer %s.\n", &enc);
@@ -221,14 +223,14 @@
   pong.header.type = htons (p2p_PROTO_PONG);
   /* allow using a different transport for sending the reply, the
      transport may have been uni-directional! */
-  ret = SYSERR;
+  ret = GNUNET_SYSERR;
   if (tsession != NULL)
     ret = coreAPI->sendPlaintext (tsession,
                                   (char *) &pong,
                                   sizeof (P2P_pingpong_MESSAGE));
-  if (ret != OK)
+  if (ret != GNUNET_OK)
     ret = sendPlaintext (sender, &pong);
-  if (ret == OK)
+  if (ret == GNUNET_OK)
     {
       if (stats != NULL)
         stats->change (stat_plaintextPongSent, 1);
@@ -245,27 +247,28 @@
  * Handler for a pong.
  */
 static int
-pongReceived (const PeerIdentity * sender, const MESSAGE_HEADER * msg)
+pongReceived (const GNUNET_PeerIdentity * sender,
+              const GNUNET_MessageHeader * msg)
 {
   int i;
   const P2P_pingpong_MESSAGE *pmsg;
   PingPongEntry *entry;
   int matched;
 #if DEBUG_PINGPONG
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   pmsg = (const P2P_pingpong_MESSAGE *) msg;
   if ((ntohs (msg->size) != sizeof (P2P_pingpong_MESSAGE)) ||
-      (0 != memcmp (sender, &pmsg->receiver, sizeof (PeerIdentity))))
+      (0 != memcmp (sender, &pmsg->receiver, sizeof (GNUNET_PeerIdentity))))
     {
       GE_LOG (ectx,
               GE_WARNING | GE_BULK | GE_USER | GE_DEVELOPER,
               _("Received malformed `%s' message. Dropping.\n"), "pong");
-      return SYSERR;            /* bad pong */
+      return GNUNET_SYSERR;     /* bad pong */
     }
 #if DEBUG_PINGPONG
-  hash2enc (&sender->hashPubKey, &enc);
+  GNUNET_hash_to_enc (&sender->hashPubKey, &enc);
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Received PONG from `%s'.\n", &enc);
@@ -273,14 +276,15 @@
   matched = 0;
   if (stats != NULL)
     stats->change (stat_encryptedPongReceived, 1);
-  MUTEX_LOCK (pingPongLock);
+  GNUNET_mutex_lock (pingPongLock);
   for (i = 0; i < MAX_PING_PONG; i++)
     {
       entry = &pingPongs[i];
       if (((int) ntohl (pmsg->challenge) == entry->challenge) &&
           (0 == memcmp (sender,
                         &entry->receiverIdentity,
-                        sizeof (PeerIdentity))) && (entry->plaintext == NO))
+                        sizeof (GNUNET_PeerIdentity)))
+          && (entry->plaintext == GNUNET_NO))
         {
           entry->method (entry->data);
           /* entry was valid for one time only */
@@ -288,9 +292,9 @@
           matched++;
         }
     }
-  MUTEX_UNLOCK (pingPongLock);
+  GNUNET_mutex_unlock (pingPongLock);
 #if DEBUG_PINGPONG
-  hash2enc (&sender->hashPubKey, &enc);
+  GNUNET_hash_to_enc (&sender->hashPubKey, &enc);
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Received PONG from `%s' matched %u peers.\n", &enc, matched);
@@ -304,44 +308,45 @@
                 "Try increasing MAX_PING_PONG constant.\n"));
 #endif
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Handler for a pong.
  */
 static int
-plaintextPongReceived (const PeerIdentity * sender,
-                       const MESSAGE_HEADER * msg, TSession * session)
+plaintextPongReceived (const GNUNET_PeerIdentity * sender,
+                       const GNUNET_MessageHeader * msg, TSession * session)
 {
   int i;
   const P2P_pingpong_MESSAGE *pmsg;
   PingPongEntry *entry;
   int matched;
 #if DEBUG_PINGPONG
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   pmsg = (const P2P_pingpong_MESSAGE *) msg;
   if ((ntohs (msg->size) != sizeof (P2P_pingpong_MESSAGE)) ||
-      (0 != memcmp (sender, &pmsg->receiver, sizeof (PeerIdentity))))
+      (0 != memcmp (sender, &pmsg->receiver, sizeof (GNUNET_PeerIdentity))))
     {
       GE_LOG (ectx,
               GE_WARNING | GE_BULK | GE_USER | GE_DEVELOPER,
               _("Received malformed `%s' message. Dropping.\n"), "pong");
-      return SYSERR;            /* bad pong */
+      return GNUNET_SYSERR;     /* bad pong */
     }
   if (stats != NULL)
     stats->change (stat_plaintextPongReceived, 1);
   matched = 0;
-  MUTEX_LOCK (pingPongLock);
+  GNUNET_mutex_lock (pingPongLock);
   for (i = 0; i < MAX_PING_PONG; i++)
     {
       entry = &pingPongs[i];
       if (((int) ntohl (pmsg->challenge) == entry->challenge) &&
           (0 == memcmp (sender,
                         &entry->receiverIdentity,
-                        sizeof (PeerIdentity))) && (entry->plaintext == YES))
+                        sizeof (GNUNET_PeerIdentity)))
+          && (entry->plaintext == GNUNET_YES))
         {
           entry->method (entry->data);
           /* entry was valid for one time only */
@@ -349,9 +354,9 @@
           matched++;
         }
     }
-  MUTEX_UNLOCK (pingPongLock);
+  GNUNET_mutex_unlock (pingPongLock);
 #if DEBUG_PINGPONG
-  hash2enc (&sender->hashPubKey, &enc);
+  GNUNET_hash_to_enc (&sender->hashPubKey, &enc);
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Received plaintext PONG from `%s' matched %u peers.\n",
@@ -366,7 +371,7 @@
                 "Try increasing MAX_PING_PONG constant.\n"));
 #endif
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -378,22 +383,22 @@
  * @param receiver the peer that should be PINGed
  * @param method the method to call if a PONG comes back
  * @param data an argument to pass to the method.
- * @param plaintext is the PONG expected to be in plaintext (YES/NO)
+ * @param plaintext is the PONG expected to be in plaintext 
(GNUNET_YES/GNUNET_NO)
  * @returns NULL on error, otherwise the PING message
  */
-static MESSAGE_HEADER *
-createPing (const PeerIdentity * receiver,
-            CronJob method, void *data, int plaintext, int challenge)
+static GNUNET_MessageHeader *
+createPing (const GNUNET_PeerIdentity * receiver,
+            GNUNET_CronJob method, void *data, int plaintext, int challenge)
 {
   int i;
   int j;
-  TIME_T min;
+  GNUNET_Int32Time min;
   PingPongEntry *entry;
-  TIME_T now;
+  GNUNET_Int32Time now;
   P2P_pingpong_MESSAGE *pmsg;
 
-  MUTEX_LOCK (pingPongLock);
-  now = TIME (&min);            /* set both, tricky... */
+  GNUNET_mutex_lock (pingPongLock);
+  now = GNUNET_get_time_int32 (&min);   /* set both, tricky... */
 
   j = -1;
   for (i = 0; i < MAX_PING_PONG; i++)
@@ -408,23 +413,23 @@
               GE_WARNING | GE_BULK | GE_ADMIN,
               _("Cannot create PING, table full. "
                 "Try increasing MAX_PING_PONG.\n"));
-      MUTEX_UNLOCK (pingPongLock);
+      GNUNET_mutex_unlock (pingPongLock);
       return NULL;
     }
   entry = &pingPongs[j];
   entry->sendTime = now;
   entry->method = method;
   entry->plaintext = plaintext;
-  FREENONNULL (entry->data);
+  GNUNET_free_non_null (entry->data);
   entry->data = data;
   entry->receiverIdentity = *receiver;
-  pmsg = MALLOC (sizeof (P2P_pingpong_MESSAGE));
+  pmsg = GNUNET_malloc (sizeof (P2P_pingpong_MESSAGE));
   pmsg->header.size = htons (sizeof (P2P_pingpong_MESSAGE));
   pmsg->header.type = htons (p2p_PROTO_PING);
   pmsg->receiver = *receiver;
   entry->challenge = challenge;
   pmsg->challenge = htonl (challenge);
-  MUTEX_UNLOCK (pingPongLock);
+  GNUNET_mutex_unlock (pingPongLock);
   if (stats != NULL)
     stats->change (stat_pingCreated, 1);
   return &pmsg->header;
@@ -434,26 +439,28 @@
  * Ping a host an call a method if a reply comes back.
  *
  * @param receiver the peer that should be PINGed
- * @param usePlaintext send the PING in plaintext (YES/NO)
+ * @param usePlaintext send the PING in plaintext (GNUNET_YES/GNUNET_NO)
  * @param method the method to call if a PONG comes back
  * @param data an argument to pass to the method.
- * @returns OK on success, SYSERR on error
+ * @returns GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
-initiatePing (const PeerIdentity * receiver,
-              CronJob method, void *data, int usePlaintext, int challenge)
+initiatePing (const GNUNET_PeerIdentity * receiver,
+              GNUNET_CronJob method, void *data, int usePlaintext,
+              int challenge)
 {
-  MESSAGE_HEADER *pmsg;
+  GNUNET_MessageHeader *pmsg;
 
   pmsg = createPing (receiver, method, data, usePlaintext, challenge);
   if (pmsg == NULL)
-    return SYSERR;
-  if (usePlaintext == YES)
+    return GNUNET_SYSERR;
+  if (usePlaintext == GNUNET_YES)
     {
-      if (OK != sendPlaintext (receiver, (const P2P_pingpong_MESSAGE *) pmsg))
+      if (GNUNET_OK !=
+          sendPlaintext (receiver, (const P2P_pingpong_MESSAGE *) pmsg))
         {
-          FREE (pmsg);
-          return SYSERR;
+          GNUNET_free (pmsg);
+          return GNUNET_SYSERR;
         }
       if (stats != NULL)
         stats->change (stat_plaintextPingSent, 1);
@@ -464,8 +471,8 @@
       if (stats != NULL)
         stats->change (stat_ciphertextPingSent, 1);
     }
-  FREE (pmsg);
-  return OK;
+  GNUNET_free (pmsg);
+  return GNUNET_OK;
 }
 
 /**
@@ -519,7 +526,7 @@
     }
   pingPongLock = capi->getConnectionModuleLock ();
   pingPongs =
-    (PingPongEntry *) MALLOC (sizeof (PingPongEntry) * MAX_PING_PONG);
+    (PingPongEntry *) GNUNET_malloc (sizeof (PingPongEntry) * MAX_PING_PONG);
   memset (pingPongs, 0, sizeof (PingPongEntry) * MAX_PING_PONG);
   GE_LOG (ectx,
           GE_DEBUG | GE_USER | GE_REQUEST,
@@ -550,8 +557,8 @@
   coreAPI->releaseService (identity);
   identity = NULL;
   for (i = 0; i < MAX_PING_PONG; i++)
-    FREENONNULL (pingPongs[i].data);
-  FREE (pingPongs);
+    GNUNET_free_non_null (pingPongs[i].data);
+  GNUNET_free (pingPongs);
   coreAPI->unregisterHandler (p2p_PROTO_PING, &pingReceived);
   coreAPI->unregisterHandler (p2p_PROTO_PONG, &pongReceived);
   coreAPI->unregisterPlaintextHandler (p2p_PROTO_PING,
@@ -559,7 +566,7 @@
   coreAPI->unregisterPlaintextHandler (p2p_PROTO_PONG,
                                        &plaintextPongReceived);
   coreAPI = NULL;
-  return OK;
+  return GNUNET_OK;
 }
 
 /* end of pingpong.c */

Modified: GNUnet/src/applications/rpc/Makefile.am
===================================================================
--- GNUnet/src/applications/rpc/Makefile.am     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/rpc/Makefile.am     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -13,8 +13,6 @@
 
 libgnunetmodule_rpc_la_LIBADD = \
   $(top_builddir)/src/util/libgnunetutil.la \
-  $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
-  $(top_builddir)/src/util/containers/libgnunetutil_containers.la \
   $(top_builddir)/src/applications/rpc/libgnunetrpc_util.la
 
 libgnunetmodule_rpc_la_LDFLAGS = \
@@ -24,7 +22,6 @@
   parameters.c 
 
 libgnunetrpc_util_la_LIBADD = \
-  $(top_builddir)/src/util/containers/libgnunetutil_containers.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 
@@ -37,5 +34,4 @@
   parameterstest.c 
 
 parameterstest_LDADD = \
-  $(top_builddir)/src/util/containers/libgnunetutil_containers.la \
   $(top_builddir)/src/util/libgnunetutil.la 

Modified: GNUnet/src/applications/rpc/parameters.c
===================================================================
--- GNUnet/src/applications/rpc/parameters.c    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/rpc/parameters.c    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -32,7 +32,7 @@
 
 /**
  * A parameter to/from an RPC call. These (and nothing else) are stored in
- * the Vector of the RPC_Param structure.
+ * the GNUNET_Vector of the RPC_Param structure.
  */
 typedef struct
 {
@@ -49,7 +49,7 @@
 RPC_Param *
 RPC_paramNew ()
 {
-  return vectorNew (4);
+  return GNUNET_vector_create (4);
 }
 
 /**
@@ -64,14 +64,14 @@
 {
   if (param == NULL)
     return;
-  while (vectorSize (param) > 0)
+  while (GNUNET_vector_get_size (param) > 0)
     {
-      Parameter *p = vectorRemoveLast (param);
-      FREE (p->name);
-      FREE (p->data);
-      FREE (p);
+      Parameter *p = GNUNET_vector_delete_last (param);
+      GNUNET_free (p->name);
+      GNUNET_free (p->data);
+      GNUNET_free (p);
     }
-  vectorFree (param);
+  GNUNET_vector_destroy (param);
 }
 
 /**
@@ -191,7 +191,7 @@
 {
   if (param == NULL)
     return 0;
-  return vectorSize (param);
+  return GNUNET_vector_get_size (param);
 }
 
 
@@ -215,8 +215,8 @@
 
   if (param == NULL)
     return;
-  new = MALLOC (sizeof (Parameter));
-  new->name = STRDUP (name);
+  new = GNUNET_malloc (sizeof (Parameter));
+  new->name = GNUNET_strdup (name);
   new->dataLength = dataLength;
   if (dataLength == 0)
     {
@@ -224,10 +224,10 @@
     }
   else
     {
-      new->data = MALLOC (dataLength);
+      new->data = GNUNET_malloc (dataLength);
       memcpy (new->data, data, dataLength);
     }
-  vectorInsertLast (param, new);
+  GNUNET_vector_insert_last (param, new);
 }
 
 
@@ -250,8 +250,8 @@
 
   if (param == NULL)
     return;
-  new = MALLOC (sizeof (Parameter));
-  new->name = STRDUP (name);
+  new = GNUNET_malloc (sizeof (Parameter));
+  new->name = GNUNET_strdup (name);
   new->dataLength = ntohl (data->size) - sizeof (DataContainer);
   if (new->dataLength == 0)
     {
@@ -259,10 +259,10 @@
     }
   else
     {
-      new->data = MALLOC (new->dataLength);
+      new->data = GNUNET_malloc (new->dataLength);
       memcpy (new->data, &data[1], new->dataLength);
     }
-  vectorInsertLast (param, new);
+  GNUNET_vector_insert_last (param, new);
 }
 
 /**
@@ -279,7 +279,7 @@
 
   if (param == NULL)
     return NULL;
-  p = vectorGetAt (param, i);
+  p = GNUNET_vector_get (param, i);
   if (p)
     return p->name;
   else
@@ -292,7 +292,7 @@
  *
  * @param param Target RPC parameter structure
  * @param value set to the value of the named parameter
- * @return SYSERR on error
+ * @return GNUNET_SYSERR on error
  */
 int
 RPC_paramValueByName (RPC_Param * param,
@@ -302,20 +302,20 @@
   Parameter *p;
 
   if (param == NULL)
-    return SYSERR;
-  p = vectorGetFirst (param);
+    return GNUNET_SYSERR;
+  p = GNUNET_vector_get_first (param);
   while (p != NULL)
     {
       if (!strcmp (p->name, name))
         {
           *value = p->data;
           *dataLength = p->dataLength;
-          return OK;
+          return GNUNET_OK;
         }
-      p = vectorGetNext (param);
+      p = GNUNET_vector_get_next (param);
     }
 
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -323,7 +323,7 @@
  *
  * @param param Target RPC parameter structure
  * @param value set to the value of the named parameter
- * @return SYSERR on error
+ * @return GNUNET_SYSERR on error
  */
 DataContainer *
 RPC_paramDataContainerByName (RPC_Param * param, const char *name)
@@ -333,17 +333,17 @@
 
   if (param == NULL)
     return NULL;
-  p = vectorGetFirst (param);
+  p = GNUNET_vector_get_first (param);
   while (p != NULL)
     {
       if (!strcmp (p->name, name))
         {
-          ret = MALLOC (sizeof (DataContainer) + p->dataLength);
+          ret = GNUNET_malloc (sizeof (DataContainer) + p->dataLength);
           ret->size = htonl (sizeof (DataContainer) + p->dataLength);
           memcpy (&ret[1], p->data, p->dataLength);
           return ret;
         }
-      p = vectorGetNext (param);
+      p = GNUNET_vector_get_next (param);
     }
 
   return NULL;
@@ -363,15 +363,15 @@
   Parameter *p;
 
   if (param == NULL)
-    return SYSERR;
-  p = vectorGetAt (param, i);
+    return GNUNET_SYSERR;
+  p = GNUNET_vector_get (param, i);
   if (p != NULL)
     {
       *dataLength = p->dataLength;
       *value = p->data;
-      return OK;
+      return GNUNET_OK;
     }
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -388,10 +388,10 @@
 
   if (param == NULL)
     return NULL;
-  p = vectorGetAt (param, i);
+  p = GNUNET_vector_get (param, i);
   if (p != NULL)
     {
-      ret = MALLOC (sizeof (DataContainer) + p->dataLength);
+      ret = GNUNET_malloc (sizeof (DataContainer) + p->dataLength);
       ret->size = htonl (sizeof (DataContainer) + p->dataLength);
       memcpy (&ret[1], p->data, p->dataLength);
       return ret;

Modified: GNUnet/src/applications/rpc/parameterstest.c
===================================================================
--- GNUnet/src/applications/rpc/parameterstest.c        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/rpc/parameterstest.c        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -36,10 +36,10 @@
 
   p = RPC_paramNew ();
 
-  if (SYSERR != RPC_paramValueByPosition (p, 0, &len, &buf))
+  if (GNUNET_SYSERR != RPC_paramValueByPosition (p, 0, &len, &buf))
     return 1;
 
-  if (SYSERR != RPC_paramValueByName (p, "not there", &len, &buf))
+  if (GNUNET_SYSERR != RPC_paramValueByName (p, "not there", &len, &buf))
     return 1;
 
   if (RPC_paramCount (p) != 0)
@@ -54,31 +54,31 @@
     return 1;
 
   size = RPC_paramSize (p);
-  buf = MALLOC (size);
+  buf = GNUNET_malloc (size);
   RPC_paramSerialize (p, buf);
   RPC_paramFree (p);
   p = RPC_paramDeserialize (buf, size);
-  FREE (buf);
+  GNUNET_free (buf);
   if (p == NULL)
     return 1;
   buf = NULL;
-  if (OK != RPC_paramValueByName (p, "foo", &len, &buf))
+  if (GNUNET_OK != RPC_paramValueByName (p, "foo", &len, &buf))
     return 1;
   if (strcmp ("bar", buf) != 0)
     return 1;
   buf = NULL;
   if (4 != len)
     return 1;
-  if (OK != RPC_paramValueByPosition (p, 1, &len, &buf))
+  if (GNUNET_OK != RPC_paramValueByPosition (p, 1, &len, &buf))
     return 1;
   if (strcmp ("foo", buf) != 0)
     return 1;
   if (4 != len)
     return 1;
-  if (SYSERR != RPC_paramValueByPosition (p, 2, &len, &buf))
+  if (GNUNET_SYSERR != RPC_paramValueByPosition (p, 2, &len, &buf))
     return 1;
 
-  if (SYSERR != RPC_paramValueByName (p, "not there", &len, &buf))
+  if (GNUNET_SYSERR != RPC_paramValueByName (p, "not there", &len, &buf))
     return 1;
   RPC_paramFree (p);
 

Modified: GNUnet/src/applications/rpc/rpc.c
===================================================================
--- GNUnet/src/applications/rpc/rpc.c   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/rpc/rpc.c   2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,34 +32,34 @@
  * Flag that determines if the RPC test will be build as
  * an application module.
  */
-#define PROVIDE_RPC_TEST YES
+#define PROVIDE_RPC_TEST GNUNET_YES
 
 /**
  * Print messages helpful for debugging the RPC code.
  */
-#define DEBUG_RPC NO
+#define DEBUG_RPC GNUNET_NO
 
 /**
  * Print messages helpful for debugging RPC clients.
  */
-#define DEBUG_RPC_CLIENT NO
+#define DEBUG_RPC_CLIENT GNUNET_NO
 
 /**
  * Minimum delay between retry attempts for RPC messages.
  */
-#define MIN_RPC_FREQUENCY (50 * cronMILLIS)
+#define MIN_RPC_FREQUENCY (50 * GNUNET_CRON_MILLISECONDS)
 
 /**
  * Initial minimum delay between retry attempts for RPC messages
  * (before we figure out how fast the connection really is).
  */
-#define INITIAL_RPC_FREQUENCY (15 * cronSECONDS)
+#define INITIAL_RPC_FREQUENCY (15 * GNUNET_CRON_SECONDS)
 
 /**
  * After what time do we time-out every request (if it is not
  * repeated)?
  */
-#define MAX_RPC_TIMEOUT (2 * cronMINUTES)
+#define MAX_RPC_TIMEOUT (2 * GNUNET_CRON_MINUTES)
 
 
 #if DEBUG_RPC_CLIENT
@@ -79,7 +79,7 @@
  * lock must be held by the thread that accesses any module-wide accessable
  * data structures.
  */
-static struct MUTEX *rpcLock;
+static struct GNUNET_Mutex *rpcLock;
 
 static struct GE_Context *ectx;
 
@@ -106,14 +106,14 @@
  * A set of RegisteredRPC structures, one for each RPC registered by the
  * local node.
  */
-static struct Vector *list_of_callbacks;
+static struct GNUNET_Vector *list_of_callbacks;
 
 
 /**
  * Registers an RPC callback under the given name.
  * @param name the name of the callback, must not be NULL
  * @param callback the function to call
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  *   (typically if a callback of that name is already in use).
  */
 static int
@@ -123,38 +123,39 @@
 
   GE_ASSERT (ectx, name != NULL);
   GE_ASSERT (ectx, callback != NULL);
-  MUTEX_LOCK (rpcLock);
-  rrpc = vectorGetFirst (list_of_callbacks);
+  GNUNET_mutex_lock (rpcLock);
+  rrpc = GNUNET_vector_get_first (list_of_callbacks);
   while (rrpc != NULL)
     {
       if (0 == strcmp (rrpc->name, name))
         {
-          MUTEX_UNLOCK (rpcLock);
+          GNUNET_mutex_unlock (rpcLock);
           GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
                   _("%s::%s - RPC %s:%p could not be registered:"
                     " another callback is already using this name (%p)\n"),
                   __FILE__, __FUNCTION__, name, callback, rrpc->callback);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
-      rrpc = vectorGetNext (list_of_callbacks);
+      rrpc = GNUNET_vector_get_next (list_of_callbacks);
     }
-  rrpc = MALLOC (sizeof (RegisteredRPC));
-  rrpc->name = STRDUP (name);
+  rrpc = GNUNET_malloc (sizeof (RegisteredRPC));
+  rrpc->name = GNUNET_strdup (name);
   rrpc->callback = callback;
   rrpc->async_callback = NULL;
-  vectorInsertLast (list_of_callbacks, rrpc);
+  GNUNET_vector_insert_last (list_of_callbacks, rrpc);
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "%s::%s - Registered RPC %d: %s\n",
-          __FILE__, __FUNCTION__, vectorSize (list_of_callbacks), name);
-  MUTEX_UNLOCK (rpcLock);
-  return OK;
+          __FILE__, __FUNCTION__, GNUNET_vector_get_size (list_of_callbacks),
+          name);
+  GNUNET_mutex_unlock (rpcLock);
+  return GNUNET_OK;
 }
 
 /**
  * Registers an async RPC callback under the given name.
  * @param name the name of the callback, must not be NULL
  * @param callback the function to call
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  *   (typically if a callback of that name is already in use).
  */
 static int
@@ -164,31 +165,32 @@
 
   GE_ASSERT (ectx, name != NULL);
   GE_ASSERT (ectx, callback != NULL);
-  MUTEX_LOCK (rpcLock);
-  rrpc = vectorGetFirst (list_of_callbacks);
+  GNUNET_mutex_lock (rpcLock);
+  rrpc = GNUNET_vector_get_first (list_of_callbacks);
   while (rrpc != NULL)
     {
       if (0 == strcmp (rrpc->name, name))
         {
-          MUTEX_UNLOCK (rpcLock);
+          GNUNET_mutex_unlock (rpcLock);
           GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
                   _("%s::%s - RPC %s:%p could not be registered:"
                     " another callback is already using this name (%p)\n"),
                   __FILE__, __FUNCTION__, name, callback, rrpc->callback);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
-      rrpc = vectorGetNext (list_of_callbacks);
+      rrpc = GNUNET_vector_get_next (list_of_callbacks);
     }
-  rrpc = MALLOC (sizeof (RegisteredRPC));
-  rrpc->name = STRDUP (name);
+  rrpc = GNUNET_malloc (sizeof (RegisteredRPC));
+  rrpc->name = GNUNET_strdup (name);
   rrpc->callback = NULL;
   rrpc->async_callback = callback;
-  vectorInsertLast (list_of_callbacks, rrpc);
+  GNUNET_vector_insert_last (list_of_callbacks, rrpc);
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "%s::%s - Registered asynchronous RPC %d: %s\n",
-          __FILE__, __FUNCTION__, vectorSize (list_of_callbacks), name);
-  MUTEX_UNLOCK (rpcLock);
-  return OK;
+          __FILE__, __FUNCTION__, GNUNET_vector_get_size (list_of_callbacks),
+          name);
+  GNUNET_mutex_unlock (rpcLock);
+  return GNUNET_OK;
 }
 
 
@@ -196,7 +198,7 @@
  * Unregisters an RPC callback of the given name.
  * @param name the name of the callback, must not be NULL
  * @param callback the function to unregister, NULL for any function
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  *   (typically if a callback of that name does not exist or is
  *    bound to a different function).
  */
@@ -206,8 +208,8 @@
   RegisteredRPC *rrpc;
 
   GE_ASSERT (ectx, name != NULL);
-  MUTEX_LOCK (rpcLock);
-  rrpc = vectorGetFirst (list_of_callbacks);
+  GNUNET_mutex_lock (rpcLock);
+  rrpc = GNUNET_vector_get_first (list_of_callbacks);
   while (rrpc != NULL)
     {
       if (0 == strcmp (rrpc->name, name))
@@ -218,32 +220,32 @@
                       _("%s::%s - RPC %s:%p could not be unregistered:"
                         " another callback registered under that name: %p\n"),
                       __FILE__, __FUNCTION__, name, callback, rrpc->callback);
-              MUTEX_UNLOCK (rpcLock);
-              return SYSERR;
+              GNUNET_mutex_unlock (rpcLock);
+              return GNUNET_SYSERR;
             }
-          vectorRemoveObject (list_of_callbacks, rrpc);
-          FREE (rrpc->name);
-          FREE (rrpc);
-          MUTEX_UNLOCK (rpcLock);
+          GNUNET_vector_delete (list_of_callbacks, rrpc);
+          GNUNET_free (rrpc->name);
+          GNUNET_free (rrpc);
+          GNUNET_mutex_unlock (rpcLock);
           GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
                   "%s::%s - Unregistered RPC %s\n",
                   __FILE__, __FUNCTION__, name);
-          return OK;
+          return GNUNET_OK;
         }
-      rrpc = vectorGetNext (list_of_callbacks);
+      rrpc = GNUNET_vector_get_next (list_of_callbacks);
     }
-  MUTEX_UNLOCK (rpcLock);
+  GNUNET_mutex_unlock (rpcLock);
   GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
           _("%s::%s - RPC %s:%p could not be unregistered: not found\n"),
           __FILE__, __FUNCTION__, name, callback);
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /**
  * Unregisters an asynchronous RPC callback of the given name.
  * @param name the name of the callback, must not be NULL
  * @param callback the function to unregister, NULL for any function
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  *   (typically if a callback of that name does not exist or is
  *    bound to a different function).
  */
@@ -253,8 +255,8 @@
   RegisteredRPC *rrpc;
 
   GE_ASSERT (ectx, name != NULL);
-  MUTEX_LOCK (rpcLock);
-  rrpc = vectorGetFirst (list_of_callbacks);
+  GNUNET_mutex_lock (rpcLock);
+  rrpc = GNUNET_vector_get_first (list_of_callbacks);
   while (rrpc != NULL)
     {
       if (0 == strcmp (rrpc->name, name))
@@ -265,26 +267,26 @@
                       _("%s::%s - RPC %s:%p could not be unregistered:"
                         " another callback registered under that name: %p\n"),
                       __FILE__, __FUNCTION__, name, callback, rrpc->callback);
-              MUTEX_UNLOCK (rpcLock);
-              return SYSERR;
+              GNUNET_mutex_unlock (rpcLock);
+              return GNUNET_SYSERR;
             }
-          vectorRemoveObject (list_of_callbacks, rrpc);
-          FREE (rrpc->name);
-          FREE (rrpc);
-          MUTEX_UNLOCK (rpcLock);
+          GNUNET_vector_delete (list_of_callbacks, rrpc);
+          GNUNET_free (rrpc->name);
+          GNUNET_free (rrpc);
+          GNUNET_mutex_unlock (rpcLock);
           GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
                   "%s::%s - Unregistered asynchronous RPC %s\n",
                   __FILE__, __FUNCTION__, name);
-          return OK;
+          return GNUNET_OK;
         }
-      rrpc = vectorGetNext (list_of_callbacks);
+      rrpc = GNUNET_vector_get_next (list_of_callbacks);
     }
-  MUTEX_UNLOCK (rpcLock);
+  GNUNET_mutex_unlock (rpcLock);
   GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
           _
           ("%s::%s - async RPC %s:%p could not be unregistered: not found\n"),
           __FILE__, __FUNCTION__, name, callback);
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 
@@ -293,7 +295,7 @@
 /**
  * What is the time-interval for which we keep activity stats?
  */
-#define PEER_TRACKING_TIME_INTERVAL (30 * cronSECONDS)
+#define PEER_TRACKING_TIME_INTERVAL (30 * GNUNET_CRON_SECONDS)
 
 /**
  * Of how many messages do we keep track per peer (for statistics).
@@ -305,12 +307,12 @@
  */
 typedef struct
 {
-  PeerIdentity identity;
+  GNUNET_PeerIdentity identity;
 
   /**
    * What is the expected response time for this peer? (0 for unknown)
    */
-  cron_t averageResponseTime;
+  GNUNET_CronTime averageResponseTime;
 
   /**
    * In which of the last 32 time intervals did we send a message?
@@ -330,7 +332,7 @@
    * What were the last times when requests were send to the peer?
    * 0 for no request send *or* last request was repeated.
    */
-  cron_t lastRequestTimes[MTRACK_COUNT];
+  GNUNET_CronTime lastRequestTimes[MTRACK_COUNT];
 
   /**
    * Message ID of the last requests.
@@ -346,22 +348,22 @@
 
 /**
  * A set of Peer structures, one for each GNUnet peer (as identified by
- * PeerIdentity) known to the RPC module. Peers are added as either RPC's
+ * GNUNET_PeerIdentity) known to the RPC module. Peers are added as either 
RPC's
  * are made to them from the local node, or an RPC call is received from them.
  */
-static struct Vector *peerInformation;
+static struct GNUNET_Vector *peerInformation;
 
 static PeerInfo *
-getPeerInfo (const PeerIdentity * id)
+getPeerInfo (const GNUNET_PeerIdentity * id)
 {
   PeerInfo *pi;
 
-  pi = (PeerInfo *) vectorGetFirst (peerInformation);
+  pi = (PeerInfo *) GNUNET_vector_get_first (peerInformation);
   while (pi != NULL)
     {
-      if (0 == memcmp (id, &pi->identity, sizeof (PeerIdentity)))
+      if (0 == memcmp (id, &pi->identity, sizeof (GNUNET_PeerIdentity)))
         return pi;
-      pi = (PeerInfo *) vectorGetNext (peerInformation);
+      pi = (PeerInfo *) GNUNET_vector_get_next (peerInformation);
     }
   return NULL;
 }
@@ -370,19 +372,19 @@
  * What is the expected response time for this peer?
  * @return 0 for unknown
  */
-static cron_t
-getExpectedResponseTime (const PeerIdentity * peer)
+static GNUNET_CronTime
+getExpectedResponseTime (const GNUNET_PeerIdentity * peer)
 {
-  cron_t result;
+  GNUNET_CronTime result;
   PeerInfo *pi;
 
-  MUTEX_LOCK (rpcLock);
+  GNUNET_mutex_lock (rpcLock);
   pi = getPeerInfo (peer);
   if (pi == NULL)
     result = 0;
   else
     result = pi->averageResponseTime;
-  MUTEX_UNLOCK (rpcLock);
+  GNUNET_mutex_unlock (rpcLock);
   return result;
 }
 
@@ -394,21 +396,21 @@
 {
   PeerInfo *pi;
 
-  MUTEX_LOCK (rpcLock);
-  pi = vectorGetFirst (peerInformation);
+  GNUNET_mutex_lock (rpcLock);
+  pi = GNUNET_vector_get_first (peerInformation);
   while (pi != NULL)
     {
       pi->agedActivitySend = pi->agedActivitySend / 2;
       pi->agedActivityRecv = pi->agedActivityRecv / 2;
       if ((pi->agedActivitySend == 0) && (pi->agedActivityRecv == 0))
         {
-          vectorRemoveObject (peerInformation, pi);
-          FREE (pi);
+          GNUNET_vector_delete (peerInformation, pi);
+          GNUNET_free (pi);
         }
 
-      pi = vectorGetNext (peerInformation);
+      pi = GNUNET_vector_get_next (peerInformation);
     }
-  MUTEX_UNLOCK (rpcLock);
+  GNUNET_mutex_unlock (rpcLock);
 }
 
 /**
@@ -422,12 +424,12 @@
  * @param messageID pseudo-unique ID of the request
  */
 static void
-notifyPeerRequest (PeerIdentity * peer, unsigned int messageID)
+notifyPeerRequest (GNUNET_PeerIdentity * peer, unsigned int messageID)
 {
   int i;
   PeerInfo *pi;
 
-  MUTEX_LOCK (rpcLock);
+  GNUNET_mutex_lock (rpcLock);
   pi = getPeerInfo (peer);
   if (pi != NULL)
     {
@@ -436,26 +438,26 @@
           if (pi->lastRequestId[i] == messageID)
             {
               pi->lastRequestTimes[i] = 0;      /* re-send! */
-              MUTEX_UNLOCK (rpcLock);
+              GNUNET_mutex_unlock (rpcLock);
               return;
             }
         }
       pi->agedActivitySend |= 0x80000000;
-      pi->lastRequestTimes[pi->oldestRTIndex] = get_time ();
+      pi->lastRequestTimes[pi->oldestRTIndex] = GNUNET_get_time ();
       pi->lastRequestId[pi->oldestRTIndex] = messageID;
       pi->oldestRTIndex = (pi->oldestRTIndex + 1) % MTRACK_COUNT;
-      MUTEX_UNLOCK (rpcLock);
+      GNUNET_mutex_unlock (rpcLock);
       return;
     }
-  pi = MALLOC (sizeof (PeerInfo));
+  pi = GNUNET_malloc (sizeof (PeerInfo));
   memset (pi, 0, sizeof (PeerInfo));
   pi->identity = *peer;
   pi->agedActivitySend = 0x80000000;
-  pi->lastRequestTimes[0] = get_time ();
+  pi->lastRequestTimes[0] = GNUNET_get_time ();
   pi->lastRequestId[0] = messageID;
   pi->oldestRTIndex = 1;
-  vectorInsertLast (peerInformation, pi);
-  MUTEX_UNLOCK (rpcLock);
+  GNUNET_vector_insert_last (peerInformation, pi);
+  GNUNET_mutex_unlock (rpcLock);
 }
 
 /**
@@ -464,16 +466,16 @@
  *        for
  */
 static void
-notifyPeerReply (const PeerIdentity * peer, unsigned int messageID)
+notifyPeerReply (const GNUNET_PeerIdentity * peer, unsigned int messageID)
 {
   int i;
   PeerInfo *pi;
 
-  MUTEX_LOCK (rpcLock);
-  pi = vectorGetFirst (peerInformation);
+  GNUNET_mutex_lock (rpcLock);
+  pi = GNUNET_vector_get_first (peerInformation);
   while (pi != NULL)
     {
-      if (0 == memcmp (peer, &pi->identity, sizeof (PeerIdentity)))
+      if (0 == memcmp (peer, &pi->identity, sizeof (GNUNET_PeerIdentity)))
         {
           for (i = 0; i < MTRACK_COUNT; i++)
             {
@@ -483,20 +485,20 @@
                     {           /* resend */
                       pi->averageResponseTime
                         = (pi->averageResponseTime * (MTRACK_COUNT - 1) +
-                           get_time () -
+                           GNUNET_get_time () -
                            pi->lastRequestTimes[i]) / MTRACK_COUNT;
                       pi->agedActivityRecv |= 0x80000000;
                       pi->lastRequestTimes[i] = 0;
                     }
-                  MUTEX_UNLOCK (rpcLock);
+                  GNUNET_mutex_unlock (rpcLock);
                   return;
                 }
             }
           break;
         }
-      pi = vectorGetNext (peerInformation);
+      pi = GNUNET_vector_get_next (peerInformation);
     }
-  MUTEX_UNLOCK (rpcLock);
+  GNUNET_mutex_unlock (rpcLock);
 }
 
 /* ***************** RPC datastructures ****************** */
@@ -507,14 +509,14 @@
  * message is of variable size to pass arguments.  Requests and reply
  * messages use the same struct, the only difference is in the value
  * of the header.type field.  For the reply, the
- * functionNameLength indicates the status (0 for OK, otherwise an
+ * functionNameLength indicates the status (0 for GNUNET_OK, otherwise an
  * error code).  argumentCount must be 0 for errors and otherwise
  * indicate the number of return values.
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
-  TIME_T timestamp;
+  GNUNET_MessageHeader header;
+  GNUNET_Int32Time timestamp;
   unsigned int sequenceNumber;
   unsigned int importance;
   unsigned short argumentCount;
@@ -541,7 +543,7 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
   /**
    * The number of the original request for which this is the
    * ACK.
@@ -550,7 +552,7 @@
 } RPC_ACK_Message;
 
 /**
- * Signature of a function called on completion of
+ * GNUNET_RSA_Signature of a function called on completion of
  * the RPC.
  * @param context closure
  * @param sequenceNumber ID of the callback
@@ -575,7 +577,7 @@
   /**
    * For which peer is this message?
    */
-  PeerIdentity receiver;
+  GNUNET_PeerIdentity receiver;
 
   /**
    * The message we are transmitting (either the request or the
@@ -590,18 +592,18 @@
    * discarded; we always send additional ACKs even if we don't have a
    * matching record anymore).
    */
-  cron_t expirationTime;
+  GNUNET_CronTime expirationTime;
 
   /**
    * Frequency at which we currently repeat the message.  Initially
    * set to the round-trip estimate, with exponential back-off.
    */
-  cron_t repetitionFrequency;
+  GNUNET_CronTime repetitionFrequency;
 
   /**
    * Last time the message was sent.
    */
-  cron_t lastAttempt;
+  GNUNET_CronTime lastAttempt;
 
   /**
    * Number of times we have attempted to transmit.
@@ -630,13 +632,13 @@
  * A set of CallInstance structures for active incoming rpc calls.
  * (requests without a reply).
  */
-static struct Vector *incomingCalls;
+static struct GNUNET_Vector *incomingCalls;
 
 /**
  * A set of CallInstance structures for active outgoing rpc calls.
  * (reply messages without an ACK).
  */
-static struct Vector *outgoingCalls;
+static struct GNUNET_Vector *outgoingCalls;
 
 /**
  * A counter whose value is used for identifying the RPC's originating
@@ -655,12 +657,15 @@
 retryRPCJob (void *ctx)
 {
   CallInstance *call = ctx;
-  cron_t now;
+  GNUNET_CronTime now;
 
-  now = get_time ();
-  GE_ASSERT (ectx, (get_time () + 1 * cronMINUTES > call->expirationTime) ||
-             (call->expirationTime - get_time () < 1 * cronHOURS));
-  MUTEX_LOCK (rpcLock);
+  now = GNUNET_get_time ();
+  GE_ASSERT (ectx,
+             (GNUNET_get_time () + 1 * GNUNET_CRON_MINUTES >
+              call->expirationTime)
+             || (call->expirationTime - GNUNET_get_time () <
+                 1 * GNUNET_CRON_HOURS));
+  GNUNET_mutex_lock (rpcLock);
   if (now > call->expirationTime)
     {
 #if DEBUG_RPC
@@ -672,18 +677,19 @@
           call->finishedCallback (call->rpcCallbackArgs,
                                   call->sequenceNumber,
                                   RPC_ERROR_TIMEOUT, NULL);
-          vectorRemoveObject (outgoingCalls, call);
+          GNUNET_vector_delete (outgoingCalls, call);
         }
       else
         {
-          vectorRemoveObject (incomingCalls, call);
+          GNUNET_vector_delete (incomingCalls, call);
         }
-      FREE (call->msg);
-      FREE (call);
+      GNUNET_free (call->msg);
+      GNUNET_free (call);
     }
   else
     {
-      if ((coreAPI != NULL) && (call->expirationTime - now > 50 * cronMILLIS))
+      if ((coreAPI != NULL)
+          && (call->expirationTime - now > 50 * GNUNET_CRON_MILLISECONDS))
         {
           unsigned int maxdelay;
 
@@ -730,19 +736,22 @@
                             &call->msg->header,
                             ntohl (call->msg->importance), maxdelay);
         }
-      GE_ASSERT (ectx, (get_time () + 1 * cronMINUTES > call->expirationTime)
-                 || (call->expirationTime - get_time () < 1 * cronHOURS));
-      cron_add_job (coreAPI->cron, &retryRPCJob, call->repetitionFrequency, 0,
-                    call);
+      GE_ASSERT (ectx,
+                 (GNUNET_get_time () + 1 * GNUNET_CRON_MINUTES >
+                  call->expirationTime)
+                 || (call->expirationTime - GNUNET_get_time () <
+                     1 * GNUNET_CRON_HOURS));
+      GNUNET_cron_add_job (coreAPI->cron, &retryRPCJob,
+                           call->repetitionFrequency, 0, call);
     }
-  MUTEX_UNLOCK (rpcLock);
+  GNUNET_mutex_unlock (rpcLock);
 }
 
 /**
  * Send an ACK message.
  */
 static void
-sendAck (const PeerIdentity * receiver,
+sendAck (const GNUNET_PeerIdentity * receiver,
          unsigned int sequenceNumber,
          unsigned int importance, unsigned int maxDelay)
 {
@@ -763,7 +772,7 @@
   slen = ntohs (req->functionNameLength);
   if (ntohs (req->header.size) < sizeof (P2P_rpc_MESSAGE) + slen)
     return NULL;                /* invalid! */
-  ret = MALLOC (slen + 1);
+  ret = GNUNET_malloc (slen + 1);
   memcpy (ret, &((P2P_rpc_MESSAGE_GENERIC *) req)->data[0], slen);
   ret[slen] = '\0';
   return ret;
@@ -821,11 +830,11 @@
     slen = 0;
   if (values != NULL)
     size += RPC_paramSize (values);
-  if (size >= MAX_BUFFER_SIZE)
+  if (size >= GNUNET_MAX_BUFFER_SIZE)
     return NULL;                /* message to big! */
-  ret = MALLOC (size);
+  ret = GNUNET_malloc (size);
   ret->header.size = htons (size);
-  ret->timestamp = htonl (TIME (NULL));
+  ret->timestamp = htonl (GNUNET_get_time_int32 (NULL));
   ret->sequenceNumber = htonl (sequenceNumber);
   ret->importance = htonl (importance);
   if (name == NULL)
@@ -852,7 +861,7 @@
 
 
 /**
- * Signature of the callback function for the ASYNC_RPC to
+ * GNUNET_RSA_Signature of the callback function for the ASYNC_RPC to
  * be called upon completion of the ASYNC function.  Initiates
  * sending back the reply.  Also called in the synchronous RPC
  * case o complete the reply (since it's the same code).
@@ -861,7 +870,7 @@
 async_rpc_complete_callback (RPC_Param * results,
                              int errorCode, CallInstance * calls)
 {
-  MUTEX_LOCK (rpcLock);
+  GNUNET_mutex_lock (rpcLock);
   /* build reply message */
   calls->msg = buildMessage (errorCode,
                              NULL,
@@ -872,13 +881,16 @@
                                NULL,
                                calls->sequenceNumber,
                                calls->importance, results);
-  vectorInsertLast (incomingCalls, calls);
+  GNUNET_vector_insert_last (incomingCalls, calls);
 
-  GE_ASSERT (ectx, (get_time () + 1 * cronMINUTES > calls->expirationTime) ||
-             (calls->expirationTime - get_time () < 1 * cronHOURS));
+  GE_ASSERT (ectx,
+             (GNUNET_get_time () + 1 * GNUNET_CRON_MINUTES >
+              calls->expirationTime)
+             || (calls->expirationTime - GNUNET_get_time () <
+                 1 * GNUNET_CRON_HOURS));
   /* for right now: schedule cron job to send reply! */
-  cron_add_job (coreAPI->cron, &retryRPCJob, 0, 0, calls);
-  MUTEX_UNLOCK (rpcLock);
+  GNUNET_cron_add_job (coreAPI->cron, &retryRPCJob, 0, 0, calls);
+  GNUNET_mutex_unlock (rpcLock);
 }
 
 
@@ -888,8 +900,8 @@
  * reply.
  */
 static int
-handleRPCMessageReq (const PeerIdentity * sender,
-                     const MESSAGE_HEADER * message)
+handleRPCMessageReq (const GNUNET_PeerIdentity * sender,
+                     const GNUNET_MessageHeader * message)
 {
   P2P_rpc_MESSAGE *req;
   CallInstance *calls;
@@ -908,7 +920,7 @@
               GE_WARNING | GE_REQUEST | GE_ADMIN,
               _("Invalid message of type %u received.  Dropping.\n"),
               ntohs (message->type));
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   req = (P2P_rpc_MESSAGE *) message;
   sq = ntohl (req->sequenceNumber);
@@ -917,13 +929,13 @@
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Received RPC request with id %u.\n", sq);
 #endif
-  MUTEX_LOCK (rpcLock);
+  GNUNET_mutex_lock (rpcLock);
 
   /* check if message is already in incomingCalls,
      if so, update expiration, otherwise deserialize,
      perform call, add reply and create cron job */
 
-  calls = vectorGetFirst (incomingCalls);
+  calls = GNUNET_vector_get_first (incomingCalls);
   if (calls == NULL)
     minSQ = 0;
   else
@@ -933,9 +945,10 @@
       if (calls->sequenceNumber < minSQ)
         minSQ = calls->sequenceNumber;
       if ((calls->sequenceNumber == sq) &&
-          (0 == memcmp (&calls->receiver, sender, sizeof (PeerIdentity))))
+          (0 ==
+           memcmp (&calls->receiver, sender, sizeof (GNUNET_PeerIdentity))))
         break;
-      calls = vectorGetNext (incomingCalls);
+      calls = GNUNET_vector_get_next (incomingCalls);
     }
   if (calls != NULL)
     {
@@ -947,19 +960,19 @@
             pi->averageResponseTime *= 2;
         }
       RPC_STATUS ("", "received duplicate request", calls);
-      calls->expirationTime = get_time () + MAX_RPC_TIMEOUT;
+      calls->expirationTime = GNUNET_get_time () + MAX_RPC_TIMEOUT;
       GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
               "Dropping RPC request %u, duplicate.\n", sq);
-      MUTEX_UNLOCK (rpcLock);
-      return OK;                /* seen before */
+      GNUNET_mutex_unlock (rpcLock);
+      return GNUNET_OK;         /* seen before */
     }
   if (minSQ > sq)
     {
       GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
               "Dropping RPC request %u, sequence number too old (current 
minimum is %u).\n",
               sq, minSQ);
-      MUTEX_UNLOCK (rpcLock);
-      return OK;                /* seen before */
+      GNUNET_mutex_unlock (rpcLock);
+      return GNUNET_OK;         /* seen before */
     }
 
   /* deserialize */
@@ -967,29 +980,29 @@
   argumentValues = deserializeArguments (req);
   if ((functionName == NULL) || (argumentValues == NULL))
     {
-      FREENONNULL (functionName);
+      GNUNET_free_non_null (functionName);
       if (argumentValues != NULL)
         RPC_paramFree (argumentValues);
-      MUTEX_UNLOCK (rpcLock);
+      GNUNET_mutex_unlock (rpcLock);
       GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
               _("Dropping RPC request %u: message malformed.\n"));
-      return SYSERR;            /* message malformed */
+      return GNUNET_SYSERR;     /* message malformed */
     }
 
   /* find matching RPC function */
-  rpc = (RegisteredRPC *) vectorGetFirst (list_of_callbacks);
+  rpc = (RegisteredRPC *) GNUNET_vector_get_first (list_of_callbacks);
   while (rpc != NULL)
     {
       if (0 == strcmp (functionName, rpc->name))
         break;
-      rpc = (RegisteredRPC *) vectorGetNext (list_of_callbacks);
+      rpc = (RegisteredRPC *) GNUNET_vector_get_next (list_of_callbacks);
     }
-  calls = MALLOC (sizeof (CallInstance));
+  calls = GNUNET_malloc (sizeof (CallInstance));
   RPC_STATUS (functionName, "received request", calls);
-  FREE (functionName);
+  GNUNET_free (functionName);
   calls->sequenceNumber = sq;
   calls->receiver = *sender;
-  calls->expirationTime = get_time () + MAX_RPC_TIMEOUT;
+  calls->expirationTime = GNUNET_get_time () + MAX_RPC_TIMEOUT;
   calls->lastAttempt = 0;
   calls->attempts = 0;
   calls->finishedCallback = NULL;
@@ -1011,17 +1024,17 @@
           rpc->async_callback (sender,
                                argumentValues,
                                &async_rpc_complete_callback, calls);
-          MUTEX_UNLOCK (rpcLock);
-          return OK;
+          GNUNET_mutex_unlock (rpcLock);
+          return GNUNET_OK;
         }
       returnValues = RPC_paramNew ();
       rpc->callback (sender, argumentValues, returnValues);
       RPC_paramFree (argumentValues);
       errorCode = RPC_ERROR_OK;
     }
-  MUTEX_UNLOCK (rpcLock);
+  GNUNET_mutex_unlock (rpcLock);
   async_rpc_complete_callback (returnValues, errorCode, calls);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -1030,8 +1043,8 @@
  * Also always sends an ACK.
  */
 static int
-handleRPCMessageRes (const PeerIdentity * sender,
-                     const MESSAGE_HEADER * message)
+handleRPCMessageRes (const GNUNET_PeerIdentity * sender,
+                     const GNUNET_MessageHeader * message)
 {
   P2P_rpc_MESSAGE *res;
   CallInstance *call;
@@ -1042,7 +1055,7 @@
       GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
               _("Invalid message of type %u received.  Dropping.\n"),
               ntohs (message->type));
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   res = (P2P_rpc_MESSAGE *) message;
 #if DEBUG_RPC
@@ -1051,19 +1064,19 @@
           "Received RPC reply with id %u.\n", ntohl (res->sequenceNumber));
 #endif
 
-  cron_suspend (coreAPI->cron, NO);
-  MUTEX_LOCK (rpcLock);
+  GNUNET_cron_suspend_jobs (coreAPI->cron, GNUNET_NO);
+  GNUNET_mutex_lock (rpcLock);
 
   /* Locate the CallInstance structure. */
-  call = vectorGetFirst (outgoingCalls);
+  call = GNUNET_vector_get_first (outgoingCalls);
   while (call != NULL)
     {
       if ((0 == memcmp (&call->receiver,
                         sender,
-                        sizeof (PeerIdentity))) &&
+                        sizeof (GNUNET_PeerIdentity))) &&
           (call->sequenceNumber == ntohl (res->sequenceNumber)))
         break;
-      call = vectorGetNext (outgoingCalls);
+      call = GNUNET_vector_get_next (outgoingCalls);
     }
   if (NULL != call)
     {
@@ -1094,20 +1107,20 @@
                                   call->sequenceNumber, error, reply);
           call->finishedCallback = NULL;
         }
-      vectorRemoveObject (outgoingCalls, call);
+      GNUNET_vector_delete (outgoingCalls, call);
       notifyPeerReply (sender,
                        MINGLE (call->sequenceNumber, P2P_PROTO_rpc_REQ));
-      cron_del_job (coreAPI->cron, &retryRPCJob, 0, call);
-      FREE (call->msg);
-      FREE (call);
+      GNUNET_cron_del_job (coreAPI->cron, &retryRPCJob, 0, call);
+      GNUNET_free (call->msg);
+      GNUNET_free (call);
       if (reply != NULL)
         RPC_paramFree (reply);
     }
   sendAck (sender, ntohl (res->sequenceNumber), 0,      /* not important, ACK 
should be tiny enough to go through anyway */
            0 /* right away */ );
-  MUTEX_UNLOCK (rpcLock);
-  cron_resume_jobs (coreAPI->cron, NO);
-  return OK;
+  GNUNET_mutex_unlock (rpcLock);
+  GNUNET_cron_resume_jobs (coreAPI->cron, GNUNET_NO);
+  return GNUNET_OK;
 }
 
 
@@ -1115,8 +1128,8 @@
  * Handle a peer-to-peer message of type P2P_PROTO_rpc_ACK.
  */
 static int
-handleRPCMessageAck (const PeerIdentity * sender,
-                     const MESSAGE_HEADER * message)
+handleRPCMessageAck (const GNUNET_PeerIdentity * sender,
+                     const GNUNET_MessageHeader * message)
 {
   RPC_ACK_Message *ack;
   CallInstance *call;
@@ -1128,7 +1141,7 @@
               GE_WARNING | GE_REQUEST | GE_ADMIN,
               _("Invalid message of type %u received.  Dropping.\n"),
               ntohs (message->type));
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
   ack = (RPC_ACK_Message *) message;
@@ -1136,19 +1149,19 @@
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "Received RPC ACK with id %u.\n", ntohl (ack->sequenceNumber));
 #endif
-  cron_suspend (coreAPI->cron, NO);
-  MUTEX_LOCK (rpcLock);
+  GNUNET_cron_suspend_jobs (coreAPI->cron, GNUNET_NO);
+  GNUNET_mutex_lock (rpcLock);
 
   /* Locate the CallInstance structure. */
-  call = (CallInstance *) vectorGetFirst (incomingCalls);
+  call = (CallInstance *) GNUNET_vector_get_first (incomingCalls);
   while (call != NULL)
     {
       if ((0 == memcmp (&call->receiver,
                         sender,
-                        sizeof (PeerIdentity))) &&
+                        sizeof (GNUNET_PeerIdentity))) &&
           (call->sequenceNumber == ntohl (ack->sequenceNumber)))
         break;
-      call = (CallInstance *) vectorGetNext (incomingCalls);
+      call = (CallInstance *) GNUNET_vector_get_next (incomingCalls);
     }
 
   /* check if we're waiting for an ACK, if so remove job */
@@ -1158,10 +1171,10 @@
       notifyPeerReply (sender,
                        MINGLE (ntohl (ack->sequenceNumber),
                                P2P_PROTO_rpc_RES));
-      cron_del_job (coreAPI->cron, &retryRPCJob, 0, call);
-      vectorRemoveObject (incomingCalls, call);
-      FREE (call->msg);
-      FREE (call);
+      GNUNET_cron_del_job (coreAPI->cron, &retryRPCJob, 0, call);
+      GNUNET_vector_delete (incomingCalls, call);
+      GNUNET_free (call->msg);
+      GNUNET_free (call);
     }
   else
     {
@@ -1177,16 +1190,16 @@
 #endif
     }
 
-  MUTEX_UNLOCK (rpcLock);
-  cron_resume_jobs (coreAPI->cron, NO);
-  return OK;
+  GNUNET_mutex_unlock (rpcLock);
+  GNUNET_cron_resume_jobs (coreAPI->cron, GNUNET_NO);
+  return GNUNET_OK;
 }
 
 /* ********************* RPC service functions ******************** */
 
 typedef struct
 {
-  struct SEMAPHORE *sem;
+  struct GNUNET_Semaphore *sem;
   RPC_Param *result;
   unsigned short ec;
 } RPC_EXEC_CLS;
@@ -1210,7 +1223,7 @@
       RPC_paramAdd (context->result, RPC_paramName (res, i), dl, data);
     }
   context->ec = ec;
-  SEMAPHORE_UP (context->sem);
+  GNUNET_semaphore_up (context->sem);
 }
 
 /**
@@ -1224,23 +1237,24 @@
  * @return the error code of the operation (0 for success).
  */
 static int
-RPC_execute (const PeerIdentity * receiver,
+RPC_execute (const GNUNET_PeerIdentity * receiver,
              const char *name,
              RPC_Param * requestParam,
-             RPC_Param * returnParam, unsigned int importance, cron_t timeout)
+             RPC_Param * returnParam, unsigned int importance,
+             GNUNET_CronTime timeout)
 {
   RPC_EXEC_CLS cls;
   CallInstance *call;
 
-  MUTEX_LOCK (rpcLock);
-  cls.sem = SEMAPHORE_CREATE (0);
+  GNUNET_mutex_lock (rpcLock);
+  cls.sem = GNUNET_semaphore_create (0);
   cls.result = returnParam;
-  call = MALLOC (sizeof (CallInstance));
+  call = GNUNET_malloc (sizeof (CallInstance));
   RPC_STATUS (name, "started synchronously", call);
   call->lastAttempt = 0;
   call->attempts = 0;
   call->repetitionFrequency = getExpectedResponseTime (receiver);
-  call->expirationTime = get_time () + timeout;
+  call->expirationTime = GNUNET_get_time () + timeout;
   call->receiver = *receiver;
   call->sequenceNumber = rpcIdentifier++;
   call->msg = buildMessage (RPC_ERROR_OK,
@@ -1248,21 +1262,23 @@
                             call->sequenceNumber, importance, requestParam);
   call->finishedCallback = (RPCFinishedCallback) & RPC_execute_callback;
   call->rpcCallbackArgs = &cls;
-  vectorInsertLast (outgoingCalls, call);
+  GNUNET_vector_insert_last (outgoingCalls, call);
   GE_ASSERT (ectx,
-             (get_time () + 1 * cronMINUTES > call->expirationTime) ||
-             (call->expirationTime - get_time () < 1 * cronHOURS));
-  cron_add_job (coreAPI->cron, &retryRPCJob, 0, 0, call);
-  MUTEX_UNLOCK (rpcLock);
-  SEMAPHORE_DOWN (cls.sem, YES);
-  SEMAPHORE_DESTROY (cls.sem);
+             (GNUNET_get_time () + 1 * GNUNET_CRON_MINUTES >
+              call->expirationTime)
+             || (call->expirationTime - GNUNET_get_time () <
+                 1 * GNUNET_CRON_HOURS));
+  GNUNET_cron_add_job (coreAPI->cron, &retryRPCJob, 0, 0, call);
+  GNUNET_mutex_unlock (rpcLock);
+  GNUNET_semaphore_down (cls.sem, GNUNET_YES);
+  GNUNET_semaphore_destroy (cls.sem);
   RPC_STATUS (name, "completed synchronously", call);
   return cls.ec;
 }
 
 typedef struct RPC_Record
 {
-  PeerIdentity peer;
+  GNUNET_PeerIdentity peer;
   CallInstance *call;
   RPC_Complete callback;
   void *closure;
@@ -1293,33 +1309,33 @@
  *  be explicitly stopped to free resources!)
  */
 static RPC_Record *
-RPC_start (const PeerIdentity * receiver,
+RPC_start (const GNUNET_PeerIdentity * receiver,
            const char *name,
            RPC_Param * request_param,
            unsigned int importance,
-           cron_t timeout, RPC_Complete callback, void *closure)
+           GNUNET_CronTime timeout, RPC_Complete callback, void *closure)
 {
   RPC_Record *ret;
 
-  if (timeout > 1 * cronHOURS)
+  if (timeout > 1 * GNUNET_CRON_HOURS)
     {
       GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
               _("`%s' called with timeout above 1 hour (bug?)\n"),
               __FUNCTION__);
-      timeout = 1 * cronHOURS;
+      timeout = 1 * GNUNET_CRON_HOURS;
     }
-  ret = MALLOC (sizeof (RPC_Record));
+  ret = GNUNET_malloc (sizeof (RPC_Record));
   RPC_STATUS (name, "started asynchronously", ret);
   ret->peer = *receiver;
   ret->callback = callback;
   ret->closure = closure;
   ret->errorCode = RPC_ERROR_TIMEOUT;
-  MUTEX_LOCK (rpcLock);
-  ret->call = MALLOC (sizeof (CallInstance));
+  GNUNET_mutex_lock (rpcLock);
+  ret->call = GNUNET_malloc (sizeof (CallInstance));
   ret->call->lastAttempt = 0;
   ret->call->attempts = 0;
   ret->call->repetitionFrequency = getExpectedResponseTime (receiver);
-  ret->call->expirationTime = get_time () + timeout;
+  ret->call->expirationTime = GNUNET_get_time () + timeout;
   ret->call->receiver = *receiver;
   ret->call->sequenceNumber = rpcIdentifier++;
   ret->call->msg = buildMessage (RPC_ERROR_OK,
@@ -1328,11 +1344,14 @@
                                  importance, request_param);
   ret->call->finishedCallback = (RPCFinishedCallback) & RPC_async_callback;
   ret->call->rpcCallbackArgs = ret;
-  vectorInsertLast (outgoingCalls, ret->call);
-  GE_ASSERT (ectx, (get_time () + 1 * cronMINUTES > ret->call->expirationTime)
-             || (ret->call->expirationTime - get_time () < 1 * cronHOURS));
-  cron_add_job (coreAPI->cron, &retryRPCJob, 0, 0, ret->call);
-  MUTEX_UNLOCK (rpcLock);
+  GNUNET_vector_insert_last (outgoingCalls, ret->call);
+  GE_ASSERT (ectx,
+             (GNUNET_get_time () + 1 * GNUNET_CRON_MINUTES >
+              ret->call->expirationTime)
+             || (ret->call->expirationTime - GNUNET_get_time () <
+                 1 * GNUNET_CRON_HOURS));
+  GNUNET_cron_add_job (coreAPI->cron, &retryRPCJob, 0, 0, ret->call);
+  GNUNET_mutex_unlock (rpcLock);
   return ret;
 }
 
@@ -1349,18 +1368,18 @@
   int ret;
 
   RPC_STATUS ("", "stopped", record);
-  cron_suspend (coreAPI->cron, YES);
-  cron_del_job (coreAPI->cron, &retryRPCJob, 0, record->call);
-  cron_resume_jobs (coreAPI->cron, YES);
-  MUTEX_LOCK (rpcLock);
-  if (NULL != vectorRemoveObject (outgoingCalls, record->call))
+  GNUNET_cron_suspend_jobs (coreAPI->cron, GNUNET_YES);
+  GNUNET_cron_del_job (coreAPI->cron, &retryRPCJob, 0, record->call);
+  GNUNET_cron_resume_jobs (coreAPI->cron, GNUNET_YES);
+  GNUNET_mutex_lock (rpcLock);
+  if (NULL != GNUNET_vector_delete (outgoingCalls, record->call))
     {
-      FREE (record->call->msg);
-      FREE (record->call);
+      GNUNET_free (record->call->msg);
+      GNUNET_free (record->call);
     }
-  MUTEX_UNLOCK (rpcLock);
+  GNUNET_mutex_unlock (rpcLock);
   ret = record->errorCode;
-  FREE (record);
+  GNUNET_free (record);
 
   return ret;
 }
@@ -1375,55 +1394,56 @@
 {
   CallInstance *call;
 
-  cron_del_job (coreAPI->cron,
-                &agePeerStats, PEER_TRACKING_TIME_INTERVAL, NULL);
+  GNUNET_cron_del_job (coreAPI->cron,
+                       &agePeerStats, PEER_TRACKING_TIME_INTERVAL, NULL);
   coreAPI->unregisterHandler (P2P_PROTO_rpc_REQ, &handleRPCMessageReq);
   coreAPI->unregisterHandler (P2P_PROTO_rpc_RES, &handleRPCMessageRes);
   coreAPI->unregisterHandler (P2P_PROTO_rpc_ACK, &handleRPCMessageAck);
   if (NULL != peerInformation)
     {
-      while (vectorSize (peerInformation) > 0)
-        FREE (vectorRemoveLast (peerInformation));
-      vectorFree (peerInformation);
+      while (GNUNET_vector_get_size (peerInformation) > 0)
+        GNUNET_free (GNUNET_vector_delete_last (peerInformation));
+      GNUNET_vector_destroy (peerInformation);
       peerInformation = NULL;
     }
   if (NULL != incomingCalls)
     {
-      while (vectorSize (incomingCalls) > 0)
+      while (GNUNET_vector_get_size (incomingCalls) > 0)
         {
-          call = (CallInstance *) vectorRemoveLast (incomingCalls);
-          cron_del_job (coreAPI->cron, &retryRPCJob, 0, call);
-          FREE (call->msg);
-          FREE (call);
+          call = (CallInstance *) GNUNET_vector_delete_last (incomingCalls);
+          GNUNET_cron_del_job (coreAPI->cron, &retryRPCJob, 0, call);
+          GNUNET_free (call->msg);
+          GNUNET_free (call);
         }
-      vectorFree (incomingCalls);
+      GNUNET_vector_destroy (incomingCalls);
       incomingCalls = NULL;
     }
   if (NULL != outgoingCalls)
     {
-      while (vectorSize (outgoingCalls) > 0)
+      while (GNUNET_vector_get_size (outgoingCalls) > 0)
         {
-          call = (CallInstance *) vectorRemoveLast (outgoingCalls);
-          cron_del_job (coreAPI->cron, &retryRPCJob, 0, call);
-          FREE (call->msg);
-          FREE (call);
+          call = (CallInstance *) GNUNET_vector_delete_last (outgoingCalls);
+          GNUNET_cron_del_job (coreAPI->cron, &retryRPCJob, 0, call);
+          GNUNET_free (call->msg);
+          GNUNET_free (call);
         }
-      vectorFree (outgoingCalls);
+      GNUNET_vector_destroy (outgoingCalls);
       outgoingCalls = NULL;
     }
   if (NULL != list_of_callbacks)
     {
-      while (vectorSize (list_of_callbacks) > 0)
+      while (GNUNET_vector_get_size (list_of_callbacks) > 0)
         {
           RegisteredRPC *rpc;
-          rpc = (RegisteredRPC *) vectorRemoveLast (list_of_callbacks);
+          rpc =
+            (RegisteredRPC *) GNUNET_vector_delete_last (list_of_callbacks);
           GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
-                  _("RPC not unregistered: %s:%p\n"),
-                  rpc->name, rpc->callback);
-          FREE (rpc->name);
-          FREE (rpc);
+                  _("RPC not unregistered: %s:%p\n"), rpc->name,
+                  rpc->callback);
+          GNUNET_free (rpc->name);
+          GNUNET_free (rpc);
         }
-      vectorFree (list_of_callbacks);
+      GNUNET_vector_destroy (list_of_callbacks);
       list_of_callbacks = NULL;
     }
   coreAPI = NULL;
@@ -1442,24 +1462,24 @@
   ectx = capi->ectx;
   rpcLock = capi->getConnectionModuleLock ();
   coreAPI = capi;
-  peerInformation = vectorNew (16);
-  incomingCalls = vectorNew (16);
-  outgoingCalls = vectorNew (16);
-  list_of_callbacks = vectorNew (16);
+  peerInformation = GNUNET_vector_create (16);
+  incomingCalls = GNUNET_vector_create (16);
+  outgoingCalls = GNUNET_vector_create (16);
+  list_of_callbacks = GNUNET_vector_create (16);
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           _("`%s' registering handlers %d %d %d\n"),
           "rpc", P2P_PROTO_rpc_REQ, P2P_PROTO_rpc_RES, P2P_PROTO_rpc_ACK);
-  rvalue = OK;
+  rvalue = GNUNET_OK;
   if (capi->registerHandler (P2P_PROTO_rpc_REQ,
-                             &handleRPCMessageReq) == SYSERR)
-    rvalue = SYSERR;
+                             &handleRPCMessageReq) == GNUNET_SYSERR)
+    rvalue = GNUNET_SYSERR;
   if (capi->registerHandler (P2P_PROTO_rpc_RES,
-                             &handleRPCMessageRes) == SYSERR)
-    rvalue = SYSERR;
+                             &handleRPCMessageRes) == GNUNET_SYSERR)
+    rvalue = GNUNET_SYSERR;
   if (capi->registerHandler (P2P_PROTO_rpc_ACK,
-                             &handleRPCMessageAck) == SYSERR)
-    rvalue = SYSERR;
-  if (rvalue == SYSERR)
+                             &handleRPCMessageAck) == GNUNET_SYSERR)
+    rvalue = GNUNET_SYSERR;
+  if (rvalue == GNUNET_SYSERR)
     {
       release_module_rpc ();
       GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
@@ -1475,10 +1495,10 @@
       rpcAPI.RPC_unregister_async = &RPC_unregister_async;
       rpcAPI.RPC_start = &RPC_start;
       rpcAPI.RPC_stop = &RPC_stop;
-      cron_add_job (coreAPI->cron,
-                    &agePeerStats,
-                    PEER_TRACKING_TIME_INTERVAL,
-                    PEER_TRACKING_TIME_INTERVAL, NULL);
+      GNUNET_cron_add_job (coreAPI->cron,
+                           &agePeerStats,
+                           PEER_TRACKING_TIME_INTERVAL,
+                           PEER_TRACKING_TIME_INTERVAL, NULL);
       return &rpcAPI;
     }
 }
@@ -1486,17 +1506,17 @@
 #if PROVIDE_RPC_TEST
 
 static void
-testCallback (const PeerIdentity * sender,
+testCallback (const GNUNET_PeerIdentity * sender,
               RPC_Param * arguments, RPC_Param * results)
 {
   unsigned int dl;
   char *data;
 
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, "RPC callback invoked!\n");
-  if ((OK == RPC_paramValueByName (arguments,
-                                   "command",
-                                   &dl,
-                                   (void **) &data)) &&
+  if ((GNUNET_OK == RPC_paramValueByName (arguments,
+                                          "command",
+                                          &dl,
+                                          (void **) &data)) &&
       (strncmp ("Hello", data, dl) == 0))
     {
       GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
@@ -1508,16 +1528,17 @@
 }
 
 static void
-async_RPC_Complete_callback (RPC_Param * results, struct SEMAPHORE *sign)
+async_RPC_Complete_callback (RPC_Param * results,
+                             struct GNUNET_Semaphore *GNUNET_RSA_sign)
 {
   unsigned int dl;
   char *reply;
 
-  SEMAPHORE_DOWN (sign, YES);
-  if ((OK != RPC_paramValueByName (results,
-                                   "response",
-                                   &dl,
-                                   (void **) &reply)) ||
+  GNUNET_semaphore_down (GNUNET_RSA_sign, GNUNET_YES);
+  if ((GNUNET_OK != RPC_paramValueByName (results,
+                                          "response",
+                                          &dl,
+                                          (void **) &reply)) ||
       (strncmp ("Hello RPC World", reply, dl) != 0))
     {
       GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
@@ -1539,71 +1560,72 @@
   char *reply;
   int code;
   RPC_Record *record;
-  struct SEMAPHORE *sign;
+  struct GNUNET_Semaphore *GNUNET_RSA_sign;
 
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, "RPC testcase starting\n");
   rpcAPI = capi->requestService ("rpc");
   if (rpcAPI == NULL)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  ret = OK;
+  ret = GNUNET_OK;
 
-  if (OK != rpcAPI->RPC_register ("testFunction", &testCallback))
+  if (GNUNET_OK != rpcAPI->RPC_register ("testFunction", &testCallback))
     {
       GE_BREAK (ectx, 0);
-      ret = SYSERR;
+      ret = GNUNET_SYSERR;
     }
 
   args = RPC_paramNew ();
   RPC_paramAdd (args, "command", strlen ("Hello") + 1, "Hello");
-  sign = SEMAPHORE_CREATE (0);
+  GNUNET_RSA_sign = GNUNET_semaphore_create (0);
   record = rpcAPI->RPC_start (coreAPI->myIdentity,
                               "testFunction",
                               args,
                               0,
-                              5 * cronSECONDS,
+                              5 * GNUNET_CRON_SECONDS,
                               (RPC_Complete) & async_RPC_Complete_callback,
-                              sign);
-  SEMAPHORE_UP (sign);          /* allow callback now - forces async! */
+                              GNUNET_RSA_sign);
+  GNUNET_semaphore_up (GNUNET_RSA_sign);        /* allow callback now - forces 
async! */
   rets = RPC_paramNew ();
   code = rpcAPI->RPC_execute (coreAPI->myIdentity,
-                              "testFunction", args, rets, 0, 5 * cronSECONDS);
+                              "testFunction", args, rets, 0,
+                              5 * GNUNET_CRON_SECONDS);
   if (code != RPC_ERROR_OK)
     {
       GE_BREAK (ectx, 0);
-      ret = SYSERR;
+      ret = GNUNET_SYSERR;
     }
   RPC_paramFree (args);
-  if ((OK != RPC_paramValueByName (rets,
-                                   "response",
-                                   &dl,
-                                   (void **) &reply)) ||
+  if ((GNUNET_OK != RPC_paramValueByName (rets,
+                                          "response",
+                                          &dl,
+                                          (void **) &reply)) ||
       (strncmp ("Hello RPC World", reply, dl) != 0))
     {
       GE_BREAK (ectx, 0);
-      ret = SYSERR;
+      ret = GNUNET_SYSERR;
     }
   RPC_paramFree (rets);
-  PTHREAD_SLEEP (1 * cronSECONDS);
+  GNUNET_thread_sleep (1 * GNUNET_CRON_SECONDS);
   if (RPC_ERROR_OK != rpcAPI->RPC_stop (record))
     GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
             _("async RPC reply not received.\n"));
 
-  if (OK != rpcAPI->RPC_unregister ("testFunction", &testCallback))
+  if (GNUNET_OK != rpcAPI->RPC_unregister ("testFunction", &testCallback))
     {
       GE_BREAK (ectx, 0);
-      ret = SYSERR;
+      ret = GNUNET_SYSERR;
     }
-  if (OK != capi->releaseService (rpcAPI))
+  if (GNUNET_OK != capi->releaseService (rpcAPI))
     {
       GE_BREAK (ectx, 0);
-      ret = SYSERR;
+      ret = GNUNET_SYSERR;
     }
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "RPC testcase completed with status %s\n",
-          ret == OK ? "SUCCESS" : "FAILURE");
+          ret == GNUNET_OK ? "SUCCESS" : "FAILURE");
   return ret;
 }
 
@@ -1614,7 +1636,7 @@
 int
 done_module_rpc ()
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 #endif

Modified: GNUnet/src/applications/session/Makefile.am
===================================================================
--- GNUnet/src/applications/session/Makefile.am 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/session/Makefile.am 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -8,8 +8,7 @@
 libgnunetmodule_session_la_SOURCES = \
   connect.c 
 libgnunetmodule_session_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la 
+ $(top_builddir)/src/util/libgnunetutil.la 
 libgnunetmodule_session_la_LDFLAGS = \
   -export-dynamic -avoid-version -module
 
@@ -29,8 +28,6 @@
 sessiontest_tcp_LDADD = \
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
   $(top_builddir)/src/applications/testing/libgnunettesting_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 
 
 sessiontest_udp_SOURCES = \
@@ -38,8 +35,6 @@
 sessiontest_udp_LDADD = \
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
   $(top_builddir)/src/applications/testing/libgnunettesting_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 
 
 sessiontest_http_SOURCES = \
@@ -47,8 +42,6 @@
 sessiontest_http_LDADD = \
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
   $(top_builddir)/src/applications/testing/libgnunettesting_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 
 
 sessiontest2_SOURCES = \
@@ -56,8 +49,6 @@
 sessiontest2_LDADD = \
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
   $(top_builddir)/src/applications/identity/libgnunetidentity_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 
 
 
@@ -66,8 +57,6 @@
 sessiontest2_http_LDADD = \
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
   $(top_builddir)/src/applications/identity/libgnunetidentity_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/session/connect.c
===================================================================
--- GNUnet/src/applications/session/connect.c   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/session/connect.c   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -37,7 +37,7 @@
 
 #define hello_HELPER_TABLE_START_SIZE 64
 
-#define DEBUG_SESSION NO
+#define DEBUG_SESSION GNUNET_NO
 
 #define EXTRA_CHECKS ALLOW_EXTRA_CHECKS
 
@@ -72,24 +72,24 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
   /**
    * time when this key was created  (network byte order)
    * Must be the first field after the header since
    * the signature starts at this offset.
    */
-  TIME_T creationTime;
+  GNUNET_Int32Time creationTime;
 
   /**
    * The encrypted session key.  May ALSO contain
    * encrypted PINGs and PONGs.
    */
-  RSAEncryptedData key;
+  GNUNET_RSA_EncryptedData key;
 
   /**
-   * Signature of the stuff above.
+   * GNUNET_RSA_Signature of the stuff above.
    */
-  Signature signature;
+  GNUNET_RSA_Signature signature;
 
 } P2P_setkey_MESSAGE;
 
@@ -98,29 +98,29 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
   /**
    * time when this key was created  (network byte order)
    * Must be the first field after the header since
    * the signature starts at this offset.
    */
-  TIME_T creationTime;
+  GNUNET_Int32Time creationTime;
 
   /**
    * The encrypted session key.  May ALSO contain
    * encrypted PINGs and PONGs.
    */
-  RSAEncryptedData key;
+  GNUNET_RSA_EncryptedData key;
 
   /**
    * Who is the intended recipient?
    */
-  PeerIdentity target;
+  GNUNET_PeerIdentity target;
 
   /**
-   * Signature of the stuff above.
+   * GNUNET_RSA_Signature of the stuff above.
    */
-  Signature signature;
+  GNUNET_RSA_Signature signature;
 
 } P2P_new_setkey_MESSAGE;
 
@@ -130,16 +130,16 @@
  * Not thread-safe, only use for debugging!
  */
 static const char *
-printSKEY (const SESSIONKEY * sk)
+printSKEY (const GNUNET_AES_SessionKey * sk)
 {
   static char r[512];
   static char t[12];
   int i;
 
   strcpy (r, "");
-  for (i = 0; i < SESSIONKEY_LEN; i++)
+  for (i = 0; i < GNUNET_SESSIONKEY_LEN; i++)
     {
-      SNPRINTF (t, 12, "%02x", sk->key[i]);
+      GNUNET_snprintf (t, 12, "%02x", sk->key[i]);
       strcat (r, t);
     }
   return r;
@@ -147,23 +147,23 @@
 #endif
 
 /**
- * We received a sign of life from this host.
+ * We received a GNUNET_RSA_sign of life from this host.
  *
- * @param hostId the peer that gave a sign of live
+ * @param hostId the peer that gave a GNUNET_RSA_sign of live
  */
 static void
 notifyPONG (void *arg)
 {
-  PeerIdentity *hostId = arg;
+  GNUNET_PeerIdentity *hostId = arg;
 #if DEBUG_SESSION
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   GE_ASSERT (ectx, hostId != NULL);
 #if DEBUG_SESSION
   IF_GELOG (ectx,
             GE_DEBUG | GE_USER | GE_REQUEST,
-            hash2enc (&hostId->hashPubKey, &enc));
+            GNUNET_hash_to_enc (&hostId->hashPubKey, &enc));
   GE_LOG (ectx,
           GE_DEBUG | GE_USER | GE_REQUEST,
           "Received `%s' from `%s', marking session as up.\n", "PONG", &enc);
@@ -172,7 +172,7 @@
   if (stats != NULL)
     stats->change (stat_sessionEstablished, 1);
   coreAPI->confirmSessionUp (hostId);
-  FREE (hostId);
+  GNUNET_free (hostId);
 }
 
 
@@ -183,21 +183,22 @@
  *
  * @param hostId the sender of the key
  * @param sks the session key message
- * @return SYSERR if invalid, OK if valid, NO if
+ * @return GNUNET_SYSERR if invalid, GNUNET_OK if valid, GNUNET_NO if
  *  connections are disallowed
  */
 static int
-verifySKS (const PeerIdentity * hostId,
-           const P2P_setkey_MESSAGE * sks, const Signature * signature)
+verifySKS (const GNUNET_PeerIdentity * hostId,
+           const P2P_setkey_MESSAGE * sks,
+           const GNUNET_RSA_Signature * signature)
 {
   char *limited;
-  EncName enc;
+  GNUNET_EncName enc;
   unsigned int rsize;
 
   if ((sks == NULL) || (hostId == NULL))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   /* check if we are allowed to accept connections
      from that peer */
@@ -206,7 +207,7 @@
                                      "GNUNETD", "LIMIT-ALLOW", "", &limited);
   if (strlen (limited) > 0)
     {
-      hash2enc (&hostId->hashPubKey, &enc);
+      GNUNET_hash_to_enc (&hostId->hashPubKey, &enc);
       if (NULL == strstr (limited, (char *) &enc))
         {
 #if DEBUG_SESSION
@@ -215,17 +216,17 @@
                   "Connection from peer `%s' was rejected (not allowed).\n",
                   &enc);
 #endif
-          FREE (limited);
-          return NO;
+          GNUNET_free (limited);
+          return GNUNET_NO;
         }
     }
-  FREE (limited);
+  GNUNET_free (limited);
   limited = NULL;
   GC_get_configuration_value_string (coreAPI->cfg,
                                      "GNUNETD", "LIMIT-DENY", "", &limited);
   if (strlen (limited) > 0)
     {
-      hash2enc (&hostId->hashPubKey, &enc);
+      GNUNET_hash_to_enc (&hostId->hashPubKey, &enc);
       if (NULL != strstr (limited, (char *) &enc))
         {
 #if DEBUG_SESSION
@@ -234,53 +235,55 @@
                   "Connection from peer `%s' was rejected (explicitly 
denied).\n",
                   &enc);
 #endif
-          FREE (limited);
-          return NO;
+          GNUNET_free (limited);
+          return GNUNET_NO;
         }
     }
-  FREE (limited);
+  GNUNET_free (limited);
 
   rsize = ntohs (sks->header.size);
   while (rsize > sizeof (P2P_new_setkey_MESSAGE))
     rsize -= pingpong->ping_size;
   if (rsize < sizeof (P2P_setkey_MESSAGE))
     {
-      EncName enc;
+      GNUNET_EncName enc;
 
       GE_BREAK_OP (ectx, 0);
       IF_GELOG (ectx,
                 GE_INFO | GE_USER | GE_REQUEST,
-                hash2enc (&hostId->hashPubKey, &enc));
+                GNUNET_hash_to_enc (&hostId->hashPubKey, &enc));
       GE_LOG (ectx,
               GE_INFO | GE_USER | GE_REQUEST,
               _("Session key from peer `%s' could not be verified.\n"), &enc);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  if (OK != identity->verifyPeerSignature (hostId,
-                                           sks,
-                                           rsize - sizeof (Signature),
-                                           signature))
+  if (GNUNET_OK != identity->verifyPeerSignature (hostId,
+                                                  sks,
+                                                  rsize -
+                                                  sizeof
+                                                  (GNUNET_RSA_Signature),
+                                                  signature))
     {
 #if DEBUG_SESSION
-      EncName enc;
+      GNUNET_EncName enc;
 
       IF_GELOG (ectx,
                 GE_INFO | GE_USER | GE_REQUEST,
-                hash2enc (&hostId->hashPubKey, &enc));
+                GNUNET_hash_to_enc (&hostId->hashPubKey, &enc));
       GE_LOG (ectx,
               GE_INFO | GE_USER | GE_REQUEST,
               _("Session key from peer `%s' could not be verified.\n"), &enc);
 #endif
-      return SYSERR;            /*reject! */
+      return GNUNET_SYSERR;     /*reject! */
     }
-  return OK;                    /* ok */
+  return GNUNET_OK;             /* ok */
 }
 
 /**
  * Force creation of a new Session key for the given host.
  *
  * @param hostId the identity of the other host
- * @param sk the SESSIONKEY to use
+ * @param sk the GNUNET_AES_SessionKey to use
  * @param created the timestamp to use
  * @param ping optional PING to include (otherwise NULL)
  * @param pong optional PONG to include (otherwise NULL)
@@ -289,25 +292,26 @@
  * @return message on success, NULL on failure
  */
 static P2P_new_setkey_MESSAGE *
-makeSessionKeySigned (const PeerIdentity * hostId,
-                      const SESSIONKEY * sk,
-                      TIME_T created,
-                      const MESSAGE_HEADER * ping,
-                      const MESSAGE_HEADER * pong)
+makeSessionKeySigned (const GNUNET_PeerIdentity * hostId,
+                      const GNUNET_AES_SessionKey * sk,
+                      GNUNET_Int32Time created,
+                      const GNUNET_MessageHeader * ping,
+                      const GNUNET_MessageHeader * pong)
 {
-  P2P_hello_MESSAGE *foreignHello;
+  GNUNET_MessageHello *foreignHello;
   int size;
   P2P_new_setkey_MESSAGE *msg;
   char *pt;
-  EncName enc;
-  PeerIdentity hc;
+  GNUNET_EncName enc;
+  GNUNET_PeerIdentity hc;
 
   GE_ASSERT (ectx, sk != NULL);
-  foreignHello = identity->identity2Hello (hostId, ANY_PROTOCOL_NUMBER, YES);
+  foreignHello =
+    identity->identity2Hello (hostId, ANY_PROTOCOL_NUMBER, GNUNET_YES);
   /* create and encrypt sessionkey */
   if (NULL == foreignHello)
     {
-      hash2enc (&hostId->hashPubKey, &enc);
+      GNUNET_hash_to_enc (&hostId->hashPubKey, &enc);
       GE_LOG (ectx,
               GE_INFO | GE_USER | GE_REQUEST,
               _("Cannot encrypt sessionkey, peer `%s' not known!\n"), &enc);
@@ -316,17 +320,19 @@
   identity->getPeerIdentity (&foreignHello->publicKey, &hc);
   if ((0 != memcmp (&hc,
                     hostId,
-                    sizeof (PeerIdentity))) ||
+                    sizeof (GNUNET_PeerIdentity))) ||
       (0 != memcmp (&hc,
-                    &foreignHello->senderIdentity, sizeof (PeerIdentity))))
+                    &foreignHello->senderIdentity,
+                    sizeof (GNUNET_PeerIdentity))))
     {
       GE_BREAK_OP (NULL,
                    0 == memcmp (&hc,
                                 &foreignHello->senderIdentity,
-                                sizeof (PeerIdentity)));
-      GE_BREAK_OP (NULL, 0 == memcmp (&hc, hostId, sizeof (PeerIdentity)));
+                                sizeof (GNUNET_PeerIdentity)));
+      GE_BREAK_OP (NULL,
+                   0 == memcmp (&hc, hostId, sizeof (GNUNET_PeerIdentity)));
       GE_BREAK_OP (NULL, 0);
-      FREE (foreignHello);
+      GNUNET_free (foreignHello);
       return NULL;
     }
 
@@ -336,34 +342,36 @@
     size += ntohs (ping->size);
   if (pong != NULL)
     size += ntohs (pong->size);
-  msg = MALLOC (size);
+  msg = GNUNET_malloc (size);
   msg->target = *hostId;
-  if (SYSERR == encryptPrivateKey (sk,
-                                   sizeof (SESSIONKEY),
-                                   &foreignHello->publicKey, &msg->key))
+  if (GNUNET_SYSERR == GNUNET_RSA_encrypt (sk,
+                                           sizeof (GNUNET_AES_SessionKey),
+                                           &foreignHello->publicKey,
+                                           &msg->key))
     {
       GE_BREAK_OP (ectx, 0);
-      FREE (foreignHello);
-      FREE (msg);
+      GNUNET_free (foreignHello);
+      GNUNET_free (msg);
       return NULL;              /* encrypt failed */
     }
-  FREE (foreignHello);
+  GNUNET_free (foreignHello);
 
   /* complete header */
   msg->header.size = htons (size);
   msg->header.type = htons (P2P_PROTO_setkey);
   msg->creationTime = htonl (created);
   GE_ASSERT (ectx,
-             SYSERR !=
+             GNUNET_SYSERR !=
              identity->signData (msg,
                                  sizeof (P2P_new_setkey_MESSAGE)
-                                 - sizeof (Signature), &msg->signature));
+                                 - sizeof (GNUNET_RSA_Signature),
+                                 &msg->signature));
 #if EXTRA_CHECKS
   /* verify signature/SKS */
   GE_ASSERT (ectx,
-             SYSERR != verifySKS (coreAPI->myIdentity,
-                                  (const P2P_setkey_MESSAGE *) msg,
-                                  &msg->signature));
+             GNUNET_SYSERR != verifySKS (coreAPI->myIdentity,
+                                         (const P2P_setkey_MESSAGE *) msg,
+                                         &msg->signature));
 #endif
 
   size = 0;
@@ -373,7 +381,7 @@
     size += ntohs (pong->size);
   if (size > 0)
     {
-      pt = MALLOC (size);
+      pt = GNUNET_malloc (size);
       size = 0;
       if (ping != NULL)
         {
@@ -392,12 +400,14 @@
               size, printSKEY (sk), *(int *) &msg->signature);
 #endif
       GE_ASSERT (ectx,
-                 -1 != encryptBlock (pt,
-                                     size,
-                                     sk,
-                                     (const INITVECTOR *) &msg->signature,
-                                     (char *) &msg[1]));
-      FREE (pt);
+                 -1 != GNUNET_AES_encrypt (pt,
+                                           size,
+                                           sk,
+                                           (const
+                                            GNUNET_AES_InitializationVector *)
+                                           &msg->signature,
+                                           (char *) &msg[1]));
+      GNUNET_free (pt);
     }
   return msg;
 }
@@ -412,32 +422,32 @@
  * @param pong pong to include (maybe NULL)
  */
 static int
-exchangeKey (const PeerIdentity * receiver,
-             TSession * tsession, MESSAGE_HEADER * pong)
+exchangeKey (const GNUNET_PeerIdentity * receiver,
+             TSession * tsession, GNUNET_MessageHeader * pong)
 {
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
   P2P_new_setkey_MESSAGE *skey;
-  SESSIONKEY sk;
-  TIME_T age;
-  MESSAGE_HEADER *ping;
-  PeerIdentity *sndr;
-  EncName enc;
+  GNUNET_AES_SessionKey sk;
+  GNUNET_Int32Time age;
+  GNUNET_MessageHeader *ping;
+  GNUNET_PeerIdentity *sndr;
+  GNUNET_EncName enc;
 
   GE_ASSERT (ectx, receiver != NULL);
   if ((tsession != NULL) &&
-      (0 != memcmp (&tsession->peer, receiver, sizeof (PeerIdentity))))
+      (0 != memcmp (&tsession->peer, receiver, sizeof (GNUNET_PeerIdentity))))
     {
       GE_BREAK (ectx, 0);
       tsession = NULL;
     }
   if ((topology != NULL) &&
-      (topology->allowConnectionFrom (receiver) == SYSERR))
-    return SYSERR;
-  hash2enc (&receiver->hashPubKey, &enc);
+      (topology->allowConnectionFrom (receiver) == GNUNET_SYSERR))
+    return GNUNET_SYSERR;
+  GNUNET_hash_to_enc (&receiver->hashPubKey, &enc);
   /* then try to connect on the transport level */
   if ((tsession == NULL)
-      || (transport->associate (tsession, __FILE__) == SYSERR))
-    tsession = transport->connectFreely (receiver, YES, __FILE__);
+      || (transport->associate (tsession, __FILE__) == GNUNET_SYSERR))
+    tsession = transport->connectFreely (receiver, GNUNET_YES, __FILE__);
   if (tsession == NULL)
     {
 #if DEBUG_SESSION
@@ -445,25 +455,26 @@
               GE_DEBUG | GE_USER | GE_REQUEST,
               "Key exchange with `%s' failed: could not connect.\n", &enc);
 #endif
-      return SYSERR;            /* failed to connect */
+      return GNUNET_SYSERR;     /* failed to connect */
     }
 
   /* create our ping */
-  sndr = MALLOC (sizeof (PeerIdentity));
+  sndr = GNUNET_malloc (sizeof (GNUNET_PeerIdentity));
   *sndr = *receiver;
-  ping = pingpong->pingUser (receiver, &notifyPONG, sndr, NO, rand ());
+  ping = pingpong->pingUser (receiver, &notifyPONG, sndr, GNUNET_NO, rand ());
   if (ping == NULL)
     {
-      FREE (sndr);
+      GNUNET_free (sndr);
       transport->disconnect (tsession, __FILE__);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
   /* get or create our session key */
-  if (OK != coreAPI->getCurrentSessionKey (receiver, &sk, &age, YES))
+  if (GNUNET_OK !=
+      coreAPI->getCurrentSessionKey (receiver, &sk, &age, GNUNET_YES))
     {
-      age = TIME (NULL);
-      makeSessionkey (&sk);
+      age = GNUNET_get_time_int32 (NULL);
+      GNUNET_AES_create_session_key (&sk);
 #if DEBUG_SESSION
       GE_LOG (ectx,
               GE_DEBUG | GE_USER | GE_REQUEST,
@@ -474,11 +485,11 @@
 
   /* build SKEY message */
   skey = makeSessionKeySigned (receiver, &sk, age, ping, pong);
-  FREE (ping);
+  GNUNET_free (ping);
   if (skey == NULL)
     {
       transport->disconnect (tsession, __FILE__);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
   /* create hello */
@@ -507,14 +518,14 @@
     {
       coreAPI->sendPlaintext (tsession,
                               (const char *) hello,
-                              P2P_hello_MESSAGE_size (hello));
-      FREE (hello);
+                              GNUNET_sizeof_hello (hello));
+      GNUNET_free (hello);
       hello = NULL;
       coreAPI->sendPlaintext (tsession,
                               (const char *) skey, ntohs (skey->header.size));
     }
-  FREE (skey);
-  if (0 != memcmp (receiver, &tsession->peer, sizeof (PeerIdentity)))
+  GNUNET_free (skey);
+  if (0 != memcmp (receiver, &tsession->peer, sizeof (GNUNET_PeerIdentity)))
     {
       GE_BREAK (NULL, 0);
     }
@@ -523,8 +534,8 @@
       coreAPI->offerTSessionFor (receiver, tsession);
     }
   transport->disconnect (tsession, __FILE__);
-  coreAPI->assignSessionKey (&sk, receiver, age, YES);
-  return OK;
+  coreAPI->assignSessionKey (&sk, receiver, age, GNUNET_YES);
+  return GNUNET_OK;
 }
 
 /**
@@ -537,46 +548,47 @@
  * @param sender the identity of the sender host
  * @param tsession the transport session handle
  * @param msg message with the session key
- * @return SYSERR or OK
+ * @return GNUNET_SYSERR or GNUNET_OK
  */
 static int
-acceptSessionKey (const PeerIdentity * sender,
-                  const MESSAGE_HEADER * msg, TSession * tsession)
+acceptSessionKey (const GNUNET_PeerIdentity * sender,
+                  const GNUNET_MessageHeader * msg, TSession * tsession)
 {
-  SESSIONKEY key;
-  MESSAGE_HEADER *ping;
-  MESSAGE_HEADER *pong;
+  GNUNET_AES_SessionKey key;
+  GNUNET_MessageHeader *ping;
+  GNUNET_MessageHeader *pong;
   const P2P_setkey_MESSAGE *sessionkeySigned;
   int size;
   int pos;
   char *plaintext;
-  EncName enc;
+  GNUNET_EncName enc;
   int ret;
-  const Signature *sig;
+  const GNUNET_RSA_Signature *sig;
   const P2P_new_setkey_MESSAGE *newMsg;
   const void *end;
 
   if (sender == NULL)
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  hash2enc (&sender->hashPubKey, &enc);
+  GNUNET_hash_to_enc (&sender->hashPubKey, &enc);
   if ((topology != NULL) &&
-      (topology->allowConnectionFrom (sender) == SYSERR))
+      (topology->allowConnectionFrom (sender) == GNUNET_SYSERR))
     {
 #if DEBUG_SESSION
       GE_LOG (ectx,
               GE_DEBUG | GE_USER | GE_REQUEST,
               "Topology rejected session key from peer `%s'.\n", &enc);
 #endif
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  if (equalsHashCode512 (&sender->hashPubKey,
-                         &coreAPI->myIdentity->hashPubKey))
+  if (0 == memcmp (&sender->hashPubKey,
+                   &coreAPI->myIdentity->hashPubKey,
+                   sizeof (GNUNET_HashCode)))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 #if DEBUG_SESSION
   GE_LOG (ectx,
@@ -591,16 +603,17 @@
               _
               ("Session key received from peer `%s' has invalid format 
(discarded).\n"),
               &enc);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  if ((OK != coreAPI->getCurrentSessionKey (sender,
-                                            NULL,
-                                            NULL,
-                                            YES)) &&
-      ((YES == identity->isBlacklisted (sender, NO)) ||
+  if ((GNUNET_OK != coreAPI->getCurrentSessionKey (sender,
+                                                   NULL,
+                                                   NULL,
+                                                   GNUNET_YES)) &&
+      ((GNUNET_YES == identity->isBlacklisted (sender, GNUNET_NO)) ||
        ((coreAPI->forAllConnectedNodes (NULL, NULL) >= 3) &&
-        (os_cpu_get_load (ectx, coreAPI->cfg) > IDLE_LOAD_THRESHOLD))))
-    return SYSERR;              /* other peer initiated but is
+        (GNUNET_cpu_get_load (ectx, coreAPI->cfg) >
+         GNUNET_IDLE_LOAD_THRESHOLD))))
+    return GNUNET_SYSERR;       /* other peer initiated but is
                                    listed as not allowed => discard */
 
   sessionkeySigned = (const P2P_setkey_MESSAGE *) msg;
@@ -613,17 +626,17 @@
     {
       newMsg = (const P2P_new_setkey_MESSAGE *) msg;
 
-      if (!equalsHashCode512 (&coreAPI->myIdentity->hashPubKey,
-                              &newMsg->target.hashPubKey))
+      if (0 != memcmp (&coreAPI->myIdentity->hashPubKey,
+                       &newMsg->target.hashPubKey, sizeof (GNUNET_HashCode)))
         {
-          EncName ta;
-          hash2enc (&newMsg->target.hashPubKey, &ta);
+          GNUNET_EncName ta;
+          GNUNET_hash_to_enc (&newMsg->target.hashPubKey, &ta);
           GE_LOG (ectx,
                   GE_WARNING | GE_DEVELOPER | GE_USER | GE_BULK,
                   _
                   ("Session key received from peer `%s' is for `%s' and not 
for me!\n"),
                   &enc, &ta);
-          return SYSERR;        /* not for us! */
+          return GNUNET_SYSERR; /* not for us! */
         }
       sig = &newMsg->signature;
     }
@@ -633,10 +646,10 @@
       newMsg = NULL;
     }
   ret = verifySKS (sender, sessionkeySigned, sig);
-  if (OK != ret)
+  if (GNUNET_OK != ret)
     {
 #if DEBUG_SESSION
-      if (ret == SYSERR)
+      if (ret == GNUNET_SYSERR)
         GE_LOG (ectx,
                 GE_INFO | GE_USER | GE_REQUEST | GE_DEVELOPER,
                 "Signature of session key from `%s' failed"
@@ -644,32 +657,32 @@
 #endif
       if (stats != NULL)
         stats->change (stat_skeyRejected, 1);
-      return SYSERR;            /* rejected */
+      return GNUNET_SYSERR;     /* rejected */
     }
-  memset (&key, 0, sizeof (SESSIONKEY));
+  memset (&key, 0, sizeof (GNUNET_AES_SessionKey));
   size = identity->decryptData (&sessionkeySigned->key,
-                                &key, sizeof (SESSIONKEY));
-  if (size != sizeof (SESSIONKEY))
+                                &key, sizeof (GNUNET_AES_SessionKey));
+  if (size != sizeof (GNUNET_AES_SessionKey))
     {
       GE_LOG (ectx,
               GE_WARNING | GE_DEVELOPER | GE_USER | GE_BULK,
               _("Invalid `%s' message received from peer `%s'.\n"),
               "setkey", &enc);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  if (key.crc32 != htonl (crc32N (&key, SESSIONKEY_LEN)))
+  if (key.crc32 != htonl (GNUNET_crc32_n (&key, GNUNET_SESSIONKEY_LEN)))
     {
 #if DEBUG_SESSION
       GE_LOG (ectx,
               GE_WARNING | GE_DEVELOPER | GE_USER | GE_BULK,
               _
               ("setkey `%s' from `%s' fails CRC check (have: %u, want %u).\n"),
-              printSKEY (&key), &enc, ntohl (key.crc32), crc32N (&key,
-                                                                 
SESSIONKEY_LEN));
+              printSKEY (&key), &enc, ntohl (key.crc32), GNUNET_crc32_n (&key,
+                                                                         
GNUNET_SESSIONKEY_LEN));
 #endif
       GE_BREAK_OP (ectx, 0);
       stats->change (stat_skeyRejected, 1);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
 #if DEBUG_SESSION
@@ -683,7 +696,8 @@
   /* notify core about session key */
   coreAPI->assignSessionKey (&key,
                              sender,
-                             ntohl (sessionkeySigned->creationTime), NO);
+                             ntohl (sessionkeySigned->creationTime),
+                             GNUNET_NO);
   pos = sizeof (P2P_setkey_MESSAGE);
   ping = NULL;
   pong = NULL;
@@ -703,7 +717,7 @@
           size -= sizeof (P2P_new_setkey_MESSAGE);
           end = &newMsg[1];
         }
-      plaintext = MALLOC (size);
+      plaintext = GNUNET_malloc (size);
 #if DEBUG_SESSION
       GE_LOG (ectx,
               GE_DEBUG | GE_USER | GE_REQUEST,
@@ -711,17 +725,19 @@
               size, &enc, printSKEY (&key), *(int *) sig);
 #endif
       GE_ASSERT (ectx,
-                 -1 != decryptBlock (&key,
-                                     end,
-                                     size,
-                                     (const INITVECTOR *) sig, plaintext));
+                 -1 != GNUNET_AES_decrypt (&key,
+                                           end,
+                                           size,
+                                           (const
+                                            GNUNET_AES_InitializationVector *)
+                                           sig, plaintext));
       pos = 0;
       /* find pings & pongs! */
-      while (pos + sizeof (MESSAGE_HEADER) < size)
+      while (pos + sizeof (GNUNET_MessageHeader) < size)
         {
-          MESSAGE_HEADER *hdr;
+          GNUNET_MessageHeader *hdr;
 
-          hdr = (MESSAGE_HEADER *) & plaintext[pos];
+          hdr = (GNUNET_MessageHeader *) & plaintext[pos];
           if (htons (hdr->size) + pos > size)
             {
               GE_LOG (ectx,
@@ -754,7 +770,7 @@
 #endif
       coreAPI->injectMessage (sender,
                               (char *) pong,
-                              ntohs (pong->size), YES, tsession);
+                              ntohs (pong->size), GNUNET_YES, tsession);
       if (ping != NULL)
         {                       /* should always be true for well-behaved 
peers */
           /* pong can go out over ordinary channels */
@@ -791,55 +807,56 @@
           /* PING not included in SKEY - bug (in other peer!?) */
         }
     }
-  FREENONNULL (plaintext);
-  return OK;
+  GNUNET_free_non_null (plaintext);
+  return GNUNET_OK;
 }
 
 /**
  * Try to connect to the given peer.
  *
- * @return SYSERR if that is impossible,
- *         YES if a connection is established upon return,
- *         NO if we're going to try to establish one asynchronously
+ * @return GNUNET_SYSERR if that is impossible,
+ *         GNUNET_YES if a connection is established upon return,
+ *         GNUNET_NO if we're going to try to establish one asynchronously
  */
 static int
-tryConnect (const PeerIdentity * peer)
+tryConnect (const GNUNET_PeerIdentity * peer)
 {
 #if DEBUG_SESSION
-  EncName enc;
+  GNUNET_EncName enc;
 
   IF_GELOG (ectx,
             GE_DEBUG | GE_USER | GE_REQUEST,
-            hash2enc (&peer->hashPubKey, &enc));
+            GNUNET_hash_to_enc (&peer->hashPubKey, &enc));
 #endif
-  if ((topology != NULL) && (topology->allowConnectionFrom (peer) == SYSERR))
+  if ((topology != NULL)
+      && (topology->allowConnectionFrom (peer) == GNUNET_SYSERR))
     {
 #if DEBUG_SESSION
       GE_LOG (ectx,
               GE_DEBUG | GE_USER | GE_REQUEST,
               "Topology rejected connecting to `%s'.\n", &enc);
 #endif
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  if (coreAPI->queryPeerStatus (peer, NULL, NULL) == OK)
+  if (coreAPI->queryPeerStatus (peer, NULL, NULL) == GNUNET_OK)
     {
 #if DEBUG_SESSION
       GE_LOG (ectx,
               GE_DEBUG | GE_USER | GE_REQUEST,
               "Connection to `%s' already up\n", &enc);
 #endif
-      return YES;               /* trivial case */
+      return GNUNET_YES;        /* trivial case */
     }
 #if DEBUG_SESSION
   GE_LOG (ectx,
           GE_DEBUG | GE_USER | GE_REQUEST,
           "Trying to exchange key with `%s'.\n", &enc);
 #endif
-  if (YES == identity->isBlacklisted (peer, NO))
-    return NO;                  /* not allowed right now! */
-  if (OK == exchangeKey (peer, NULL, NULL))
-    return NO;
-  return SYSERR;
+  if (GNUNET_YES == identity->isBlacklisted (peer, GNUNET_NO))
+    return GNUNET_NO;           /* not allowed right now! */
+  if (GNUNET_OK == exchangeKey (peer, NULL, NULL))
+    return GNUNET_NO;
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -848,11 +865,11 @@
  * value.  (Rekeying).
  */
 static int
-acceptSessionKeyUpdate (const PeerIdentity * sender,
-                        const MESSAGE_HEADER * msg)
+acceptSessionKeyUpdate (const GNUNET_PeerIdentity * sender,
+                        const GNUNET_MessageHeader * msg)
 {
   acceptSessionKey (sender, msg, NULL);
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -940,7 +957,7 @@
   coreAPI->releaseService (pingpong);
   pingpong = NULL;
   coreAPI = NULL;
-  return OK;
+  return GNUNET_OK;
 }
 
 /* end of connect.c */

Modified: GNUnet/src/applications/session/sessiontest.c
===================================================================
--- GNUnet/src/applications/session/sessiontest.c       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/session/sessiontest.c       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -32,7 +32,7 @@
 #include "gnunet_testing_lib.h"
 #include "gnunet_stats_lib.h"
 
-#define START_PEERS YES
+#define START_PEERS GNUNET_YES
 
 static int ok;
 
@@ -42,9 +42,9 @@
   if ((value > 0) && (0 == strcmp (_("# of connected peers"), name)))
     {
       ok = 1;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -58,22 +58,22 @@
 main (int argc, char **argv)
 {
 #if START_PEERS
-  struct DaemonContext *peers;
+  struct GNUNET_TESTING_DaemonContext *peers;
 #endif
   int ret;
-  struct ClientServerConnection *sock1;
-  struct ClientServerConnection *sock2;
+  struct GNUNET_ClientServerConnection *sock1;
+  struct GNUNET_ClientServerConnection *sock2;
   int left;
   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_PEERS
-  peers = gnunet_testing_start_daemons (strstr (argv[0], "_") + 1,      /* 
tcp, udp or http */
+  peers = GNUNET_TESTING_start_daemons (strstr (argv[0], "_") + 1,      /* 
tcp, udp or http */
                                         "advertising stats",
                                         "/tmp/gnunet-session-test", 2087,
                                         10000, 2);
@@ -83,17 +83,19 @@
       return -1;
     }
 #endif
-  gnunet_testing_connect_daemons (2087, 12087);
-  if (OK == connection_wait_for_running (NULL, cfg, 30 * cronSECONDS))
+  GNUNET_TESTING_connect_daemons (2087, 12087);
+  if (GNUNET_OK ==
+      GNUNET_wait_for_daemon_running (NULL, cfg, 30 * GNUNET_CRON_SECONDS))
     {
-      sock1 = client_connection_create (NULL, cfg);
+      sock1 = GNUNET_client_connection_create (NULL, cfg);
       GC_set_configuration_value_string (cfg,
                                          NULL,
                                          "NETWORK",
                                          "HOST", "localhost:12087");
-      sock2 = client_connection_create (NULL, cfg);
+      sock2 = GNUNET_client_connection_create (NULL, cfg);
       left = 30;                /* how many iterations should we wait? */
-      while (OK == STATS_getStatistics (NULL, sock1, &waitForConnect, NULL))
+      while (GNUNET_OK ==
+             STATS_getStatistics (NULL, sock1, &waitForConnect, NULL))
         {
           printf ("Waiting for peers to connect (%u iterations left)...\n",
                   left);
@@ -111,7 +113,7 @@
           for (left = 0; left < 10; left++)
             {
               ok = 0;
-              while (GNUNET_SHUTDOWN_TEST () == NO)
+              while (GNUNET_shutdown_test () == GNUNET_NO)
                 {
                   printf ("Checking that peers are staying connected 1...\n");
                   STATS_getStatistics (NULL, sock1, &waitForConnect, NULL);
@@ -138,8 +140,8 @@
         }
 #endif
 
-      connection_destroy (sock1);
-      connection_destroy (sock2);
+      GNUNET_client_connection_destroy (sock1);
+      GNUNET_client_connection_destroy (sock2);
     }
   else
     {
@@ -147,7 +149,7 @@
       ret = 1;
     }
 #if START_PEERS
-  gnunet_testing_stop_daemons (peers);
+  GNUNET_TESTING_stop_daemons (peers);
 #endif
   GC_free (cfg);
   return (ok == 0) ? 1 : 0;

Modified: GNUnet/src/applications/session/sessiontest2.c
===================================================================
--- GNUnet/src/applications/session/sessiontest2.c      2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/session/sessiontest2.c      2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -42,9 +42,9 @@
   if ((value > 0) && (0 == strcmp (_("# of connected peers"), name)))
     {
       ok = 1;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -53,45 +53,48 @@
  *
  * @param port1 client port of the first daemon
  * @param port2 client port of the second daemon
- * @return OK on success, SYSERR on failure
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
 static int
 connect_daemons (unsigned short port1, unsigned short port2)
 {
   char host[128];
-  GC_Configuration *cfg1 = GC_create_C_impl ();
-  GC_Configuration *cfg2 = GC_create_C_impl ();
-  struct ClientServerConnection *sock1;
-  struct ClientServerConnection *sock2;
+  GC_Configuration *cfg1 = GC_create ();
+  GC_Configuration *cfg2 = GC_create ();
+  struct GNUNET_ClientServerConnection *sock1;
+  struct GNUNET_ClientServerConnection *sock2;
   int ret;
-  P2P_hello_MESSAGE *h1;
+  GNUNET_MessageHello *h1;
 
-  ret = SYSERR;
-  SNPRINTF (host, 128, "localhost:%u", port1);
+  ret = GNUNET_SYSERR;
+  GNUNET_snprintf (host, 128, "localhost:%u", port1);
   GC_set_configuration_value_string (cfg1, NULL, "NETWORK", "HOST", host);
-  SNPRINTF (host, 128, "localhost:%u", port2);
+  GNUNET_snprintf (host, 128, "localhost:%u", port2);
   GC_set_configuration_value_string (cfg2, NULL, "NETWORK", "HOST", host);
-  if ((OK == connection_wait_for_running (NULL,
-                                          cfg1,
-                                          300 * cronSECONDS)) &&
-      (OK == connection_wait_for_running (NULL, cfg2, 300 * cronSECONDS)))
+  if ((GNUNET_OK == GNUNET_wait_for_daemon_running (NULL,
+                                                    cfg1,
+                                                    300 *
+                                                    GNUNET_CRON_SECONDS))
+      && (GNUNET_OK ==
+          GNUNET_wait_for_daemon_running (NULL, cfg2,
+                                          300 * GNUNET_CRON_SECONDS)))
     {
-      sock1 = client_connection_create (NULL, cfg1);
-      sock2 = client_connection_create (NULL, cfg2);
+      sock1 = GNUNET_client_connection_create (NULL, cfg1);
+      sock2 = GNUNET_client_connection_create (NULL, cfg2);
       h1 = NULL;
       fprintf (stderr, "Notifying NATed peer about other peer");
-      if ((OK == gnunet_identity_get_self (sock1,
-                                           &h1)) &&
-          (OK == gnunet_identity_peer_add (sock2, h1)))
+      if ((GNUNET_OK == GNUNET_IDENTITY_get_self (sock1,
+                                                  &h1)) &&
+          (GNUNET_OK == GNUNET_IDENTITY_peer_add (sock2, h1)))
         {
           fprintf (stderr, "!\n");
-          ret = OK;
+          ret = GNUNET_OK;
         }
       else
         fprintf (stderr, "?\n");
-      FREENONNULL (h1);
-      connection_destroy (sock1);
-      connection_destroy (sock2);
+      GNUNET_free_non_null (h1);
+      GNUNET_client_connection_destroy (sock1);
+      GNUNET_client_connection_destroy (sock2);
     }
   else
     {
@@ -118,37 +121,39 @@
   pid_t peer2;
 #endif
   int ret;
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   int left;
   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_PEERS
-  peer1 = os_daemon_start (NULL, cfg, "tcp-peer.conf", NO);
+  peer1 = GNUNET_daemon_start (NULL, cfg, "tcp-peer.conf", GNUNET_NO);
   if (peer1 == -1)
     {
       GC_free (cfg);
       return -1;
     }
-  peer2 = os_daemon_start (NULL, cfg, "nat-peer.conf", NO);
+  peer2 = GNUNET_daemon_start (NULL, cfg, "nat-peer.conf", GNUNET_NO);
   if (peer2 == -1)
     {
-      os_daemon_stop (NULL, peer1);
+      GNUNET_daemon_stop (NULL, peer1);
       GC_free (cfg);
       return -1;
     }
 #endif
   connect_daemons (2087, 12087);
-  if (OK == connection_wait_for_running (NULL, cfg, 30 * cronSECONDS))
+  if (GNUNET_OK ==
+      GNUNET_wait_for_daemon_running (NULL, cfg, 30 * GNUNET_CRON_SECONDS))
     {
-      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 connect (%u iterations left)...\n",
                   left);
@@ -160,7 +165,7 @@
               break;
             }
         }
-      connection_destroy (sock);
+      GNUNET_client_connection_destroy (sock);
     }
   else
     {
@@ -168,8 +173,8 @@
       ret = 1;
     }
 #if START_PEERS
-  os_daemon_stop (NULL, peer1);
-  os_daemon_stop (NULL, peer2);
+  GNUNET_daemon_stop (NULL, peer1);
+  GNUNET_daemon_stop (NULL, peer2);
 #endif
   GC_free (cfg);
   return (ok == 0) ? 1 : 0;

Modified: GNUnet/src/applications/session/sessiontest_http.c
===================================================================
--- GNUnet/src/applications/session/sessiontest_http.c  2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/session/sessiontest_http.c  2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -42,9 +42,9 @@
   if ((value > 0) && (0 == strcmp (_("# of connected peers"), name)))
     {
       ok = 1;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -53,45 +53,48 @@
  *
  * @param port1 client port of the first daemon
  * @param port2 client port of the second daemon
- * @return OK on success, SYSERR on failure
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
 static int
 connect_daemons (unsigned short port1, unsigned short port2)
 {
   char host[128];
-  GC_Configuration *cfg1 = GC_create_C_impl ();
-  GC_Configuration *cfg2 = GC_create_C_impl ();
-  struct ClientServerConnection *sock1;
-  struct ClientServerConnection *sock2;
+  GC_Configuration *cfg1 = GC_create ();
+  GC_Configuration *cfg2 = GC_create ();
+  struct GNUNET_ClientServerConnection *sock1;
+  struct GNUNET_ClientServerConnection *sock2;
   int ret;
-  P2P_hello_MESSAGE *h1;
+  GNUNET_MessageHello *h1;
 
-  ret = SYSERR;
-  SNPRINTF (host, 128, "localhost:%u", port1);
+  ret = GNUNET_SYSERR;
+  GNUNET_snprintf (host, 128, "localhost:%u", port1);
   GC_set_configuration_value_string (cfg1, NULL, "NETWORK", "HOST", host);
-  SNPRINTF (host, 128, "localhost:%u", port2);
+  GNUNET_snprintf (host, 128, "localhost:%u", port2);
   GC_set_configuration_value_string (cfg2, NULL, "NETWORK", "HOST", host);
-  if ((OK == connection_wait_for_running (NULL,
-                                          cfg1,
-                                          300 * cronSECONDS)) &&
-      (OK == connection_wait_for_running (NULL, cfg2, 300 * cronSECONDS)))
+  if ((GNUNET_OK == GNUNET_wait_for_daemon_running (NULL,
+                                                    cfg1,
+                                                    300 *
+                                                    GNUNET_CRON_SECONDS))
+      && (GNUNET_OK ==
+          GNUNET_wait_for_daemon_running (NULL, cfg2,
+                                          300 * GNUNET_CRON_SECONDS)))
     {
-      sock1 = client_connection_create (NULL, cfg1);
-      sock2 = client_connection_create (NULL, cfg2);
+      sock1 = GNUNET_client_connection_create (NULL, cfg1);
+      sock2 = GNUNET_client_connection_create (NULL, cfg2);
       h1 = NULL;
       fprintf (stderr, "Notifying NATed peer about other peer");
-      if ((OK == gnunet_identity_get_self (sock1,
-                                           &h1)) &&
-          (OK == gnunet_identity_peer_add (sock2, h1)))
+      if ((GNUNET_OK == GNUNET_IDENTITY_get_self (sock1,
+                                                  &h1)) &&
+          (GNUNET_OK == GNUNET_IDENTITY_peer_add (sock2, h1)))
         {
           fprintf (stderr, "!\n");
-          ret = OK;
+          ret = GNUNET_OK;
         }
       else
         fprintf (stderr, "?\n");
-      FREENONNULL (h1);
-      connection_destroy (sock1);
-      connection_destroy (sock2);
+      GNUNET_free_non_null (h1);
+      GNUNET_client_connection_destroy (sock1);
+      GNUNET_client_connection_destroy (sock2);
     }
   else
     {
@@ -118,37 +121,39 @@
   pid_t peer2;
 #endif
   int ret;
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   int left;
   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_PEERS
-  peer1 = os_daemon_start (NULL, cfg, "http-peer.conf", NO);
+  peer1 = GNUNET_daemon_start (NULL, cfg, "http-peer.conf", GNUNET_NO);
   if (peer1 == -1)
     {
       GC_free (cfg);
       return -1;
     }
-  peer2 = os_daemon_start (NULL, cfg, "nat-http-peer.conf", NO);
+  peer2 = GNUNET_daemon_start (NULL, cfg, "nat-http-peer.conf", GNUNET_NO);
   if (peer2 == -1)
     {
-      os_daemon_stop (NULL, peer1);
+      GNUNET_daemon_stop (NULL, peer1);
       GC_free (cfg);
       return -1;
     }
 #endif
   connect_daemons (2087, 12087);
-  if (OK == connection_wait_for_running (NULL, cfg, 30 * cronSECONDS))
+  if (GNUNET_OK ==
+      GNUNET_wait_for_daemon_running (NULL, cfg, 30 * GNUNET_CRON_SECONDS))
     {
-      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 connect (%u iterations left)...\n",
                   left);
@@ -160,7 +165,7 @@
               break;
             }
         }
-      connection_destroy (sock);
+      GNUNET_client_connection_destroy (sock);
     }
   else
     {
@@ -168,8 +173,8 @@
       ret = 1;
     }
 #if START_PEERS
-  os_daemon_stop (NULL, peer1);
-  os_daemon_stop (NULL, peer2);
+  GNUNET_daemon_stop (NULL, peer1);
+  GNUNET_daemon_stop (NULL, peer2);
 #endif
   GC_free (cfg);
   return (ok == 0) ? 1 : 0;

Modified: GNUnet/src/applications/sqstore_mysql/Makefile.am
===================================================================
--- GNUnet/src/applications/sqstore_mysql/Makefile.am   2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/sqstore_mysql/Makefile.am   2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -36,19 +36,16 @@
  mysqltest.c 
 mysqltest_LDADD = \
  $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
  $(top_builddir)/src/server/libgnunetcore.la
 
 mysqltest2_SOURCES = \
  mysqltest2.c 
 mysqltest2_LDADD = \
  $(top_builddir)/src/server/libgnunetcore.la  \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
  $(top_builddir)/src/util/libgnunetutil.la  
 
 mysqltest3_SOURCES = \
  mysqltest3.c 
 mysqltest3_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/sqstore_mysql/mysql.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysql.c       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/sqstore_mysql/mysql.c       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -131,9 +131,9 @@
 #include "gnunet_state_service.h"
 #include <mysql/mysql.h>
 
-#define DEBUG_MYSQL NO
+#define DEBUG_MYSQL GNUNET_NO
 
-#define DEBUG_TIME_MYSQL NO
+#define DEBUG_TIME_MYSQL GNUNET_NO
 
 #define MAX_DATUM_SIZE 65536
 
@@ -165,7 +165,7 @@
 /**
  * Lock for updating content_size
  */
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 static struct GE_Context *ectx;
 
@@ -233,9 +233,9 @@
 #endif
 
 /* warning, slighly crazy mysql statements ahead.  Essentially, MySQL does not 
handle
-   "OR" very well, so we need to use UNION instead.  And UNION does not 
-   automatically apply a LIMIT on the outermost clause, so we need to 
-   repeat ourselves quite a bit.  All hail the performance gods (and thanks 
+   "OR" very well, so we need to use UNION instead.  And UNION does not
+   automatically apply a LIMIT on the outermost clause, so we need to
+   repeat ourselves quite a bit.  All hail the performance gods (and thanks
    to #mysql on freenode) */
 #define SELECT_IT_LOW_PRIORITY "(SELECT * FROM gn071 FORCE INDEX(prio) WHERE 
(prio = ? AND vkey > ?) "\
                                "ORDER BY prio ASC,vkey ASC LIMIT 1) "\
@@ -284,7 +284,7 @@
 {
 #define PEND(h) if (h != NULL) { mysql_stmt_close(h); h = NULL; } else {}
   if (dbh->dbf == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   PEND (dbh->select_value);
   PEND (dbh->delete_value);
   PEND (dbh->insert_value);
@@ -301,15 +301,15 @@
   PEND (dbh->iter[3]);
   mysql_close (dbh->dbf);
   dbh->dbf = NULL;
-  dbh->valid = NO;
-  return OK;
+  dbh->valid = GNUNET_NO;
+  return GNUNET_OK;
 }
 
 /**
  * Initiate the database connection.  Uses dbh->cnffile for the
  * configuration, so that must be set already.
  *
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 static int
 iopen ()
@@ -319,10 +319,10 @@
   unsigned int timeout = 60;    /* in seconds */
 
   if (dbh->cnffile == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   dbh->dbf = mysql_init (NULL);
   if (dbh->dbf == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   mysql_options (dbh->dbf, MYSQL_READ_DEFAULT_FILE, dbh->cnffile);
   mysql_options (dbh->dbf, MYSQL_READ_DEFAULT_GROUP, "client");
   mysql_options (dbh->dbf, MYSQL_OPT_RECONNECT, &reconnect);
@@ -336,12 +336,12 @@
                                      "MYSQL", "DATABASE", "gnunet", &dbname);
   GE_ASSERT (ectx, dbname != NULL);
   mysql_real_connect (dbh->dbf, NULL, NULL, NULL, dbname, 0, NULL, 0);
-  FREE (dbname);
+  GNUNET_free (dbname);
   if (mysql_error (dbh->dbf)[0])
     {
       LOG_MYSQL (GE_ERROR | GE_ADMIN | GE_BULK, "mysql_real_connect", dbh);
       iclose ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   mysql_query (dbh->dbf,
                "SET SESSION net_read_timeout=60, SESSION 
net_write_timeout=60");
@@ -349,9 +349,9 @@
     {
       LOG_MYSQL (GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", dbh);
       iclose ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  /* MySQL 5.0.46 fixes a bug in MyISAM (presumably); 
+  /* MySQL 5.0.46 fixes a bug in MyISAM (presumably);
      earlier versions have issues with INDEX over BINARY data,
      which is why we need to use InnoDB for those
      (even though MyISAM would be faster) */
@@ -396,7 +396,7 @@
     {
       LOG_MYSQL (GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", dbh);
       iclose ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   mysql_query (dbh->dbf,
                "CREATE TABLE IF NOT EXISTS gn072 ("
@@ -406,20 +406,20 @@
     {
       LOG_MYSQL (GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", dbh);
       iclose ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   mysql_query (dbh->dbf, "SET AUTOCOMMIT = 1");
   if (mysql_error (dbh->dbf)[0])
     {
       LOG_MYSQL (GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", dbh);
       iclose ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-#define PINIT(a,b) a = mysql_stmt_init(dbh->dbf); if (a == NULL) { iclose(); 
return SYSERR; } else { \
+#define PINIT(a,b) a = mysql_stmt_init(dbh->dbf); if (a == NULL) { iclose(); 
return GNUNET_SYSERR; } else { \
     if (mysql_stmt_prepare (a, b, strlen(b))) { \
       GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER, \
              _("`%s' failed at %s:%d with error: %s"), "mysql_stmt_prepare", 
__FILE__, __LINE__, \
-             mysql_stmt_error (a));  iclose(); return SYSERR; } }
+             mysql_stmt_error (a));  iclose(); return GNUNET_SYSERR; } }
   PINIT (dbh->select_value, SELECT_VALUE);
   PINIT (dbh->delete_value, DELETE_VALUE);
   PINIT (dbh->insert_value, INSERT_VALUE);
@@ -434,23 +434,23 @@
   PINIT (dbh->iter[1], SELECT_IT_NON_ANONYMOUS);
   PINIT (dbh->iter[2], SELECT_IT_EXPIRATION_TIME);
   PINIT (dbh->iter[3], SELECT_IT_MIGRATION_ORDER);
-  dbh->valid = YES;
-  return OK;
+  dbh->valid = GNUNET_YES;
+  return GNUNET_OK;
 }
 
 /**
- * Check if DBH handle is valid, return OK if it is.
+ * Check if DBH handle is valid, return GNUNET_OK if it is.
  * Also tries to re-connect to the DB if the connection
  * is down.
  */
-#define CHECK_DBH ((dbh->valid == NO) ? iopen(dbh, YES) : OK)
+#define CHECK_DBH ((dbh->valid == GNUNET_NO) ? iopen(dbh, GNUNET_YES) : 
GNUNET_OK)
 
 
 /**
  * Delete an value from the gn072 table.
  *
  * @param vkey vkey identifying the value to delete
- * @return OK on success, NO if no such value exists, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_NO if no such value exists, 
GNUNET_SYSERR on error
  */
 static int
 delete_value (unsigned long long vkey)
@@ -459,7 +459,7 @@
   int ret;
 
   memset (qbind, 0, sizeof (qbind));
-  qbind[0].is_unsigned = YES;
+  qbind[0].is_unsigned = GNUNET_YES;
   qbind[0].buffer_type = MYSQL_TYPE_LONGLONG;
   qbind[0].buffer = &vkey;
   GE_ASSERT (ectx, mysql_stmt_param_count (dbh->delete_value) == 1);
@@ -471,7 +471,7 @@
               "mysql_stmt_bind_param",
               __FILE__, __LINE__, mysql_stmt_error (dbh->delete_value));
       iclose ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (mysql_stmt_execute (dbh->delete_value))
     {
@@ -481,12 +481,12 @@
               "mysql_stmt_execute",
               __FILE__, __LINE__, mysql_stmt_error (dbh->delete_value));
       iclose ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (mysql_stmt_affected_rows (dbh->delete_value) == 0)
-    ret = NO;
+    ret = GNUNET_NO;
   else
-    ret = OK;
+    ret = GNUNET_OK;
   mysql_stmt_reset (dbh->delete_value);
   return ret;
 }
@@ -497,7 +497,7 @@
  * @param value the value to insert
  * @param size size of the value
  * @param vkey vkey identifying the value henceforth (set)
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
 insert_value (const void *value, unsigned int size, unsigned long long *vkey)
@@ -519,7 +519,7 @@
               "mysql_stmt_bind_param",
               __FILE__, __LINE__, mysql_stmt_error (dbh->insert_value));
       iclose ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (mysql_stmt_execute (dbh->insert_value))
     {
@@ -529,18 +529,18 @@
               "mysql_stmt_execute",
               __FILE__, __LINE__, mysql_stmt_error (dbh->insert_value));
       iclose ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   *vkey = (unsigned long long) mysql_stmt_insert_id (dbh->insert_value);
   mysql_stmt_reset (dbh->insert_value);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Delete an entry from the gn071 table.
  *
  * @param vkey vkey identifying the entry to delete
- * @return OK on success, NO if no such value exists, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_NO if no such value exists, 
GNUNET_SYSERR on error
  */
 static int
 delete_entry_by_vkey (unsigned long long vkey)
@@ -549,7 +549,7 @@
   int ret;
 
   memset (qbind, 0, sizeof (qbind));
-  qbind[0].is_unsigned = YES;
+  qbind[0].is_unsigned = GNUNET_YES;
   qbind[0].buffer_type = MYSQL_TYPE_LONGLONG;
   qbind[0].buffer = &vkey;
   GE_ASSERT (ectx, mysql_stmt_param_count (dbh->delete_entry_by_vkey) == 1);
@@ -562,7 +562,7 @@
               __FILE__, __LINE__,
               mysql_stmt_error (dbh->delete_entry_by_vkey));
       iclose ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (mysql_stmt_execute (dbh->delete_entry_by_vkey))
     {
@@ -573,12 +573,12 @@
               __FILE__, __LINE__,
               mysql_stmt_error (dbh->delete_entry_by_vkey));
       iclose ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (mysql_stmt_affected_rows (dbh->delete_entry_by_vkey) == 0)
-    ret = NO;
+    ret = GNUNET_NO;
   else
-    ret = OK;
+    ret = GNUNET_OK;
   mysql_stmt_reset (dbh->delete_entry_by_vkey);
   return ret;
 }
@@ -618,8 +618,8 @@
       (result[4].buffer_type != MYSQL_TYPE_LONGLONG) ||
       (!result[4].is_unsigned) ||
       (result[5].buffer_type != MYSQL_TYPE_BLOB) ||
-      (result[5].buffer_length != sizeof (HashCode512)) ||
-      (*result[5].length != sizeof (HashCode512)) ||
+      (result[5].buffer_length != sizeof (GNUNET_HashCode)) ||
+      (*result[5].length != sizeof (GNUNET_HashCode)) ||
       (result[6].buffer_type != MYSQL_TYPE_LONGLONG) ||
       (!result[6].is_unsigned))
     {
@@ -636,17 +636,17 @@
   level = *(unsigned int *) result[3].buffer;
   exp = *(unsigned long long *) result[4].buffer;
   vkey = *(unsigned long long *) result[6].buffer;
-  datum = MALLOC (sizeof (Datastore_Value) + contentSize);
+  datum = GNUNET_malloc (sizeof (Datastore_Value) + contentSize);
   datum->size = htonl (contentSize + sizeof (Datastore_Value));
   datum->type = htonl (type);
   datum->prio = htonl (prio);
   datum->anonymityLevel = htonl (level);
-  datum->expirationTime = htonll (exp);
+  datum->expirationTime = GNUNET_htonll (exp);
 
   /* now do query on gn072 */
   length = contentSize;
   memset (qbind, 0, sizeof (qbind));
-  qbind[0].is_unsigned = YES;
+  qbind[0].is_unsigned = GNUNET_YES;
   qbind[0].buffer_type = MYSQL_TYPE_LONGLONG;
   qbind[0].buffer = &vkey;
   memset (rbind, 0, sizeof (rbind));
@@ -654,11 +654,11 @@
   rbind[0].buffer_length = contentSize;
   rbind[0].length = &length;
   rbind[0].buffer = &datum[1];
-  MUTEX_LOCK (lock);
-  if (OK != CHECK_DBH)
+  GNUNET_mutex_lock (lock);
+  if (GNUNET_OK != CHECK_DBH)
     {
-      MUTEX_UNLOCK (lock);
-      FREE (datum);
+      GNUNET_mutex_unlock (lock);
+      GNUNET_free (datum);
       return NULL;
     }
   GE_ASSERT (ectx, mysql_stmt_param_count (dbh->select_value) == 1);
@@ -670,8 +670,8 @@
               "mysql_stmt_bind_param",
               __FILE__, __LINE__, mysql_stmt_error (dbh->select_value));
       iclose ();
-      MUTEX_UNLOCK (lock);
-      FREE (datum);
+      GNUNET_mutex_unlock (lock);
+      GNUNET_free (datum);
       return NULL;
     }
   if (mysql_stmt_execute (dbh->select_value))
@@ -682,7 +682,7 @@
               "mysql_stmt_execute",
               __FILE__, __LINE__, mysql_stmt_error (dbh->select_value));
       iclose ();
-      FREE (datum);
+      GNUNET_free (datum);
       return NULL;
     }
   GE_ASSERT (ectx, mysql_stmt_field_count (dbh->select_value) == 1);
@@ -694,8 +694,8 @@
               "mysql_stmt_bind_result",
               __FILE__, __LINE__, mysql_stmt_error (dbh->select_value));
       iclose ();
-      MUTEX_UNLOCK (lock);
-      FREE (datum);
+      GNUNET_mutex_unlock (lock);
+      GNUNET_free (datum);
       return NULL;
     }
   if ((0 != mysql_stmt_fetch (dbh->select_value)) ||
@@ -709,22 +709,22 @@
               __FILE__, __LINE__, mysql_stmt_error (dbh->select_value));
       delete_entry_by_vkey (vkey);
       content_size -= ntohl (datum->size);
-      MUTEX_UNLOCK (lock);
-      FREE (datum);
+      GNUNET_mutex_unlock (lock);
+      GNUNET_free (datum);
       return NULL;
     }
   mysql_stmt_reset (dbh->select_value);
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return datum;
 }
 
 /**
  * Store an item in the datastore.
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
-put (const HashCode512 * key, const Datastore_Value * value)
+put (const GNUNET_HashCode * key, const Datastore_Value * value)
 {
   unsigned long contentSize;
   unsigned long hashSize;
@@ -736,65 +736,65 @@
   unsigned long long vkey;
   MYSQL_BIND qbind[7];
 #if DEBUG_MYSQL
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   if (((ntohl (value->size) < sizeof (Datastore_Value))) ||
       ((ntohl (value->size) - sizeof (Datastore_Value)) > MAX_DATUM_SIZE))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   mysql_thread_init ();
-  if (OK != CHECK_DBH)
+  if (GNUNET_OK != CHECK_DBH)
     {
       mysql_thread_end ();
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   contentSize = ntohl (value->size) - sizeof (Datastore_Value);
-  if (OK != insert_value (&value[1], contentSize, &vkey))
+  if (GNUNET_OK != insert_value (&value[1], contentSize, &vkey))
     {
       mysql_thread_end ();
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
-  hashSize = sizeof (HashCode512);
+  hashSize = sizeof (GNUNET_HashCode);
   size = ntohl (value->size);
   type = ntohl (value->type);
   prio = ntohl (value->prio);
   level = ntohl (value->anonymityLevel);
-  expiration = ntohll (value->expirationTime);
+  expiration = GNUNET_ntohll (value->expirationTime);
 #if DEBUG_MYSQL
-  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 in database block with type %u and key %s.\n", type, &enc);
 #endif
   GE_ASSERT (ectx, mysql_stmt_param_count (dbh->insert_entry) == 7);
   memset (qbind, 0, sizeof (qbind));
   qbind[0].buffer_type = MYSQL_TYPE_LONG;       /* size */
   qbind[0].buffer = &size;
-  qbind[0].is_unsigned = YES;
+  qbind[0].is_unsigned = GNUNET_YES;
   qbind[1].buffer_type = MYSQL_TYPE_LONG;       /* type */
-  qbind[1].is_unsigned = YES;
+  qbind[1].is_unsigned = GNUNET_YES;
   qbind[1].buffer = &type;
   qbind[2].buffer_type = MYSQL_TYPE_LONG;       /* prio */
-  qbind[2].is_unsigned = YES;
+  qbind[2].is_unsigned = GNUNET_YES;
   qbind[2].buffer = &prio;
   qbind[3].buffer_type = MYSQL_TYPE_LONG;       /* anon level */
-  qbind[3].is_unsigned = YES;
+  qbind[3].is_unsigned = GNUNET_YES;
   qbind[3].buffer = &level;
   qbind[4].buffer_type = MYSQL_TYPE_LONGLONG;   /* expiration */
-  qbind[4].is_unsigned = YES;
+  qbind[4].is_unsigned = GNUNET_YES;
   qbind[4].buffer = &expiration;
-  qbind[5].buffer_type = MYSQL_TYPE_BLOB;       /* hash */
+  qbind[5].buffer_type = MYSQL_TYPE_BLOB;       /* GNUNET_hash */
   qbind[5].buffer = (void *) key;
   qbind[5].length = &hashSize;
   qbind[5].buffer_length = hashSize;
   qbind[6].buffer_type = MYSQL_TYPE_LONGLONG;   /* vkey */
-  qbind[6].is_unsigned = YES;
+  qbind[6].is_unsigned = GNUNET_YES;
   qbind[6].buffer = &vkey;
 
   if (mysql_stmt_bind_param (dbh->insert_entry, qbind))
@@ -807,8 +807,8 @@
       delete_value (vkey);
       iclose ();
       mysql_thread_end ();
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
 
   if (mysql_stmt_execute (dbh->insert_entry))
@@ -821,13 +821,13 @@
       delete_value (vkey);
       iclose ();
       mysql_thread_end ();
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   mysql_thread_end ();
   content_size += ntohl (value->size);
-  MUTEX_UNLOCK (lock);
-  return OK;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 
@@ -844,7 +844,7 @@
  * @param is_asc are we using ascending order?
  * @param is_prio is the extra ordering by priority (otherwise by expiration)
  * @param is_migr is this IT_MIGRATON_ORDER (with expire)
- * @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
@@ -867,8 +867,8 @@
   unsigned long long expiration;
   unsigned long long vkey;
   unsigned long hashSize;
-  HashCode512 key;
-  cron_t now;
+  GNUNET_HashCode key;
+  GNUNET_CronTime now;
   MYSQL_BIND qbind[6];
   MYSQL_BIND rbind[7];
   MYSQL_STMT *stmt;
@@ -891,76 +891,76 @@
     {
       qbind[0].buffer_type = MYSQL_TYPE_LONG;
       qbind[0].buffer = &last_prio;
-      qbind[0].is_unsigned = YES;
+      qbind[0].is_unsigned = GNUNET_YES;
       qbind[2 + is_migr].buffer_type = MYSQL_TYPE_LONG;
       qbind[2 + is_migr].buffer = &last_prio;
-      qbind[2 + is_migr].is_unsigned = YES;
+      qbind[2 + is_migr].is_unsigned = GNUNET_YES;
     }
   else
     {
       qbind[0].buffer_type = MYSQL_TYPE_LONGLONG;
       qbind[0].buffer = &last_expire;
-      qbind[0].is_unsigned = YES;
+      qbind[0].is_unsigned = GNUNET_YES;
       qbind[2 + is_migr].buffer_type = MYSQL_TYPE_LONGLONG;
       qbind[2 + is_migr].buffer = &last_expire;
-      qbind[2 + is_migr].is_unsigned = YES;
+      qbind[2 + is_migr].is_unsigned = GNUNET_YES;
     }
   qbind[1].buffer_type = MYSQL_TYPE_LONGLONG;
   qbind[1].buffer = &last_vkey;
-  qbind[1].is_unsigned = YES;
+  qbind[1].is_unsigned = GNUNET_YES;
   qbind[3 + is_migr].buffer_type = MYSQL_TYPE_LONGLONG;
   qbind[3 + is_migr].buffer = &last_vkey;
-  qbind[3 + is_migr].is_unsigned = YES;
+  qbind[3 + is_migr].is_unsigned = GNUNET_YES;
   if (is_migr)
     {
       qbind[2].buffer_type = MYSQL_TYPE_LONGLONG;
       qbind[2].buffer = &now;
-      qbind[2].is_unsigned = YES;
+      qbind[2].is_unsigned = GNUNET_YES;
       qbind[5].buffer_type = MYSQL_TYPE_LONGLONG;
       qbind[5].buffer = &now;
-      qbind[5].is_unsigned = YES;
+      qbind[5].is_unsigned = GNUNET_YES;
     }
 
-  hashSize = sizeof (HashCode512);
+  hashSize = sizeof (GNUNET_HashCode);
   memset (rbind, 0, sizeof (rbind));
   rbind[0].buffer_type = MYSQL_TYPE_LONG;
   rbind[0].buffer = &size;
-  rbind[0].is_unsigned = YES;
+  rbind[0].is_unsigned = GNUNET_YES;
   rbind[1].buffer_type = MYSQL_TYPE_LONG;
   rbind[1].buffer = &rtype;
-  rbind[1].is_unsigned = YES;
+  rbind[1].is_unsigned = GNUNET_YES;
   rbind[2].buffer_type = MYSQL_TYPE_LONG;
   rbind[2].buffer = &prio;
-  rbind[2].is_unsigned = YES;
+  rbind[2].is_unsigned = GNUNET_YES;
   rbind[3].buffer_type = MYSQL_TYPE_LONG;
   rbind[3].buffer = &level;
-  rbind[3].is_unsigned = YES;
+  rbind[3].is_unsigned = GNUNET_YES;
   rbind[4].buffer_type = MYSQL_TYPE_LONGLONG;
   rbind[4].buffer = &expiration;
-  rbind[4].is_unsigned = YES;
+  rbind[4].is_unsigned = GNUNET_YES;
   rbind[5].buffer_type = MYSQL_TYPE_BLOB;
   rbind[5].buffer = &key;
   rbind[5].buffer_length = hashSize;
   rbind[5].length = &hashSize;
   rbind[6].buffer_type = MYSQL_TYPE_LONGLONG;
   rbind[6].buffer = &vkey;
-  rbind[6].is_unsigned = YES;
+  rbind[6].is_unsigned = GNUNET_YES;
 
   mysql_thread_init ();
   count = 0;
   while (1)
     {
-      MUTEX_LOCK (lock);
-      if (OK != CHECK_DBH)
+      GNUNET_mutex_lock (lock);
+      if (GNUNET_OK != CHECK_DBH)
         {
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           mysql_thread_end ();
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       stmt = dbh->iter[iter_select];
       GE_ASSERT (ectx, mysql_stmt_param_count (stmt) <= 6);
       GE_ASSERT (ectx, mysql_stmt_field_count (stmt) == 7);
-      now = get_time ();
+      now = GNUNET_get_time ();
       if (mysql_stmt_bind_param (stmt, qbind))
         {
           GE_LOG (ectx,
@@ -969,9 +969,9 @@
                   "mysql_stmt_bind_param",
                   __FILE__, __LINE__, mysql_stmt_error (stmt));
           iclose ();
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           mysql_thread_end ();
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (mysql_stmt_execute (stmt))
         {
@@ -981,9 +981,9 @@
                   "mysql_stmt_execute",
                   __FILE__, __LINE__, mysql_stmt_error (stmt));
           iclose ();
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           mysql_thread_end ();
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (mysql_stmt_bind_result (stmt, rbind))
         {
@@ -994,18 +994,18 @@
                   __FILE__, __LINE__, mysql_stmt_error (stmt));
           iclose ();
           mysql_thread_end ();
-          MUTEX_UNLOCK (lock);
-          return SYSERR;
+          GNUNET_mutex_unlock (lock);
+          return GNUNET_SYSERR;
         }
       datum = NULL;
       if (0 != mysql_stmt_fetch (stmt))
         {
           mysql_stmt_reset (stmt);
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           break;
         }
       mysql_stmt_reset (stmt);
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       last_vkey = vkey;
       last_prio = prio;
       last_expire = expiration;
@@ -1016,20 +1016,20 @@
           if (datum == NULL)
             continue;
           ret = iter (&key, datum, closure, vkey);
-          if (ret == SYSERR)
+          if (ret == GNUNET_SYSERR)
             {
-              FREE (datum);
+              GNUNET_free (datum);
               break;
             }
-          if (ret == NO)
+          if (ret == GNUNET_NO)
             {
-              MUTEX_LOCK (lock);
+              GNUNET_mutex_lock (lock);
               delete_value (vkey);
               delete_entry_by_vkey (vkey);
               content_size -= ntohl (datum->size);
-              MUTEX_UNLOCK (lock);
+              GNUNET_mutex_unlock (lock);
             }
-          FREE (datum);
+          GNUNET_free (datum);
         }
     }
   mysql_thread_end ();
@@ -1043,13 +1043,14 @@
  * @param type entries of which type should be considered?
  *        Use 0 for any type.
  * @param iter never NULL
- * @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
 iterateLowPriority (unsigned int type, Datum_Iterator iter, void *closure)
 {
-  return iterateHelper (type, YES, YES, NO, 0, iter, closure);
+  return iterateHelper (type, GNUNET_YES, GNUNET_YES, GNUNET_NO, 0, iter,
+                        closure);
 }
 
 /**
@@ -1059,13 +1060,14 @@
  * @param type entries of which type should be considered?
  *        Use 0 for any type.
  * @param iter never NULL
- * @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
 iterateNonAnonymous (unsigned int type, Datum_Iterator iter, void *closure)
 {
-  return iterateHelper (type, NO, YES, NO, 1, iter, closure);
+  return iterateHelper (type, GNUNET_NO, GNUNET_YES, GNUNET_NO, 1, iter,
+                        closure);
 }
 
 /**
@@ -1075,13 +1077,14 @@
  * @param type entries of which type should be considered?
  *        Use 0 for any type.
  * @param iter never NULL
- * @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
 iterateExpirationTime (unsigned int type, Datum_Iterator iter, void *closure)
 {
-  return iterateHelper (type, YES, NO, NO, 2, iter, closure);
+  return iterateHelper (type, GNUNET_YES, GNUNET_NO, GNUNET_NO, 2, iter,
+                        closure);
 }
 
 /**
@@ -1089,13 +1092,14 @@
  * order.
  *
  * @param iter never NULL
- * @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
 iterateMigrationOrder (Datum_Iterator iter, void *closure)
 {
-  return iterateHelper (0, NO, NO, YES, 3, iter, closure);
+  return iterateHelper (0, GNUNET_NO, GNUNET_NO, GNUNET_YES, 3, iter,
+                        closure);
 }
 
 /**
@@ -1103,13 +1107,14 @@
  * quickly as possible (in any order).
  *
  * @param iter never NULL
- * @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
 iterateAllNow (Datum_Iterator iter, void *closure)
 {
-  return iterateHelper (0, YES, YES, NO, 0, iter, closure);
+  return iterateHelper (0, GNUNET_YES, GNUNET_YES, GNUNET_NO, 0, iter,
+                        closure);
 }
 
 /**
@@ -1120,11 +1125,11 @@
  * @param type entries of which type are relevant?
  *     Use 0 for any type.
  * @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
-get (const HashCode512 * query,
+get (const GNUNET_HashCode * query,
      unsigned int type, Datum_Iterator iter, void *closure)
 {
   int count;
@@ -1138,59 +1143,59 @@
   unsigned long long vkey;
   unsigned long long last_vkey;
   Datastore_Value *datum;
-  HashCode512 key;
+  GNUNET_HashCode key;
   unsigned long hashSize;
   MYSQL_BIND qbind[3];
   MYSQL_BIND rbind[7];
 #if DEBUG_MYSQL
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   if (query == NULL)
     return iterateLowPriority (type, iter, closure);
 
 #if DEBUG_MYSQL
-  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,
           "MySQL looks for `%s' of type %u\n", &enc, type);
 #endif
 
-  hashSize = sizeof (HashCode512);
+  hashSize = sizeof (GNUNET_HashCode);
   memset (qbind, 0, sizeof (qbind));
   qbind[0].buffer_type = MYSQL_TYPE_BLOB;
   qbind[0].buffer = (void *) query;
   qbind[0].length = &hashSize;
   qbind[0].buffer_length = hashSize;
   qbind[1].buffer_type = MYSQL_TYPE_LONGLONG;
-  qbind[1].is_unsigned = YES;
+  qbind[1].is_unsigned = GNUNET_YES;
   qbind[1].buffer = &last_vkey;
   qbind[2].buffer_type = MYSQL_TYPE_LONG;
-  qbind[2].is_unsigned = YES;
+  qbind[2].is_unsigned = GNUNET_YES;
   qbind[2].buffer = &type;
   memset (rbind, 0, sizeof (rbind));
   rbind[0].buffer_type = MYSQL_TYPE_LONG;
   rbind[0].buffer = &size;
-  rbind[0].is_unsigned = YES;
+  rbind[0].is_unsigned = GNUNET_YES;
   rbind[1].buffer_type = MYSQL_TYPE_LONG;
   rbind[1].buffer = &rtype;
-  rbind[1].is_unsigned = YES;
+  rbind[1].is_unsigned = GNUNET_YES;
   rbind[2].buffer_type = MYSQL_TYPE_LONG;
   rbind[2].buffer = &prio;
-  rbind[2].is_unsigned = YES;
+  rbind[2].is_unsigned = GNUNET_YES;
   rbind[3].buffer_type = MYSQL_TYPE_LONG;
   rbind[3].buffer = &level;
-  rbind[3].is_unsigned = YES;
+  rbind[3].is_unsigned = GNUNET_YES;
   rbind[4].buffer_type = MYSQL_TYPE_LONGLONG;
   rbind[4].buffer = &expiration;
-  rbind[4].is_unsigned = YES;
+  rbind[4].is_unsigned = GNUNET_YES;
   rbind[5].buffer_type = MYSQL_TYPE_BLOB;
   rbind[5].buffer = &key;
   rbind[5].buffer_length = hashSize;
   rbind[5].length = &hashSize;
   rbind[6].buffer_type = MYSQL_TYPE_LONGLONG;
   rbind[6].buffer = &vkey;
-  rbind[6].is_unsigned = YES;
+  rbind[6].is_unsigned = GNUNET_YES;
 
 
   mysql_thread_init ();
@@ -1198,12 +1203,12 @@
   count = 0;
   while (1)
     {
-      MUTEX_LOCK (lock);
-      if (OK != CHECK_DBH)
+      GNUNET_mutex_lock (lock);
+      if (GNUNET_OK != CHECK_DBH)
         {
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           mysql_thread_end ();
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (type != 0)
         {
@@ -1234,8 +1239,8 @@
                   __FILE__, __LINE__, mysql_stmt_error (stmt));
           iclose ();
           mysql_thread_end ();
-          MUTEX_UNLOCK (lock);
-          return SYSERR;
+          GNUNET_mutex_unlock (lock);
+          return GNUNET_SYSERR;
         }
       if (mysql_stmt_execute (stmt))
         {
@@ -1245,9 +1250,9 @@
                   "mysql_stmt_execute",
                   __FILE__, __LINE__, mysql_stmt_error (stmt));
           iclose ();
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           mysql_thread_end ();
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (mysql_stmt_bind_result (stmt, rbind))
         {
@@ -1258,13 +1263,13 @@
                   __FILE__, __LINE__, mysql_stmt_error (stmt));
           iclose ();
           mysql_thread_end ();
-          MUTEX_UNLOCK (lock);
-          return SYSERR;
+          GNUNET_mutex_unlock (lock);
+          return GNUNET_SYSERR;
         }
       if (0 != mysql_stmt_fetch (stmt))
         {
           mysql_stmt_reset (stmt);
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           break;
         }
       last_vkey = vkey;
@@ -1273,31 +1278,31 @@
           count = mysql_stmt_affected_rows (stmt);
           mysql_stmt_reset (stmt);
           mysql_thread_end ();
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
 
           return count;
         }
       mysql_stmt_reset (stmt);
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       datum = assembleDatum (rbind);
       if (datum == NULL)
         continue;
       count++;
       ret = iter (&key, datum, closure, vkey);
-      if (ret == SYSERR)
+      if (ret == GNUNET_SYSERR)
         {
-          FREE (datum);
+          GNUNET_free (datum);
           break;
         }
-      if (ret == NO)
+      if (ret == GNUNET_NO)
         {
-          MUTEX_LOCK (lock);
+          GNUNET_mutex_lock (lock);
           delete_value (vkey);
           delete_entry_by_vkey (vkey);
           content_size -= ntohl (datum->size);
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
         }
-      FREE (datum);
+      GNUNET_free (datum);
     }
   mysql_thread_end ();
   return count;
@@ -1308,30 +1313,30 @@
  * in the datastore.
  */
 static int
-update (unsigned long long vkey, int delta, cron_t expire)
+update (unsigned long long vkey, int delta, GNUNET_CronTime expire)
 {
-  cron_t start;
+  GNUNET_CronTime start;
   MYSQL_BIND qbind[4];
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   mysql_thread_init ();
-  if (OK != CHECK_DBH)
+  if (GNUNET_OK != CHECK_DBH)
     {
       mysql_thread_end ();
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   memset (qbind, 0, sizeof (qbind));
   qbind[0].buffer_type = MYSQL_TYPE_LONG;
   qbind[0].buffer = &delta;
   qbind[1].buffer_type = MYSQL_TYPE_LONGLONG;
   qbind[1].buffer = &expire;
-  qbind[1].is_unsigned = YES;
+  qbind[1].is_unsigned = GNUNET_YES;
   qbind[2].buffer_type = MYSQL_TYPE_LONGLONG;
-  qbind[2].is_unsigned = YES;
+  qbind[2].is_unsigned = GNUNET_YES;
   qbind[2].buffer = &expire;
   qbind[3].buffer_type = MYSQL_TYPE_LONGLONG;
-  qbind[3].is_unsigned = YES;
+  qbind[3].is_unsigned = GNUNET_YES;
   qbind[3].buffer = &vkey;
   GE_ASSERT (ectx, mysql_stmt_param_count (dbh->update_entry) == 4);
   if (mysql_stmt_bind_param (dbh->update_entry, qbind))
@@ -1343,15 +1348,15 @@
               __FILE__, __LINE__, mysql_stmt_error (dbh->update_entry));
       iclose ();
       mysql_thread_end ();
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   /* NOTE: as the table entry for 'prio' is defined as unsigned,
    * mysql will zero the value if its about to go negative. (This
    * will generate a warning though, but its probably not seen
    * at all in this context.)
    */
-  start = get_time ();
+  start = GNUNET_get_time ();
   if (mysql_stmt_execute (dbh->update_entry))
     {
       GE_LOG (ectx,
@@ -1359,16 +1364,17 @@
               _("`%s' failed at %s:%d with error `%s' after %llums\n"),
               "mysql_stmt_execute",
               __FILE__, __LINE__,
-              mysql_stmt_error (dbh->update_entry), get_time () - start);
+              mysql_stmt_error (dbh->update_entry),
+              GNUNET_get_time () - start);
       iclose ();
       mysql_thread_end ();
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   mysql_stmt_reset (dbh->update_entry);
   mysql_thread_end ();
-  MUTEX_UNLOCK (lock);
-  return OK;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 
@@ -1383,11 +1389,11 @@
 {
   unsigned long long ret;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   ret = content_size;
   if (stats)
     stats->set (stat_size, ret);
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return ret * 1.2;
 }
 
@@ -1400,32 +1406,32 @@
 {
   int ok;
 
-  ok = YES;
-  MUTEX_LOCK (lock);
+  ok = GNUNET_YES;
+  GNUNET_mutex_lock (lock);
   mysql_thread_init ();
-  if (OK != CHECK_DBH)
+  if (GNUNET_OK != CHECK_DBH)
     {
       mysql_thread_end ();
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       return;
     }
   mysql_query (dbh->dbf, "DROP TABLE gn071");
   if (mysql_error (dbh->dbf)[0])
     {
       LOG_MYSQL (GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", dbh);
-      ok = NO;
+      ok = GNUNET_NO;
     }
   mysql_query (dbh->dbf, "DROP TABLE gn072");
   if (mysql_error (dbh->dbf)[0])
     {
       LOG_MYSQL (GE_ERROR | GE_ADMIN | GE_BULK, "mysql_query", dbh);
-      ok = NO;
+      ok = GNUNET_NO;
     }
-  if (ok == YES)
+  if (ok == GNUNET_YES)
     content_size = 0;
   iclose ();
   mysql_thread_end ();
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 SQstore_ServiceAPI *
@@ -1453,18 +1459,18 @@
   pw = getpwuid (getuid ());
   if (!pw)
     GE_DIE_STRERROR (ectx, GE_FATAL | GE_ADMIN | GE_IMMEDIATE, "getpwuid");
-  home_dir = STRDUP (pw->pw_dir);
+  home_dir = GNUNET_strdup (pw->pw_dir);
 #else
-  home_dir = (char *) MALLOC (_MAX_PATH + 1);
+  home_dir = (char *) GNUNET_malloc (_MAX_PATH + 1);
   plibc_conv_to_win_path ("~/", home_dir);
 #endif
   nX = strlen (home_dir) + 10;
-  cnffile = MALLOC (nX);
-  SNPRINTF (cnffile, nX, "%s/.my.cnf", home_dir);
-  FREE (home_dir);
+  cnffile = GNUNET_malloc (nX);
+  GNUNET_snprintf (cnffile, nX, "%s/.my.cnf", home_dir);
+  GNUNET_free (home_dir);
   GC_get_configuration_value_filename (capi->cfg,
                                        "MYSQL", "CONFIG", cnffile, &home_dir);
-  FREE (cnffile);
+  GNUNET_free (cnffile);
   cnffile = home_dir;
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
@@ -1476,20 +1482,20 @@
                             GE_ERROR | GE_ADMIN | GE_BULK, "fopen", cnffile);
       if (stats != NULL)
         coreAPI->releaseService (stats);
-      FREE (cnffile);
+      GNUNET_free (cnffile);
       return NULL;
     }
   else
     {
       fclose (fp);
     }
-  dbh = MALLOC (sizeof (mysqlHandle));
+  dbh = GNUNET_malloc (sizeof (mysqlHandle));
   memset (dbh, 0, sizeof (mysqlHandle));
   dbh->cnffile = cnffile;
-  if (OK != iopen ())
+  if (GNUNET_OK != iopen ())
     {
-      FREE (cnffile);
-      FREE (dbh);
+      GNUNET_free (cnffile);
+      GNUNET_free (dbh);
       GE_LOG (ectx,
               GE_ERROR | GE_BULK | GE_USER,
               _
@@ -1500,7 +1506,7 @@
       return NULL;
     }
 
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
   state = coreAPI->requestService ("state");
   sb = NULL;
   if (sizeof (unsigned long long)
@@ -1539,7 +1545,7 @@
   else
     {
       content_size = *sb;
-      FREE (sb);
+      GNUNET_free (sb);
       /* no longer valid! remember it by deleting
          the outdated state file! */
       state->unlink (ectx, "mysql-size");
@@ -1567,12 +1573,12 @@
   State_ServiceAPI *state;
 
   iclose (dbh);
-  FREE (dbh->cnffile);
-  FREE (dbh);
+  GNUNET_free (dbh->cnffile);
+  GNUNET_free (dbh);
   dbh = NULL;
   if (stats != NULL)
     coreAPI->releaseService (stats);
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   state = coreAPI->requestService ("state");
   state->write (ectx,
                 "mysql-size", sizeof (unsigned long long), &content_size);
@@ -1600,18 +1606,18 @@
   pw = getpwuid (getuid ());
   if (!pw)
     GE_DIE_STRERROR (ectx, GE_FATAL | GE_ADMIN | GE_IMMEDIATE, "getpwuid");
-  home_dir = STRDUP (pw->pw_dir);
+  home_dir = GNUNET_strdup (pw->pw_dir);
 #else
-  home_dir = (char *) MALLOC (_MAX_PATH + 1);
+  home_dir = (char *) GNUNET_malloc (_MAX_PATH + 1);
   plibc_conv_to_win_path ("~/", home_dir);
 #endif
   nX = strlen (home_dir) + 10;
-  cnffile = MALLOC (nX);
-  SNPRINTF (cnffile, nX, "%s/.my.cnf", home_dir);
-  FREE (home_dir);
+  cnffile = GNUNET_malloc (nX);
+  GNUNET_snprintf (cnffile, nX, "%s/.my.cnf", home_dir);
+  GNUNET_free (home_dir);
   GC_get_configuration_value_filename (uapi->cfg,
                                        "MYSQL", "CONFIG", cnffile, &home_dir);
-  FREE (cnffile);
+  GNUNET_free (cnffile);
   cnffile = home_dir;
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
@@ -1621,20 +1627,20 @@
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_ERROR | GE_ADMIN | GE_BULK, "fopen", cnffile);
-      FREE (cnffile);
+      GNUNET_free (cnffile);
       return;
     }
   else
     {
       fclose (fp);
     }
-  dbh = MALLOC (sizeof (mysqlHandle));
+  dbh = GNUNET_malloc (sizeof (mysqlHandle));
   memset (dbh, 0, sizeof (mysqlHandle));
   dbh->cnffile = cnffile;
-  if (OK != iopen ())
+  if (GNUNET_OK != iopen ())
     {
-      FREE (cnffile);
-      FREE (dbh);
+      GNUNET_free (cnffile);
+      GNUNET_free (dbh);
       GE_LOG (ectx,
               GE_ERROR | GE_BULK | GE_USER,
               _
@@ -1653,8 +1659,8 @@
     mysql_query (dbh->dbf, "DROP TABLE gn070");
 
   iclose (dbh);
-  FREE (dbh->cnffile);
-  FREE (dbh);
+  GNUNET_free (dbh->cnffile);
+  GNUNET_free (dbh);
   dbh = NULL;
   mysql_library_end ();
   ectx = NULL;

Modified: GNUnet/src/applications/sqstore_mysql/mysqltest.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysqltest.c   2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/sqstore_mysql/mysqltest.c   2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -33,25 +33,25 @@
 
 #define ASSERT(x) do { if (! (x)) { printf("Error at %s:%d\n", __FILE__, 
__LINE__); goto FAILURE;} } while (0)
 
-static cron_t now;
+static GNUNET_CronTime now;
 
 static Datastore_Value *
 initValue (int i)
 {
   Datastore_Value *value;
 
-  value = MALLOC (sizeof (Datastore_Value) + 8 * i);
+  value = GNUNET_malloc (sizeof (Datastore_Value) + 8 * i);
   value->size = htonl (sizeof (Datastore_Value) + 8 * i);
   value->type = htonl (i);
   value->prio = htonl (i + 1);
   value->anonymityLevel = htonl (i);
-  value->expirationTime = htonll (now - i * cronSECONDS);
+  value->expirationTime = GNUNET_htonll (now - i * GNUNET_CRON_SECONDS);
   memset (&value[1], i, 8 * i);
   return value;
 }
 
 static int
-checkValue (const HashCode512 * key,
+checkValue (const GNUNET_HashCode * key,
             const Datastore_Value * val, void *closure,
             unsigned long long uid)
 {
@@ -63,23 +63,23 @@
   value = initValue (i);
   if ((value->size == val->size) &&
       (0 == memcmp (val, value, ntohl (val->size))))
-    ret = OK;
+    ret = GNUNET_OK;
   else
     {
       /*
          printf("Wanted: %u, %llu; got %u, %llu - %d\n",
-         ntohl(value->size), ntohll(value->expirationTime),
-         ntohl(val->size), ntohll(val->expirationTime),
+         ntohl(value->size), GNUNET_ntohll(value->expirationTime),
+         ntohl(val->size), GNUNET_ntohll(val->expirationTime),
          memcmp(val, value, ntohl(val->size))); */
-      ret = SYSERR;
+      ret = GNUNET_SYSERR;
     }
-  FREE (value);
+  GNUNET_free (value);
   return ret;
 }
 
 static int
-iterateUp (const HashCode512 * key, const Datastore_Value * val, int *closure,
-           unsigned long long uid)
+iterateUp (const GNUNET_HashCode * key, const Datastore_Value * val,
+           int *closure, unsigned long long uid)
 {
   int ret;
 
@@ -89,7 +89,7 @@
 }
 
 static int
-iterateDown (const HashCode512 * key,
+iterateDown (const GNUNET_HashCode * key,
              const Datastore_Value * val, int *closure,
              unsigned long long uid)
 {
@@ -101,24 +101,24 @@
 }
 
 static int
-iterateDelete (const HashCode512 * key,
+iterateDelete (const GNUNET_HashCode * key,
                const Datastore_Value * val, void *closure,
                unsigned long long uid)
 {
-  return NO;
+  return GNUNET_NO;
 }
 
 static int
-iteratePriority (const HashCode512 * key,
+iteratePriority (const GNUNET_HashCode * key,
                  const Datastore_Value * val, SQstore_ServiceAPI * api,
                  unsigned long long uid)
 {
   api->update (uid, 4, 0);
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
-priorityCheck (const HashCode512 * key,
+priorityCheck (const GNUNET_HashCode * key,
                const Datastore_Value * val, int *closure,
                unsigned long long uid)
 {
@@ -126,13 +126,13 @@
 
   id = (*closure);
   if (id + 1 == ntohl (val->prio))
-    return OK;
+    return GNUNET_OK;
   else
-    return SYSERR;
+    return GNUNET_SYSERR;
 }
 
 static int
-multipleCheck (const HashCode512 * key,
+multipleCheck (const GNUNET_HashCode * key,
                const Datastore_Value * val, Datastore_Value ** last,
                unsigned long long uid)
 {
@@ -140,12 +140,12 @@
     {
       if (((*last)->size == val->size) &&
           (0 == memcmp (*last, val, ntohl (val->size))))
-        return SYSERR;          /* duplicate! */
-      FREE (*last);
+        return GNUNET_SYSERR;   /* duplicate! */
+      GNUNET_free (*last);
     }
-  *last = MALLOC (ntohl (val->size));
+  *last = GNUNET_malloc (ntohl (val->size));
   memcpy (*last, val, ntohl (val->size));
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -156,7 +156,7 @@
 test (SQstore_ServiceAPI * api)
 {
   Datastore_Value *value;
-  HashCode512 key;
+  GNUNET_HashCode key;
   unsigned long long oldSize;
   int i;
 
@@ -165,26 +165,26 @@
   for (i = 0; i < 256; i++)
     {
       value = initValue (i);
-      memset (&key, 256 - i, sizeof (HashCode512));
-      ASSERT (OK == api->put (&key, value));
-      FREE (value);
+      memset (&key, 256 - i, sizeof (GNUNET_HashCode));
+      ASSERT (GNUNET_OK == api->put (&key, value));
+      GNUNET_free (value);
     }
   ASSERT (oldSize < api->getSize ());
   ASSERT (256 == api->iterateLowPriority (ANY_BLOCK, NULL, NULL));
   ASSERT (256 == api->iterateExpirationTime (ANY_BLOCK, NULL, NULL));
   for (i = 255; i >= 0; i--)
     {
-      memset (&key, 256 - i, sizeof (HashCode512));
+      memset (&key, 256 - i, sizeof (GNUNET_HashCode));
       ASSERT (1 == api->get (&key, i, &checkValue, (void *) &i));
     }
 
   oldSize = api->getSize ();
   for (i = 255; i >= 0; i -= 2)
     {
-      memset (&key, 256 - i, sizeof (HashCode512));
+      memset (&key, 256 - i, sizeof (GNUNET_HashCode));
       value = initValue (i);
       ASSERT (1 == api->get (&key, 0, &iterateDelete, NULL));
-      FREE (value);
+      GNUNET_free (value);
     }
   ASSERT (oldSize > api->getSize ());
   i = 0;
@@ -204,7 +204,7 @@
 
   i = 42;
   value = initValue (i);
-  memset (&key, 256 - i, sizeof (HashCode512));
+  memset (&key, 256 - i, sizeof (GNUNET_HashCode));
   api->put (&key, value);
   ASSERT (1 == api->iterateExpirationTime (ANY_BLOCK,
                                            (Datum_Iterator) & priorityCheck,
@@ -214,27 +214,27 @@
   ASSERT (1 == api->iterateExpirationTime (ANY_BLOCK,
                                            (Datum_Iterator) & priorityCheck,
                                            &i));
-  FREE (value);
+  GNUNET_free (value);
 
   /* test multiple results */
   value = initValue (i + 1);
   api->put (&key, value);
-  FREE (value);
+  GNUNET_free (value);
 
   value = NULL;
   ASSERT (2 == api->iterateExpirationTime (ANY_BLOCK,
                                            (Datum_Iterator) & multipleCheck,
                                            &value));
-  FREE (value);
+  GNUNET_free (value);
   ASSERT (2 == api->iterateAllNow ((Datum_Iterator) & iterateDelete, api));
   ASSERT (0 == api->iterateExpirationTime (ANY_BLOCK, NULL, NULL));
   api->drop ();
 
-  return OK;
+  return GNUNET_OK;
 
 FAILURE:
   api->drop ();
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 int
@@ -243,9 +243,9 @@
   SQstore_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);
@@ -260,11 +260,11 @@
       releaseService (api);
     }
   else
-    ok = SYSERR;
+    ok = GNUNET_SYSERR;
   doneCore ();
-  cron_destroy (cron);
+  GNUNET_cron_destroy (cron);
   GC_free (cfg);
-  if (ok == SYSERR)
+  if (ok == GNUNET_SYSERR)
     return 1;
   return 0;
 }

Modified: GNUnet/src/applications/sqstore_mysql/mysqltest2.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysqltest2.c  2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/sqstore_mysql/mysqltest2.c  2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -85,10 +85,10 @@
 #define MAX_SIZE 1024LL * 1024 * 16
 
 /**
- * Report progress outside of major reports? Should probably be YES if
+ * Report progress outside of major reports? Should probably be GNUNET_YES if
  * size is > 16 MB.
  */
-#define REPORT_ID NO
+#define REPORT_ID GNUNET_NO
 
 /**
  * Number of put operations equivalent to 1/10th of MAX_SIZE
@@ -121,36 +121,40 @@
 
 static unsigned long long stored_ops;
 
-static cron_t start_time;
+static GNUNET_CronTime start_time;
 
 static int
 putValue (SQstore_ServiceAPI * api, int i)
 {
   Datastore_Value *value;
   size_t size;
-  static HashCode512 key;
+  static GNUNET_HashCode key;
   static int ic;
 
   /* most content is 32k */
   size = sizeof (Datastore_Value) + 32 * 1024;
-  if (weak_randomi (16) == 0)   /* but some of it is less! */
-    size = sizeof (Datastore_Value) + weak_randomi (32 * 1024);
+  if (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 16) == 0)  /* but some of 
it is less! */
+    size =
+      sizeof (Datastore_Value) +
+      GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 32 * 1024);
   size = size - (size & 7);     /* always multiple of 8 */
 
   /* generate random key */
-  hash (&key, sizeof (HashCode512), &key);
-  value = MALLOC (size);
+  GNUNET_hash (&key, sizeof (GNUNET_HashCode), &key);
+  value = GNUNET_malloc (size);
   value->size = htonl (size);
   value->type = htonl (i);
-  value->prio = htonl (weak_randomi (100));
+  value->prio = htonl (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 100));
   value->anonymityLevel = htonl (i);
-  value->expirationTime = htonll (get_time () + weak_randomi (1000));
+  value->expirationTime =
+    GNUNET_htonll (GNUNET_get_time () +
+                   GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 1000));
   memset (&value[1], i, size - sizeof (Datastore_Value));
-  if (OK != api->put (&key, value))
+  if (GNUNET_OK != api->put (&key, value))
     {
-      FREE (value);
+      GNUNET_free (value);
       fprintf (stderr, "E");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   ic++;
 #if REPORT_ID
@@ -160,21 +164,21 @@
   stored_bytes += ntohl (value->size);
   stored_ops++;
   stored_entries++;
-  FREE (value);
-  return OK;
+  GNUNET_free (value);
+  return GNUNET_OK;
 }
 
 static int
-iterateDelete (const HashCode512 * key,
+iterateDelete (const GNUNET_HashCode * key,
                const Datastore_Value * val, void *cls, unsigned long long uid)
 {
   SQstore_ServiceAPI *api = cls;
   static int dc;
 
   if (api->getSize () < MAX_SIZE)
-    return SYSERR;
-  if (GNUNET_SHUTDOWN_TEST () == YES)
-    return SYSERR;
+    return GNUNET_SYSERR;
+  if (GNUNET_shutdown_test () == GNUNET_YES)
+    return GNUNET_SYSERR;
   dc++;
 #if REPORT_ID
   if (dc % REP_FREQ == 0)
@@ -182,7 +186,7 @@
 #endif
   stored_bytes -= ntohl (val->size);
   stored_entries--;
-  return NO;
+  return GNUNET_NO;
 }
 
 /**
@@ -207,8 +211,8 @@
       /* insert data equivalent to 1/10th of MAX_SIZE */
       for (j = 0; j < PUT_10; j++)
         {
-          ASSERT (OK == putValue (api, j));
-          if (GNUNET_SHUTDOWN_TEST () == YES)
+          ASSERT (GNUNET_OK == putValue (api, j));
+          if (GNUNET_shutdown_test () == GNUNET_YES)
             break;
         }
 
@@ -220,7 +224,7 @@
 
       size = 0;
       if (have_file)
-        disk_file_size (NULL, DB_NAME, &size, NO);
+        GNUNET_disk_file_size (NULL, DB_NAME, &size, GNUNET_NO);
       printf (
 #if REPORT_ID
                "\n"
@@ -230,16 +234,16 @@
                size / 1024,     /* disk size in kb */
                (100.0 * size / stored_bytes) - 100,     /* overhead */
                (stored_ops * 2 - stored_entries) / 1024,        /* total 
operations (in k) */
-               1000 * (stored_ops * 2 - stored_entries) / (1 + get_time () - 
start_time));      /* operations per second */
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+               1000 * (stored_ops * 2 - stored_entries) / (1 + GNUNET_get_time 
() - start_time));       /* operations per second */
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   api->drop ();
-  return OK;
+  return GNUNET_OK;
 
 FAILURE:
   api->drop ();
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 int
@@ -248,9 +252,9 @@
   SQstore_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);
@@ -261,16 +265,16 @@
   api = requestService ("sqstore");
   if (api != NULL)
     {
-      start_time = get_time ();
+      start_time = GNUNET_get_time ();
       ok = test (api);
       releaseService (api);
     }
   else
-    ok = SYSERR;
+    ok = GNUNET_SYSERR;
   doneCore ();
-  cron_destroy (cron);
+  GNUNET_cron_destroy (cron);
   GC_free (cfg);
-  if (ok == SYSERR)
+  if (ok == GNUNET_SYSERR)
     return 1;
   return 0;
 }

Modified: GNUnet/src/applications/sqstore_mysql/mysqltest3.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysqltest3.c  2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/sqstore_mysql/mysqltest3.c  2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -53,55 +53,58 @@
 
 static unsigned long long stored_ops;
 
-static cron_t start_time;
+static GNUNET_CronTime start_time;
 
 static int
 putValue (SQstore_ServiceAPI * api, int i)
 {
   Datastore_Value *value;
   size_t size;
-  static HashCode512 key;
+  static GNUNET_HashCode key;
   static int ic;
 
   /* most content is 32k */
   size = sizeof (Datastore_Value) + 32 * 1024;
 
-  if (weak_randomi (16) == 0)   /* but some of it is less! */
-    size = sizeof (Datastore_Value) + weak_randomi (32 * 1024);
+  if (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 16) == 0)  /* but some of 
it is less! */
+    size =
+      sizeof (Datastore_Value) +
+      GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 32 * 1024);
   size = size - (size & 7);     /* always multiple of 8 */
 
   /* generate random key */
-  key.bits[0] = (unsigned int) get_time ();
-  hash (&key, sizeof (HashCode512), &key);
-  value = MALLOC (size);
+  key.bits[0] = (unsigned int) GNUNET_get_time ();
+  GNUNET_hash (&key, sizeof (GNUNET_HashCode), &key);
+  value = GNUNET_malloc (size);
   value->size = htonl (size);
   value->type = htonl (i);
-  value->prio = htonl (weak_randomi (100));
+  value->prio = htonl (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 100));
   value->anonymityLevel = htonl (i);
   value->expirationTime =
-    htonll (get_time () + 60 * cronHOURS + weak_randomi (1000));
+    GNUNET_htonll (GNUNET_get_time () + 60 * GNUNET_CRON_HOURS +
+                   GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 1000));
   memset (&value[1], i, size - sizeof (Datastore_Value));
-  if (OK != api->put (&key, value))
+  if (GNUNET_OK != api->put (&key, value))
     {
-      FREE (value);
+      GNUNET_free (value);
       fprintf (stderr, "E");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   ic++;
   stored_bytes += ntohl (value->size);
   stored_ops++;
   stored_entries++;
-  FREE (value);
-  return OK;
+  GNUNET_free (value);
+  return GNUNET_OK;
 }
 
 static int
-iterateDummy (const HashCode512 * key, const Datastore_Value * val, void *cls,
-              unsigned long long uid)
+iterateDummy (const GNUNET_HashCode * key, const Datastore_Value * val,
+              void *cls, unsigned long long uid)
 {
-  if (GNUNET_SHUTDOWN_TEST () == YES)
-    return SYSERR;
-  return OK;
+  if (GNUNET_shutdown_test () == GNUNET_YES)
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 static int
@@ -110,62 +113,62 @@
   int i;
   int j;
   int ret;
-  cron_t start;
-  cron_t end;
+  GNUNET_CronTime start;
+  GNUNET_CronTime end;
 
   for (i = 0; i < ITERATIONS; i++)
     {
       /* insert data equivalent to 1/10th of MAX_SIZE */
-      start = get_time ();
+      start = GNUNET_get_time ();
       for (j = 0; j < PUT_10; j++)
         {
-          if (OK != putValue (api, j))
+          if (GNUNET_OK != putValue (api, j))
             break;
-          if (GNUNET_SHUTDOWN_TEST () == YES)
+          if (GNUNET_shutdown_test () == GNUNET_YES)
             break;
         }
-      end = get_time ();
+      end = GNUNET_get_time ();
       printf ("%3u insertion              took %20llums\n", i, end - start);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
-      start = get_time ();
+      start = GNUNET_get_time ();
       ret = api->iterateLowPriority (0, &iterateDummy, api);
-      end = get_time ();
+      end = GNUNET_get_time ();
       printf ("%3u low priority iteration took %20llums (%d)\n", i,
               end - start, ret);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
-      start = get_time ();
+      start = GNUNET_get_time ();
       ret = api->iterateExpirationTime (0, &iterateDummy, api);
-      end = get_time ();
+      end = GNUNET_get_time ();
       printf ("%3u expiration t iteration took %20llums (%d)\n", i,
               end - start, ret);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
-      start = get_time ();
+      start = GNUNET_get_time ();
       ret = api->iterateNonAnonymous (0, &iterateDummy, api);
-      end = get_time ();
+      end = GNUNET_get_time ();
       printf ("%3u non anonymou iteration took %20llums (%d)\n", i,
               end - start, ret);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
-      start = get_time ();
+      start = GNUNET_get_time ();
       ret = api->iterateMigrationOrder (&iterateDummy, api);
-      end = get_time ();
+      end = GNUNET_get_time ();
       printf ("%3u migration or iteration took %20llums (%d)\n", i,
               end - start, ret);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
-      start = get_time ();
+      start = GNUNET_get_time ();
       ret = api->iterateAllNow (&iterateDummy, api);
-      end = get_time ();
+      end = GNUNET_get_time ();
       printf ("%3u all now      iteration took %20llums (%d)\n", i,
               end - start, ret);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   api->drop ();
-  return OK;
+  return GNUNET_OK;
 }
 
 int
@@ -174,9 +177,9 @@
   SQstore_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);
@@ -187,16 +190,16 @@
   api = requestService ("sqstore");
   if (api != NULL)
     {
-      start_time = get_time ();
+      start_time = GNUNET_get_time ();
       ok = test (api);
       releaseService (api);
     }
   else
-    ok = SYSERR;
+    ok = GNUNET_SYSERR;
   doneCore ();
-  cron_destroy (cron);
+  GNUNET_cron_destroy (cron);
   GC_free (cfg);
-  if (ok == SYSERR)
+  if (ok == GNUNET_SYSERR)
     return 1;
   return 0;
 }

Modified: GNUnet/src/applications/sqstore_sqlite/Makefile.am
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/Makefile.am  2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/sqstore_sqlite/Makefile.am  2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -32,7 +32,6 @@
  sqlitetest.c 
 sqlitetest_LDADD = \
  $(top_builddir)/src/server/libgnunetcore.la  \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
  $(top_builddir)/src/util/libgnunetutil.la  
 
 
@@ -40,7 +39,6 @@
  sqlitetest2.c 
 sqlitetest2_LDADD = \
  $(top_builddir)/src/server/libgnunetcore.la  \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  \
  $(top_builddir)/src/util/libgnunetutil.la  
 
 
@@ -49,5 +47,4 @@
  sqlitetest3.c 
 sqlitetest3_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/sqstore_sqlite/sqlite.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlite.c     2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/sqstore_sqlite/sqlite.c     2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -37,7 +37,7 @@
 #include "gnunet_stats_service.h"
 #include <sqlite3.h>
 
-#define DEBUG_SQLITE NO
+#define DEBUG_SQLITE GNUNET_NO
 
 /**
  * Die with an error message that indicates
@@ -56,13 +56,13 @@
 /* These selects basically work in the same way as the old MySQL selects do. 
But because the
    reverse ordering kills performance, we are using subselects with MAX() for 
SQLite instead.
 
-#define SELECT_IT_NON_ANONYMOUS "SELECT size, type, prio, anonLevel, expire, 
hash, value, _ROWID_ FROM gn070 WHERE ( (prio = ? AND hash < ?) OR (prio < ? 
AND hash != ?) ) "\
+#define SELECT_IT_NON_ANONYMOUS "SELECT size, type, prio, anonLevel, expire, 
GNUNET_hash, value, _ROWID_ FROM gn070 WHERE ( (prio = ? AND GNUNET_hash < ?) 
OR (prio < ? AND GNUNET_hash != ?) ) "\
                                 "AND anonLevel=0 AND type not in (4294967294, 
4294967295) "\
-                                "ORDER BY prio DESC,hash DESC LIMIT 1"
+                                "ORDER BY prio DESC,GNUNET_hash DESC LIMIT 1"
 
-#define SELECT_IT_MIGRATION_ORDER "SELECT size, type, prio, anonLevel, expire, 
hash, value, _ROWID_ FROM gn070 WHERE ( (expire = ? AND hash < ?) OR (expire < 
? AND hash != ?) ) "\
+#define SELECT_IT_MIGRATION_ORDER "SELECT size, type, prio, anonLevel, expire, 
GNUNET_hash, value, _ROWID_ FROM gn070 WHERE ( (expire = ? AND GNUNET_hash < ?) 
OR (expire < ? AND GNUNET_hash != ?) ) "\
                                   "AND expire > ? AND type!=3 "\
-                                  "ORDER BY expire DESC,hash DESC LIMIT 1" 
+                                  "ORDER BY expire DESC,GNUNET_hash DESC LIMIT 
1"
 */
 
 #define SELECT_IT_LOW_PRIORITY "SELECT size, type, prio, anonLevel, expire, 
hash, value, _ROWID_ FROM gn070 WHERE " \
@@ -114,7 +114,7 @@
   /**
    * Thread ID owning this handle
    */
-  struct PTHREAD *tid;
+  struct GNUNET_ThreadHandle *tid;
 
   /**
    * Precompiled SQL
@@ -136,7 +136,7 @@
 
 static struct GE_Context *ectx;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 static char *fn;
 
@@ -225,11 +225,11 @@
 
   /* Is the DB already open? */
   for (idx = 0; idx < handle_count; idx++)
-    if (PTHREAD_TEST_SELF (handles[idx]->tid))
+    if (GNUNET_thread_test_self (handles[idx]->tid))
       return handles[idx];
 
   /* we haven't opened the DB for this thread yet */
-  ret = MALLOC (sizeof (sqliteHandle));
+  ret = GNUNET_malloc (sizeof (sqliteHandle));
   /* Open database and precompile statements */
   if (sqlite3_open (fn, &ret->dbh) != SQLITE_OK)
     {
@@ -238,7 +238,7 @@
               _("Unable to initialize SQLite: %s.\n"),
               sqlite3_errmsg (ret->dbh));
       sqlite3_close (ret->dbh);
-      FREE (ret);
+      GNUNET_free (ret);
       return NULL;
     }
 
@@ -279,7 +279,7 @@
                       GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
                       "sqlite_create");
           sqlite3_finalize (stmt);
-          FREE (ret);
+          GNUNET_free (ret);
           return NULL;
         }
       createIndices (ret->dbh);
@@ -313,11 +313,11 @@
         sqlite3_finalize (ret->updPrio);
       if (ret->insertContent != NULL)
         sqlite3_finalize (ret->insertContent);
-      FREE (ret);
+      GNUNET_free (ret);
       return NULL;
     }
-  ret->tid = PTHREAD_GET_SELF ();
-  APPEND (handles, handle_count, ret);
+  ret->tid = GNUNET_thread_get_self ();
+  GNUNET_array_append (handles, handle_count, ret);
   return ret;
 }
 
@@ -349,17 +349,17 @@
  * Get a (good) estimate of the size of the given
  * value (and its key) in the datastore.<p>
  * <pre>
- * row length = hash length + block length + numbers + column count + 
estimated index size + 1
+ * row length = GNUNET_hash length + block length + numbers + column count + 
estimated index size + 1
  * </pre>
  */
 static unsigned int
 getContentDatastoreSize (const Datastore_Value * value)
 {
-  return sizeof (HashCode512) + ntohl (value->size) - sizeof (Datastore_Value)
-    + getIntSize (ntohl (value->size)) + getIntSize (ntohl (value->type)) +
-    getIntSize (ntohl (value->prio)) +
+  return sizeof (GNUNET_HashCode) + ntohl (value->size) -
+    sizeof (Datastore_Value) + getIntSize (ntohl (value->size)) +
+    getIntSize (ntohl (value->type)) + getIntSize (ntohl (value->prio)) +
     getIntSize (ntohl (value->anonymityLevel)) +
-    getIntSize (ntohll (value->expirationTime)) + 7 + 245 + 1;
+    getIntSize (GNUNET_ntohll (value->expirationTime)) + 7 + 245 + 1;
 }
 
 
@@ -375,11 +375,11 @@
 {
   double ret;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   ret = payload;
   if (stats)
     stats->set (stat_size, ret);
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return (unsigned long long) (ret * 1.13);
   /* benchmarking shows 13% overhead */
 }
@@ -394,7 +394,7 @@
     {
       LOG_SQLITE (handle,
                   GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "sq_prepare");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   sqlite3_bind_int64 (stmt, 1, rid);
   if (SQLITE_DONE != sqlite3_step (stmt))
@@ -402,19 +402,19 @@
       LOG_SQLITE (handle,
                   GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "sqlite3_step");
       sqlite3_finalize (stmt);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   sqlite3_finalize (stmt);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
- * Given a full row from gn070 table 
(size,type,prio,anonLevel,expire,hash,value),
+ * Given a full row from gn070 table 
(size,type,prio,anonLevel,expire,GNUNET_hash,value),
  * assemble it into a Datastore_Value representation.
  */
 static Datastore_Value *
 assembleDatum (sqliteHandle * handle, sqlite3_stmt * stmt,
-               HashCode512 * key, unsigned long long *rowid)
+               GNUNET_HashCode * key, unsigned long long *rowid)
 {
   Datastore_Value *value;
   int contentSize;
@@ -465,7 +465,7 @@
       return NULL;              /* error */
     }
 
-  if (sqlite3_column_bytes (stmt, 5) != sizeof (HashCode512) ||
+  if (sqlite3_column_bytes (stmt, 5) != sizeof (GNUNET_HashCode) ||
       sqlite3_column_bytes (stmt, 6) != contentSize)
     {
       sqlite3_stmt *stmtd;
@@ -481,9 +481,9 @@
                       "DELETE FROM gn070 WHERE NOT ((LENGTH(hash) = ?) AND 
(size = LENGTH(value) + ?))",
                       &stmtd) == SQLITE_OK)
         {
-          if (SQLITE_OK != sqlite3_bind_int (stmtd, 1, sizeof (HashCode512)))
-            LOG_SQLITE (handle,
-                        GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+          if (SQLITE_OK !=
+              sqlite3_bind_int (stmtd, 1, sizeof (GNUNET_HashCode)))
+            LOG_SQLITE (handle, GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
                         "sqlite3_bind_int");
           if (SQLITE_OK !=
               sqlite3_bind_int (stmtd, 2, sizeof (Datastore_Value)))
@@ -505,13 +505,13 @@
       return NULL;
     }
 
-  value = MALLOC (sizeof (Datastore_Value) + contentSize);
+  value = GNUNET_malloc (sizeof (Datastore_Value) + contentSize);
   value->size = htonl (contentSize + sizeof (Datastore_Value));
   value->type = htonl (type);
   value->prio = htonl (sqlite3_column_int (stmt, 2));
   value->anonymityLevel = htonl (sqlite3_column_int (stmt, 3));
-  value->expirationTime = htonll (sqlite3_column_int64 (stmt, 4));
-  memcpy (key, sqlite3_column_blob (stmt, 5), sizeof (HashCode512));
+  value->expirationTime = GNUNET_htonll (sqlite3_column_int64 (stmt, 4));
+  memcpy (key, sqlite3_column_blob (stmt, 5), sizeof (GNUNET_HashCode));
   memcpy (&value[1], sqlite3_column_blob (stmt, 6), contentSize);
   return value;
 }
@@ -520,14 +520,14 @@
 /**
  * @brief Get database statistics
  * @param key kind of stat to retrieve
- * @return SYSERR on error, the value otherwise
+ * @return GNUNET_SYSERR on error, the value otherwise
  */
 static unsigned long long
 getStat (sqliteHandle * handle, const char *key)
 {
   int i;
   sqlite3_stmt *stmt;
-  unsigned long long ret = SYSERR;
+  unsigned long long ret = GNUNET_SYSERR;
 
   i = sq_prepare (handle->dbh,
                   "SELECT expire FROM gn070 WHERE hash = ?", &stmt);
@@ -549,12 +549,12 @@
       sqlite3_finalize (stmt);
     }
   if (i == SQLITE_BUSY)
-    return SYSERR;
+    return GNUNET_SYSERR;
   if (i != SQLITE_OK)
     {
       LOG_SQLITE (handle,
                   GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "sqlite_getStat");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   return ret;
 }
@@ -563,7 +563,7 @@
  * @brief set database statistics
  * @param key statistic to set
  * @param val value to set
- * @return SYSERR on error, OK otherwise
+ * @return GNUNET_SYSERR on error, GNUNET_OK otherwise
  */
 static int
 setStat (sqliteHandle * handle, const char *key, unsigned long long val)
@@ -586,7 +586,7 @@
   if (sq_prepare (dbh,
                   "INSERT INTO gn070(hash, expire, type) VALUES (?, ?, ?)",
                   &stmt) != SQLITE_OK)
-    return SYSERR;
+    return GNUNET_SYSERR;
   if ((SQLITE_OK !=
        sqlite3_bind_text (stmt, 1, key, strlen (key), SQLITE_STATIC))
       || (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, val))
@@ -596,18 +596,18 @@
                   GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
                   "sqlite3_bind_xxx");
       sqlite3_finalize (stmt);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (sqlite3_step (stmt) != SQLITE_DONE)
     {
       LOG_SQLITE (handle,
                   GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "sqlite3_step");
       sqlite3_finalize (stmt);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   sqlite3_finalize (stmt);
 
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -645,14 +645,14 @@
   Datastore_Value *datum;
   unsigned int lastPrio;
   unsigned long long lastExp;
-  HashCode512 key;
+  GNUNET_HashCode key;
   sqlite3 *dbh;
   sqliteHandle *handle;
   int ret;
-  cron_t now;
+  GNUNET_CronTime now;
   unsigned long long rowid;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   handle = getDBHandle ();
   dbh = handle->dbh;
 
@@ -672,28 +672,28 @@
       break;
     default:
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
   if (sq_prepare (dbh, stmt_str, &stmt) != SQLITE_OK)
     {
       LOG_SQLITE (handle,
                   GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "sqlite3_prepare");
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   count = 0;
   if (is_asc)
     {
       lastPrio = 0;
       lastExp = 0;
-      memset (&key, 0, sizeof (HashCode512));
+      memset (&key, 0, sizeof (GNUNET_HashCode));
     }
   else
     {
       lastPrio = 0x7FFFFFFF;
       lastExp = 0x7FFFFFFFFFFFFFFFLL;
-      memset (&key, 255, sizeof (HashCode512));
+      memset (&key, 255, sizeof (GNUNET_HashCode));
     }
   while (1)
     {
@@ -708,30 +708,30 @@
           sqlite3_bind_int64 (stmt, 3, lastExp);
         }
 
-      sqlite3_bind_blob (stmt, 2, &key, sizeof (HashCode512),
+      sqlite3_bind_blob (stmt, 2, &key, sizeof (GNUNET_HashCode),
                          SQLITE_TRANSIENT);
-      sqlite3_bind_blob (stmt, 4, &key, sizeof (HashCode512),
+      sqlite3_bind_blob (stmt, 4, &key, sizeof (GNUNET_HashCode),
                          SQLITE_TRANSIENT);
-      now = get_time ();
+      now = GNUNET_get_time ();
 
       if (is_migr)
         {
           sqlite3_bind_int64 (stmt, 5, lastExp);
-          sqlite3_bind_blob (stmt, 6, &key, sizeof (HashCode512),
+          sqlite3_bind_blob (stmt, 6, &key, sizeof (GNUNET_HashCode),
                              SQLITE_TRANSIENT);
 
           sqlite3_bind_int64 (stmt, 7, lastExp);
-          sqlite3_bind_blob (stmt, 8, &key, sizeof (HashCode512),
+          sqlite3_bind_blob (stmt, 8, &key, sizeof (GNUNET_HashCode),
                              SQLITE_TRANSIENT);
         }
       else if (limit_nonanonymous)
         {
           sqlite3_bind_int (stmt, 5, lastPrio);
-          sqlite3_bind_blob (stmt, 6, &key, sizeof (HashCode512),
+          sqlite3_bind_blob (stmt, 6, &key, sizeof (GNUNET_HashCode),
                              SQLITE_TRANSIENT);
 
           sqlite3_bind_int (stmt, 7, lastPrio);
-          sqlite3_bind_blob (stmt, 8, &key, sizeof (HashCode512),
+          sqlite3_bind_blob (stmt, 8, &key, sizeof (GNUNET_HashCode),
                              SQLITE_TRANSIENT);
         }
 
@@ -751,24 +751,24 @@
           printf ("FOUND %4u prio %4u exp %20llu old: %4u, %20llu\n",
                   (ntohl (datum->size) - sizeof (Datastore_Value)),
                   ntohl (datum->prio),
-                  ntohll (datum->expirationTime), lastPrio, lastExp);
+                  GNUNET_ntohll (datum->expirationTime), lastPrio, lastExp);
 #endif
-          if ((NO == limit_nonanonymous) ||
+          if ((GNUNET_NO == limit_nonanonymous) ||
               (ntohl (datum->anonymityLevel) == 0))
             {
               count++;
               if (iter != NULL)
                 {
-                  MUTEX_UNLOCK (lock);
+                  GNUNET_mutex_unlock (lock);
                   ret = iter (&key, datum, closure, rowid);
-                  MUTEX_LOCK (lock);
-                  if (ret == SYSERR)
+                  GNUNET_mutex_lock (lock);
+                  if (ret == GNUNET_SYSERR)
                     {
-                      FREE (datum);
-                      count = SYSERR;
+                      GNUNET_free (datum);
+                      count = GNUNET_SYSERR;
                       break;
                     }
-                  if (ret == NO)
+                  if (ret == GNUNET_NO)
                     {
                       payload -= getContentDatastoreSize (datum);
                       delete_by_rowid (handle, rowid);
@@ -776,8 +776,8 @@
                 }
             }
           lastPrio = ntohl (datum->prio);
-          lastExp = ntohll (datum->expirationTime);
-          FREE (datum);
+          lastExp = GNUNET_ntohll (datum->expirationTime);
+          GNUNET_free (datum);
         }
       else
         {
@@ -787,15 +787,15 @@
                           GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
                           "sqlite3_step");
               sqlite3_finalize (stmt);
-              MUTEX_UNLOCK (lock);
-              return SYSERR;
+              GNUNET_mutex_unlock (lock);
+              return GNUNET_SYSERR;
             }
           sqlite3_reset (stmt);
           break;
         }
     }
   sqlite3_finalize (stmt);
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return count;
 }
 
@@ -807,13 +807,14 @@
  *   type. 0 for all entries.
  * @param iter the callback method
  * @param closure argument to all callback calls
- * @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
 iterateLowPriority (unsigned int type, Datum_Iterator iter, void *closure)
 {
-  return sqlite_iterate (type, YES, YES, NO, NO, 0, iter, closure);
+  return sqlite_iterate (type, GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_NO,
+                         0, iter, closure);
 }
 
 /**
@@ -823,13 +824,14 @@
  *   type. 0 for all entries.
   * @param iter the callback method
  * @param closure argument to all callback calls
- * @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
 iterateNonAnonymous (unsigned int type, Datum_Iterator iter, void *closure)
 {
-  return sqlite_iterate (type, NO, YES, NO, YES, 1, iter, closure);
+  return sqlite_iterate (type, GNUNET_NO, GNUNET_YES, GNUNET_NO, GNUNET_YES,
+                         1, iter, closure);
 }
 
 /**
@@ -844,7 +846,8 @@
 static int
 iterateExpirationTime (unsigned int type, Datum_Iterator iter, void *closure)
 {
-  return sqlite_iterate (type, YES, NO, NO, NO, 2, iter, closure);
+  return sqlite_iterate (type, GNUNET_YES, GNUNET_NO, GNUNET_NO, GNUNET_NO, 2,
+                         iter, closure);
 }
 
 /**
@@ -852,13 +855,14 @@
  * order.
  *
  * @param iter never NULL
- * @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
 iterateMigrationOrder (Datum_Iterator iter, void *closure)
 {
-  return sqlite_iterate (0, NO, NO, YES, NO, 3, iter, closure);
+  return sqlite_iterate (0, GNUNET_NO, GNUNET_NO, GNUNET_YES, GNUNET_NO, 3,
+                         iter, closure);
 }
 
 /**
@@ -882,10 +886,10 @@
   unsigned long long newpayload;
   unsigned long long rowid;
   unsigned long long last_rowid;
-  HashCode512 key;
+  GNUNET_HashCode key;
 
   newpayload = 0;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   handle = getDBHandle ();
   dbh = handle->dbh;
   /* For the rowid trick see
@@ -897,8 +901,8 @@
     {
       LOG_SQLITE (handle,
                   GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "sqlite3_prepare");
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   count = 0;
   last_rowid = 0;
@@ -917,29 +921,29 @@
       newpayload += getContentDatastoreSize (datum);
       if (iter != NULL)
         {
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           ret = iter (&key, datum, closure, rowid);
-          MUTEX_LOCK (lock);
+          GNUNET_mutex_lock (lock);
         }
       else
-        ret = OK;
-      if (ret == SYSERR)
+        ret = GNUNET_OK;
+      if (ret == GNUNET_SYSERR)
         {
-          FREE (datum);
-          count = SYSERR;
+          GNUNET_free (datum);
+          count = GNUNET_SYSERR;
           break;
         }
-      if (ret == NO)
+      if (ret == GNUNET_NO)
         {
           newpayload -= getContentDatastoreSize (datum);
           delete_by_rowid (handle, rowid);
         }
-      FREE (datum);
+      GNUNET_free (datum);
       count++;
     }
   sqlite3_reset (stmt);
   sqlite3_finalize (stmt);
-  if (count != SYSERR)
+  if (count != GNUNET_SYSERR)
     {
       /* re-computed payload! */
       GE_LOG (ectx,
@@ -949,7 +953,7 @@
       payload = newpayload;
       syncStats (handle);
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return count;
 }
 
@@ -973,7 +977,7 @@
     {
       sqliteHandle *h = handles[idx];
 
-      PTHREAD_REL_SELF (h->tid);
+      GNUNET_thread_release_self (h->tid);
       sqlite3_finalize (h->countContent);
       sqlite3_finalize (h->exists);
       sqlite3_finalize (h->updPrio);
@@ -981,12 +985,12 @@
       if (sqlite3_close (h->dbh) != SQLITE_OK)
         LOG_SQLITE (h,
                     GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "sqlite_close");
-      FREE (h);
+      GNUNET_free (h);
     }
-  FREE (handles);
+  GNUNET_free (handles);
   handles = NULL;
   handle_count = 0;
-  FREE (fn);
+  GNUNET_free (fn);
   fn = NULL;
 }
 
@@ -997,10 +1001,10 @@
 static void
 drop ()
 {
-  char *n = STRDUP (fn);
+  char *n = GNUNET_strdup (fn);
   sqlite_shutdown ();
   UNLINK (n);
-  FREE (n);
+  GNUNET_free (n);
 }
 
 
@@ -1012,11 +1016,11 @@
  * @param type entries of which type are relevant?
  *     Use 0 for any type.
  * @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
-get (const HashCode512 * key,
+get (const GNUNET_HashCode * key,
      unsigned int type, Datum_Iterator iter, void *closure)
 {
   int ret;
@@ -1026,13 +1030,13 @@
   Datastore_Value *datum;
   sqlite3 *dbh;
   sqliteHandle *handle;
-  HashCode512 rkey;
+  GNUNET_HashCode rkey;
   unsigned long long last_rowid;
   unsigned long long rowid;
 
   if (key == NULL)
     return iterateLowPriority (type, iter, closure);
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   handle = getDBHandle ();
   dbh = handle->dbh;
   strcpy (scratch, "SELECT ");
@@ -1049,8 +1053,8 @@
     {
       LOG_SQLITE (handle,
                   GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "sqlite_prepare");
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   count = 0;
   last_rowid = 0;
@@ -1058,7 +1062,8 @@
     {
       ret = sqlite3_bind_blob (stmt,
                                1,
-                               key, sizeof (HashCode512), SQLITE_TRANSIENT);
+                               key, sizeof (GNUNET_HashCode),
+                               SQLITE_TRANSIENT);
       if (ret == SQLITE_OK)
         ret = sqlite3_bind_int64 (stmt, 2, last_rowid);
       if (type && (ret == SQLITE_OK))
@@ -1073,7 +1078,7 @@
               count = sqlite3_column_int (stmt, 0);
               sqlite3_reset (stmt);
               sqlite3_finalize (stmt);
-              MUTEX_UNLOCK (lock);
+              GNUNET_mutex_unlock (lock);
               return count;
             }
           datum = assembleDatum (handle, stmt, &rkey, &rowid);
@@ -1082,34 +1087,34 @@
           if (datum == NULL)
             continue;
           if ((key != NULL) &&
-              (0 != memcmp (&rkey, key, sizeof (HashCode512))))
+              (0 != memcmp (&rkey, key, sizeof (GNUNET_HashCode))))
             {
               GE_BREAK (NULL, 0);
-              FREE (datum);
+              GNUNET_free (datum);
               continue;
             }
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           ret = iter (&rkey, datum, closure, rowid);
-          MUTEX_LOCK (lock);
-          if (ret == SYSERR)
+          GNUNET_mutex_lock (lock);
+          if (ret == GNUNET_SYSERR)
             {
-              count = SYSERR;
-              FREE (datum);
+              count = GNUNET_SYSERR;
+              GNUNET_free (datum);
               ret = SQLITE_DONE;
               break;
             }
-          if (ret == NO)
+          if (ret == GNUNET_NO)
             {
               payload -= getContentDatastoreSize (datum);
               delete_by_rowid (handle, rowid);
             }
-          FREE (datum);
+          GNUNET_free (datum);
           count++;
         }
     }
   sqlite3_reset (stmt);
   sqlite3_finalize (stmt);
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return count;
 }
 
@@ -1117,10 +1122,10 @@
  * Write content to the db.  Always adds a new record
  * (does NOT overwrite existing data).
  *
- * @return SYSERR on error, NO on temporary error, OK if ok.
+ * @return GNUNET_SYSERR on error, GNUNET_NO on temporary error, GNUNET_OK if 
ok.
  */
 static int
-put (const HashCode512 * key, const Datastore_Value * value)
+put (const GNUNET_HashCode * key, const Datastore_Value * value)
 {
   int n;
   sqlite3_stmt *stmt;
@@ -1129,22 +1134,22 @@
   unsigned long long expir;
   sqliteHandle *dbh;
 #if DEBUG_SQLITE
-  EncName enc;
+  GNUNET_EncName enc;
 
-  IF_GELOG (ectx, GE_DEBUG | GE_BULK | GE_USER, hash2enc (key, &enc));
-  GE_LOG (ectx,
-          GE_DEBUG | GE_BULK | GE_USER,
+  IF_GELOG (ectx, GE_DEBUG | GE_BULK | GE_USER,
+            GNUNET_hash_to_enc (key, &enc));
+  GE_LOG (ectx, GE_DEBUG | GE_BULK | GE_USER,
           "Storing in database block with type %u/key `%s'/priority 
%u/expiration %llu.\n",
-          ntohl (*(int *) &value[1]),
-          &enc, ntohl (value->prio), ntohll (value->expirationTime));
+          ntohl (*(int *) &value[1]), &enc, ntohl (value->prio),
+          GNUNET_ntohll (value->expirationTime));
 #endif
 
   if ((ntohl (value->size) < sizeof (Datastore_Value)))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   dbh = getDBHandle ();
   if (lastSync > 1000)
     syncStats (dbh);
@@ -1154,14 +1159,14 @@
   type = ntohl (value->type);
   prio = ntohl (value->prio);
   anon = ntohl (value->anonymityLevel);
-  expir = ntohll (value->expirationTime);
+  expir = GNUNET_ntohll (value->expirationTime);
   if ((SQLITE_OK != sqlite3_bind_int (stmt, 1, size)) ||
       (SQLITE_OK != sqlite3_bind_int (stmt, 2, type)) ||
       (SQLITE_OK != sqlite3_bind_int (stmt, 3, prio)) ||
       (SQLITE_OK != sqlite3_bind_int (stmt, 4, anon)) ||
       (SQLITE_OK != sqlite3_bind_int64 (stmt, 5, expir)) ||
       (SQLITE_OK !=
-       sqlite3_bind_blob (stmt, 6, key, sizeof (HashCode512),
+       sqlite3_bind_blob (stmt, 6, key, sizeof (GNUNET_HashCode),
                           SQLITE_TRANSIENT))
       || (SQLITE_OK !=
           sqlite3_bind_blob (stmt, 7, &value[1], contentSize,
@@ -1173,8 +1178,8 @@
       if (SQLITE_OK != sqlite3_reset (stmt))
         LOG_SQLITE (dbh,
                     GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "sqlite3_reset");
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
 
   n = sqlite3_step (stmt);
@@ -1183,14 +1188,14 @@
       if (n == SQLITE_BUSY)
         {
           sqlite3_reset (stmt);
-          MUTEX_UNLOCK (lock);
-          return NO;
+          GNUNET_mutex_unlock (lock);
+          return GNUNET_NO;
         }
       LOG_SQLITE (dbh,
                   GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "sqlite3_step");
       sqlite3_reset (stmt);
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   if (SQLITE_OK != sqlite3_reset (stmt))
     LOG_SQLITE (dbh,
@@ -1201,8 +1206,8 @@
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER, "SQLite: done writing content\n");
 #endif
-  MUTEX_UNLOCK (lock);
-  return OK;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 /**
@@ -1210,12 +1215,12 @@
  * in the datastore.
  */
 static int
-update (unsigned long long uid, int delta, cron_t expire)
+update (unsigned long long uid, int delta, GNUNET_CronTime expire)
 {
   int n;
   sqliteHandle *dbh;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   dbh = getDBHandle ();
   sqlite3_bind_int (dbh->updPrio, 1, delta);
   sqlite3_bind_int64 (dbh->updPrio, 2, expire);
@@ -1229,10 +1234,10 @@
 #if DEBUG_SQLITE
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, "SQLite: block updated\n");
 #endif
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   if (n == SQLITE_BUSY)
-    return NO;
-  return n == SQLITE_OK ? OK : SYSERR;
+    return GNUNET_NO;
+  return n == SQLITE_OK ? GNUNET_OK : GNUNET_SYSERR;
 }
 
 SQstore_ServiceAPI *
@@ -1259,14 +1264,14 @@
                                        "DIR",
                                        VAR_DAEMON_DIRECTORY "/data/fs/",
                                        &afsdir);
-  dir = MALLOC (strlen (afsdir) + strlen ("/content/gnunet.dat") + 2);
+  dir = GNUNET_malloc (strlen (afsdir) + strlen ("/content/gnunet.dat") + 2);
   strcpy (dir, afsdir);
   strcat (dir, "/content/gnunet.dat");
-  FREE (afsdir);
-  if (OK != disk_directory_create_for_file (ectx, dir))
+  GNUNET_free (afsdir);
+  if (GNUNET_OK != GNUNET_disk_directory_create_for_file (ectx, dir))
     {
       GE_BREAK (ectx, 0);
-      FREE (dir);
+      GNUNET_free (dir);
       return NULL;
     }
   fn = dir;
@@ -1274,23 +1279,23 @@
   if (dbh == NULL)
     {
       GE_BREAK (ectx, 0);
-      FREE (fn);
+      GNUNET_free (fn);
       fn = NULL;
       return NULL;
     }
 
   payload = getStat (dbh, "PAYLOAD");
-  if (payload == SYSERR)
+  if (payload == GNUNET_SYSERR)
     {
       GE_BREAK (ectx, 0);
       LOG_SQLITE (dbh,
                   GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "sqlite_payload");
-      MUTEX_DESTROY (lock);
-      FREE (fn);
+      GNUNET_mutex_destroy (lock);
+      GNUNET_free (fn);
       fn = NULL;
       return NULL;
     }
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
   coreAPI = capi;
   stats = coreAPI->requestService ("stats");
   if (stats)
@@ -1322,7 +1327,7 @@
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER, "SQLite: database shutdown\n");
 #endif
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   lock = NULL;
   coreAPI = NULL;
 }
@@ -1349,28 +1354,28 @@
                                        "DIR",
                                        VAR_DAEMON_DIRECTORY "/data/fs/",
                                        &afsdir);
-  dir = MALLOC (strlen (afsdir) + 8 + 2);       /* 8 = "content/" */
+  dir = GNUNET_malloc (strlen (afsdir) + 8 + 2);        /* 8 = "content/" */
   strcpy (dir, afsdir);
   strcat (dir, "/content/");
-  FREE (afsdir);
-  if (OK != disk_directory_create (ectx, dir))
+  GNUNET_free (afsdir);
+  if (GNUNET_OK != GNUNET_disk_directory_create (ectx, dir))
     {
-      FREE (dir);
+      GNUNET_free (dir);
       return;
     }
   fn = dir;
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
   dbh = getDBHandle ();
   if (dbh == NULL)
     {
-      MUTEX_DESTROY (lock);
-      FREE (fn);
+      GNUNET_mutex_destroy (lock);
+      GNUNET_free (fn);
       fn = NULL;
       return;
     }
   createIndices (dbh->dbh);
   sqlite_shutdown ();
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
 }
 
 /* end of sqlite.c */

Modified: GNUnet/src/applications/sqstore_sqlite/sqlitetest.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlitetest.c 2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/sqstore_sqlite/sqlitetest.c 2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -33,25 +33,25 @@
 
 #define ASSERT(x) do { if (! (x)) { printf("Error at %s:%d\n", __FILE__, 
__LINE__); goto FAILURE;} } while (0)
 
-static cron_t now;
+static GNUNET_CronTime now;
 
 static Datastore_Value *
 initValue (int i)
 {
   Datastore_Value *value;
 
-  value = MALLOC (sizeof (Datastore_Value) + 8 * i);
+  value = GNUNET_malloc (sizeof (Datastore_Value) + 8 * i);
   value->size = htonl (sizeof (Datastore_Value) + 8 * i);
   value->type = htonl (i);
   value->prio = htonl (i + 1);
   value->anonymityLevel = htonl (i);
-  value->expirationTime = htonll (now - i * cronSECONDS);
+  value->expirationTime = GNUNET_htonll (now - i * GNUNET_CRON_SECONDS);
   memset (&value[1], i, 8 * i);
   return value;
 }
 
 static int
-checkValue (const HashCode512 * key,
+checkValue (const GNUNET_HashCode * key,
             const Datastore_Value * val, void *closure,
             unsigned long long uid)
 {
@@ -63,23 +63,23 @@
   value = initValue (i);
   if ((value->size == val->size) &&
       (0 == memcmp (val, value, ntohl (val->size))))
-    ret = OK;
+    ret = GNUNET_OK;
   else
     {
       /*
          printf("Wanted: %u, %llu; got %u, %llu - %d\n",
-         ntohl(value->size), ntohll(value->expirationTime),
-         ntohl(val->size), ntohll(val->expirationTime),
+         ntohl(value->size), GNUNET_ntohll(value->expirationTime),
+         ntohl(val->size), GNUNET_ntohll(val->expirationTime),
          memcmp(val, value, ntohl(val->size))); */
-      ret = SYSERR;
+      ret = GNUNET_SYSERR;
     }
-  FREE (value);
+  GNUNET_free (value);
   return ret;
 }
 
 static int
-iterateUp (const HashCode512 * key, const Datastore_Value * val, int *closure,
-           unsigned long long uid)
+iterateUp (const GNUNET_HashCode * key, const Datastore_Value * val,
+           int *closure, unsigned long long uid)
 {
   int ret;
 
@@ -89,7 +89,7 @@
 }
 
 static int
-iterateDown (const HashCode512 * key,
+iterateDown (const GNUNET_HashCode * key,
              const Datastore_Value * val, int *closure,
              unsigned long long uid)
 {
@@ -101,24 +101,24 @@
 }
 
 static int
-iterateDelete (const HashCode512 * key,
+iterateDelete (const GNUNET_HashCode * key,
                const Datastore_Value * val, void *closure,
                unsigned long long uid)
 {
-  return NO;
+  return GNUNET_NO;
 }
 
 static int
-iteratePriority (const HashCode512 * key,
+iteratePriority (const GNUNET_HashCode * key,
                  const Datastore_Value * val, SQstore_ServiceAPI * api,
                  unsigned long long uid)
 {
   api->update (uid, 4, 0);
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
-priorityCheck (const HashCode512 * key,
+priorityCheck (const GNUNET_HashCode * key,
                const Datastore_Value * val, int *closure,
                unsigned long long uid)
 {
@@ -126,13 +126,13 @@
 
   id = (*closure);
   if (id + 1 == ntohl (val->prio))
-    return OK;
+    return GNUNET_OK;
   else
-    return SYSERR;
+    return GNUNET_SYSERR;
 }
 
 static int
-multipleCheck (const HashCode512 * key,
+multipleCheck (const GNUNET_HashCode * key,
                const Datastore_Value * val, Datastore_Value ** last,
                unsigned long long uid)
 {
@@ -140,12 +140,12 @@
     {
       if (((*last)->size == val->size) &&
           (0 == memcmp (*last, val, ntohl (val->size))))
-        return SYSERR;          /* duplicate! */
-      FREE (*last);
+        return GNUNET_SYSERR;   /* duplicate! */
+      GNUNET_free (*last);
     }
-  *last = MALLOC (ntohl (val->size));
+  *last = GNUNET_malloc (ntohl (val->size));
   memcpy (*last, val, ntohl (val->size));
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -156,7 +156,7 @@
 test (SQstore_ServiceAPI * api)
 {
   Datastore_Value *value;
-  HashCode512 key;
+  GNUNET_HashCode key;
   unsigned long long oldSize;
   int i;
 
@@ -165,26 +165,26 @@
   for (i = 0; i < 256; i++)
     {
       value = initValue (i);
-      memset (&key, 256 - i, sizeof (HashCode512));
-      ASSERT (OK == api->put (&key, value));
-      FREE (value);
+      memset (&key, 256 - i, sizeof (GNUNET_HashCode));
+      ASSERT (GNUNET_OK == api->put (&key, value));
+      GNUNET_free (value);
     }
   ASSERT (oldSize < api->getSize ());
   ASSERT (256 == api->iterateLowPriority (ANY_BLOCK, NULL, NULL));
   ASSERT (256 == api->iterateExpirationTime (ANY_BLOCK, NULL, NULL));
   for (i = 255; i >= 0; i--)
     {
-      memset (&key, 256 - i, sizeof (HashCode512));
+      memset (&key, 256 - i, sizeof (GNUNET_HashCode));
       ASSERT (1 == api->get (&key, i, &checkValue, (void *) &i));
     }
 
   oldSize = api->getSize ();
   for (i = 255; i >= 0; i -= 2)
     {
-      memset (&key, 256 - i, sizeof (HashCode512));
+      memset (&key, 256 - i, sizeof (GNUNET_HashCode));
       value = initValue (i);
       ASSERT (1 == api->get (&key, 0, &iterateDelete, NULL));
-      FREE (value);
+      GNUNET_free (value);
     }
   ASSERT (oldSize > api->getSize ());
   i = 0;
@@ -204,7 +204,7 @@
 
   i = 42;
   value = initValue (i);
-  memset (&key, 256 - i, sizeof (HashCode512));
+  memset (&key, 256 - i, sizeof (GNUNET_HashCode));
   api->put (&key, value);
   ASSERT (1 == api->iterateExpirationTime (ANY_BLOCK,
                                            (Datum_Iterator) & priorityCheck,
@@ -214,27 +214,27 @@
   ASSERT (1 == api->iterateExpirationTime (ANY_BLOCK,
                                            (Datum_Iterator) & priorityCheck,
                                            &i));
-  FREE (value);
+  GNUNET_free (value);
 
   /* test multiple results */
   value = initValue (i + 1);
   api->put (&key, value);
-  FREE (value);
+  GNUNET_free (value);
 
   value = NULL;
   ASSERT (2 == api->iterateExpirationTime (ANY_BLOCK,
                                            (Datum_Iterator) & multipleCheck,
                                            &value));
-  FREE (value);
+  GNUNET_free (value);
   ASSERT (2 == api->iterateAllNow ((Datum_Iterator) & iterateDelete, api));
   ASSERT (0 == api->iterateExpirationTime (ANY_BLOCK, NULL, NULL));
   api->drop ();
 
-  return OK;
+  return GNUNET_OK;
 
 FAILURE:
   api->drop ();
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 int
@@ -243,9 +243,9 @@
   SQstore_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);
@@ -260,11 +260,11 @@
       releaseService (api);
     }
   else
-    ok = SYSERR;
+    ok = GNUNET_SYSERR;
   doneCore ();
-  cron_destroy (cron);
+  GNUNET_cron_destroy (cron);
   GC_free (cfg);
-  if (ok == SYSERR)
+  if (ok == GNUNET_SYSERR)
     return 1;
   return 0;
 }

Modified: GNUnet/src/applications/sqstore_sqlite/sqlitetest2.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlitetest2.c        2007-11-23 
11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/sqstore_sqlite/sqlitetest2.c        2007-11-23 
11:51:54 UTC (rev 5742)
@@ -85,10 +85,10 @@
 #define MAX_SIZE 1024LL * 1024 * 16
 
 /**
- * Report progress outside of major reports? Should probably be YES if
+ * Report progress outside of major reports? Should probably be GNUNET_YES if
  * size is > 16 MB.
  */
-#define REPORT_ID NO
+#define REPORT_ID GNUNET_NO
 
 /**
  * Number of put operations equivalent to 1/10th of MAX_SIZE
@@ -121,36 +121,40 @@
 
 static unsigned long long stored_ops;
 
-static cron_t start_time;
+static GNUNET_CronTime start_time;
 
 static int
 putValue (SQstore_ServiceAPI * api, int i)
 {
   Datastore_Value *value;
   size_t size;
-  static HashCode512 key;
+  static GNUNET_HashCode key;
   static int ic;
 
   /* most content is 32k */
   size = sizeof (Datastore_Value) + 32 * 1024;
-  if (weak_randomi (16) == 0)   /* but some of it is less! */
-    size = sizeof (Datastore_Value) + weak_randomi (32 * 1024);
+  if (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 16) == 0)  /* but some of 
it is less! */
+    size =
+      sizeof (Datastore_Value) +
+      GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 32 * 1024);
   size = size - (size & 7);     /* always multiple of 8 */
 
   /* generate random key */
-  hash (&key, sizeof (HashCode512), &key);
-  value = MALLOC (size);
+  GNUNET_hash (&key, sizeof (GNUNET_HashCode), &key);
+  value = GNUNET_malloc (size);
   value->size = htonl (size);
   value->type = htonl (i);
-  value->prio = htonl (weak_randomi (100));
+  value->prio = htonl (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 100));
   value->anonymityLevel = htonl (i);
-  value->expirationTime = htonll (get_time () + weak_randomi (1000));
+  value->expirationTime =
+    GNUNET_htonll (GNUNET_get_time () +
+                   GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 1000));
   memset (&value[1], i, size - sizeof (Datastore_Value));
-  if (OK != api->put (&key, value))
+  if (GNUNET_OK != api->put (&key, value))
     {
-      FREE (value);
+      GNUNET_free (value);
       fprintf (stderr, "E");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   ic++;
 #if REPORT_ID
@@ -160,21 +164,21 @@
   stored_bytes += ntohl (value->size);
   stored_ops++;
   stored_entries++;
-  FREE (value);
-  return OK;
+  GNUNET_free (value);
+  return GNUNET_OK;
 }
 
 static int
-iterateDelete (const HashCode512 * key,
+iterateDelete (const GNUNET_HashCode * key,
                const Datastore_Value * val, void *cls, unsigned long long uid)
 {
   SQstore_ServiceAPI *api = cls;
   static int dc;
 
   if (api->getSize () < MAX_SIZE)
-    return SYSERR;
-  if (GNUNET_SHUTDOWN_TEST () == YES)
-    return SYSERR;
+    return GNUNET_SYSERR;
+  if (GNUNET_shutdown_test () == GNUNET_YES)
+    return GNUNET_SYSERR;
   dc++;
 #if REPORT_ID
   if (dc % REP_FREQ == 0)
@@ -182,7 +186,7 @@
 #endif
   stored_bytes -= ntohl (val->size);
   stored_entries--;
-  return NO;
+  return GNUNET_NO;
 }
 
 /**
@@ -207,8 +211,8 @@
       /* insert data equivalent to 1/10th of MAX_SIZE */
       for (j = 0; j < PUT_10; j++)
         {
-          ASSERT (OK == putValue (api, j));
-          if (GNUNET_SHUTDOWN_TEST () == YES)
+          ASSERT (GNUNET_OK == putValue (api, j));
+          if (GNUNET_shutdown_test () == GNUNET_YES)
             break;
         }
 
@@ -220,7 +224,7 @@
 
       size = 0;
       if (have_file)
-        disk_file_size (NULL, DB_NAME, &size, NO);
+        GNUNET_disk_file_size (NULL, DB_NAME, &size, GNUNET_NO);
       printf (
 #if REPORT_ID
                "\n"
@@ -230,16 +234,16 @@
                size / 1024,     /* disk size in kb */
                (100.0 * size / stored_bytes) - 100,     /* overhead */
                (stored_ops * 2 - stored_entries) / 1024,        /* total 
operations (in k) */
-               1000 * (stored_ops * 2 - stored_entries) / (1 + get_time () - 
start_time));      /* operations per second */
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+               1000 * (stored_ops * 2 - stored_entries) / (1 + GNUNET_get_time 
() - start_time));       /* operations per second */
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   api->drop ();
-  return OK;
+  return GNUNET_OK;
 
 FAILURE:
   api->drop ();
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 int
@@ -248,9 +252,9 @@
   SQstore_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);
@@ -261,16 +265,16 @@
   api = requestService ("sqstore");
   if (api != NULL)
     {
-      start_time = get_time ();
+      start_time = GNUNET_get_time ();
       ok = test (api);
       releaseService (api);
     }
   else
-    ok = SYSERR;
+    ok = GNUNET_SYSERR;
   doneCore ();
-  cron_destroy (cron);
+  GNUNET_cron_destroy (cron);
   GC_free (cfg);
-  if (ok == SYSERR)
+  if (ok == GNUNET_SYSERR)
     return 1;
   return 0;
 }

Modified: GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c        2007-11-23 
11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/sqstore_sqlite/sqlitetest3.c        2007-11-23 
11:51:54 UTC (rev 5742)
@@ -53,55 +53,58 @@
 
 static unsigned long long stored_ops;
 
-static cron_t start_time;
+static GNUNET_CronTime start_time;
 
 static int
 putValue (SQstore_ServiceAPI * api, int i)
 {
   Datastore_Value *value;
   size_t size;
-  static HashCode512 key;
+  static GNUNET_HashCode key;
   static int ic;
 
   /* most content is 32k */
   size = sizeof (Datastore_Value) + 32 * 1024;
 
-  if (weak_randomi (16) == 0)   /* but some of it is less! */
-    size = sizeof (Datastore_Value) + weak_randomi (32 * 1024);
+  if (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 16) == 0)  /* but some of 
it is less! */
+    size =
+      sizeof (Datastore_Value) +
+      GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 32 * 1024);
   size = size - (size & 7);     /* always multiple of 8 */
 
   /* generate random key */
-  key.bits[0] = (unsigned int) get_time ();
-  hash (&key, sizeof (HashCode512), &key);
-  value = MALLOC (size);
+  key.bits[0] = (unsigned int) GNUNET_get_time ();
+  GNUNET_hash (&key, sizeof (GNUNET_HashCode), &key);
+  value = GNUNET_malloc (size);
   value->size = htonl (size);
   value->type = htonl (i);
-  value->prio = htonl (weak_randomi (100));
+  value->prio = htonl (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 100));
   value->anonymityLevel = htonl (i);
   value->expirationTime =
-    htonll (get_time () + 60 * cronHOURS + weak_randomi (1000));
+    GNUNET_htonll (GNUNET_get_time () + 60 * GNUNET_CRON_HOURS +
+                   GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 1000));
   memset (&value[1], i, size - sizeof (Datastore_Value));
-  if (OK != api->put (&key, value))
+  if (GNUNET_OK != api->put (&key, value))
     {
-      FREE (value);
+      GNUNET_free (value);
       fprintf (stderr, "E");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   ic++;
   stored_bytes += ntohl (value->size);
   stored_ops++;
   stored_entries++;
-  FREE (value);
-  return OK;
+  GNUNET_free (value);
+  return GNUNET_OK;
 }
 
 static int
-iterateDummy (const HashCode512 * key, const Datastore_Value * val, void *cls,
-              unsigned long long uid)
+iterateDummy (const GNUNET_HashCode * key, const Datastore_Value * val,
+              void *cls, unsigned long long uid)
 {
-  if (GNUNET_SHUTDOWN_TEST () == YES)
-    return SYSERR;
-  return OK;
+  if (GNUNET_shutdown_test () == GNUNET_YES)
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 static int
@@ -110,62 +113,62 @@
   int i;
   int j;
   int ret;
-  cron_t start;
-  cron_t end;
+  GNUNET_CronTime start;
+  GNUNET_CronTime end;
 
   for (i = 0; i < ITERATIONS; i++)
     {
       /* insert data equivalent to 1/10th of MAX_SIZE */
-      start = get_time ();
+      start = GNUNET_get_time ();
       for (j = 0; j < PUT_10; j++)
         {
-          if (OK != putValue (api, j))
+          if (GNUNET_OK != putValue (api, j))
             break;
-          if (GNUNET_SHUTDOWN_TEST () == YES)
+          if (GNUNET_shutdown_test () == GNUNET_YES)
             break;
         }
-      end = get_time ();
+      end = GNUNET_get_time ();
       printf ("%3u insertion              took %20llums\n", i, end - start);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
-      start = get_time ();
+      start = GNUNET_get_time ();
       ret = api->iterateLowPriority (0, &iterateDummy, api);
-      end = get_time ();
+      end = GNUNET_get_time ();
       printf ("%3u low priority iteration took %20llums (%d)\n", i,
               end - start, ret);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
-      start = get_time ();
+      start = GNUNET_get_time ();
       ret = api->iterateExpirationTime (0, &iterateDummy, api);
-      end = get_time ();
+      end = GNUNET_get_time ();
       printf ("%3u expiration t iteration took %20llums (%d)\n", i,
               end - start, ret);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
-      start = get_time ();
+      start = GNUNET_get_time ();
       ret = api->iterateNonAnonymous (0, &iterateDummy, api);
-      end = get_time ();
+      end = GNUNET_get_time ();
       printf ("%3u non anonymou iteration took %20llums (%d)\n", i,
               end - start, ret);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
-      start = get_time ();
+      start = GNUNET_get_time ();
       ret = api->iterateMigrationOrder (&iterateDummy, api);
-      end = get_time ();
+      end = GNUNET_get_time ();
       printf ("%3u migration or iteration took %20llums (%d)\n", i,
               end - start, ret);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
-      start = get_time ();
+      start = GNUNET_get_time ();
       ret = api->iterateAllNow (&iterateDummy, api);
-      end = get_time ();
+      end = GNUNET_get_time ();
       printf ("%3u all now      iteration took %20llums (%d)\n", i,
               end - start, ret);
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
     }
   api->drop ();
-  return OK;
+  return GNUNET_OK;
 }
 
 int
@@ -174,9 +177,9 @@
   SQstore_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);
@@ -187,16 +190,16 @@
   api = requestService ("sqstore");
   if (api != NULL)
     {
-      start_time = get_time ();
+      start_time = GNUNET_get_time ();
       ok = test (api);
       releaseService (api);
     }
   else
-    ok = SYSERR;
+    ok = GNUNET_SYSERR;
   doneCore ();
-  cron_destroy (cron);
+  GNUNET_cron_destroy (cron);
   GC_free (cfg);
-  if (ok == SYSERR)
+  if (ok == GNUNET_SYSERR)
     return 1;
   return 0;
 }

Modified: GNUnet/src/applications/state/state.c
===================================================================
--- GNUnet/src/applications/state/state.c       2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/state/state.c       2007-11-23 11:51:54 UTC (rev 
5742)
@@ -36,7 +36,7 @@
 #include "gnunet_state_service.h"
 #include "platform.h"
 
-#define STATE_DEBUG NO
+#define STATE_DEBUG GNUNET_NO
 
 #define DIR_EXT "state.sdb"
 
@@ -65,27 +65,27 @@
   if (result == NULL)
     return -1;
   n = strlen (dbh) + strlen (name) + 2;
-  fil = MALLOC (n);
-  SNPRINTF (fil, n, "%s/%s", dbh, name);
-  if ((OK != disk_file_test (ectx,
-                             fil)) ||
-      (OK != disk_file_size (ectx,
-                             fil,
-                             &fsize,
-                             YES)) ||
+  fil = GNUNET_malloc (n);
+  GNUNET_snprintf (fil, n, "%s/%s", dbh, name);
+  if ((GNUNET_OK != GNUNET_disk_file_test (ectx,
+                                           fil)) ||
+      (GNUNET_OK != GNUNET_disk_file_size (ectx,
+                                           fil,
+                                           &fsize,
+                                           GNUNET_YES)) ||
       (fsize == 0) ||
-      (-1 == (fd = disk_file_open (ectx, fil, O_RDONLY, S_IRUSR))))
+      (-1 == (fd = GNUNET_disk_file_open (ectx, fil, O_RDONLY, S_IRUSR))))
     {
-      FREE (fil);
+      GNUNET_free (fil);
       return -1;
     }
-  *result = MALLOC_LARGE (fsize);
+  *result = GNUNET_malloc_large (fsize);
   size = READ (fd, *result, fsize);
-  disk_file_close (ectx, fil, fd);
-  FREE (fil);
+  GNUNET_disk_file_close (ectx, fil, fd);
+  GNUNET_free (fil);
   if (size == -1)
     {
-      FREE (*result);
+      GNUNET_free (*result);
       *result = NULL;
     }
   return size;
@@ -98,7 +98,7 @@
  * @param name the key for the entry
  * @param len the number of bytes in block
  * @param block the data to store
- * @return SYSERR on error, OK if ok.
+ * @return GNUNET_SYSERR on error, GNUNET_OK if ok.
  */
 static int
 stateAppendContent (struct GE_Context *ectx,
@@ -111,21 +111,21 @@
 
   GE_ASSERT (ectx, handle != NULL);
   n = strlen (dbh) + strlen (name) + 2;
-  fil = MALLOC (n);
-  SNPRINTF (fil, n, "%s/%s", dbh, name);
-  fd = disk_file_open (ectx, fil, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+  fil = GNUNET_malloc (n);
+  GNUNET_snprintf (fil, n, "%s/%s", dbh, name);
+  fd = GNUNET_disk_file_open (ectx, fil, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
   if (fd == -1)
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_WARNING | GE_BULK | GE_USER, "open", fil);
-      FREE (fil);
-      return SYSERR;            /* failed! */
+      GNUNET_free (fil);
+      return GNUNET_SYSERR;     /* failed! */
     }
   LSEEK (fd, 0, SEEK_END);
   WRITE (fd, block, len);
-  disk_file_close (ectx, fil, fd);
-  FREE (fil);
-  return OK;
+  GNUNET_disk_file_close (ectx, fil, fd);
+  GNUNET_free (fil);
+  return GNUNET_OK;
 }
 
 /**
@@ -134,7 +134,7 @@
  * @param name the key for the entry
  * @param len the number of bytes in block
  * @param block the data to store
- * @return SYSERR on error, OK if ok.
+ * @return GNUNET_SYSERR on error, GNUNET_OK if ok.
  */
 static int
 stateWriteContent (struct GE_Context *ectx,
@@ -147,23 +147,23 @@
 
   GE_ASSERT (ectx, handle != NULL);
   n = strlen (dbh) + strlen (name) + 2;
-  fil = MALLOC (n);
-  SNPRINTF (fil, n, "%s/%s", dbh, name);
-  fd = disk_file_open (ectx, fil, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+  fil = GNUNET_malloc (n);
+  GNUNET_snprintf (fil, n, "%s/%s", dbh, name);
+  fd = GNUNET_disk_file_open (ectx, fil, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
   if (fd == -1)
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_WARNING | GE_BULK | GE_USER, "open", fil);
-      FREE (fil);
-      return SYSERR;            /* failed! */
+      GNUNET_free (fil);
+      return GNUNET_SYSERR;     /* failed! */
     }
   WRITE (fd, block, len);
   if (0 != FTRUNCATE (fd, len))
     GE_LOG_STRERROR_FILE (ectx,
                           GE_WARNING | GE_BULK | GE_ADMIN, "ftruncate", fil);
-  disk_file_close (ectx, fil, fd);
-  FREE (fil);
-  return OK;
+  GNUNET_disk_file_close (ectx, fil, fd);
+  GNUNET_free (fil);
+  return GNUNET_OK;
 }
 
 /**
@@ -180,11 +180,11 @@
 
   GE_ASSERT (ectx, handle != NULL);
   n = strlen (dbh) + strlen (name) + 2;
-  fil = MALLOC (n);
-  SNPRINTF (fil, n, "%s/%s", dbh, name);
+  fil = GNUNET_malloc (n);
+  GNUNET_snprintf (fil, n, "%s/%s", dbh, name);
   UNLINK (fil);
-  FREE (fil);
-  return OK;
+  GNUNET_free (fil);
+  return GNUNET_OK;
 }
 
 State_ServiceAPI *
@@ -203,12 +203,12 @@
     return NULL;
   GE_ASSERT (capi->ectx, dbh != NULL);
   n = strlen (dbh) + strlen (DIR_EXT) + 5;
-  handle = MALLOC (n);
-  SNPRINTF (handle, n, "%s/%s/", dbh, DIR_EXT);
-  FREE (dbh);
-  if (SYSERR == disk_directory_create (capi->ectx, handle))
+  handle = GNUNET_malloc (n);
+  GNUNET_snprintf (handle, n, "%s/%s/", dbh, DIR_EXT);
+  GNUNET_free (dbh);
+  if (GNUNET_SYSERR == GNUNET_disk_directory_create (capi->ectx, handle))
     {
-      FREE (handle);
+      GNUNET_free (handle);
       handle = NULL;
       return NULL;
     }
@@ -226,7 +226,7 @@
 release_module_state ()
 {
   GE_ASSERT (NULL, handle != NULL);
-  FREE (handle);
+  GNUNET_free (handle);
   handle = NULL;
 }
 

Modified: GNUnet/src/applications/state/statetest.c
===================================================================
--- GNUnet/src/applications/state/statetest.c   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/state/statetest.c   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -31,13 +31,15 @@
       switch (c)
         {
         case 'c':
-          FREENONNULL (setConfigurationString ("FILES",
-                                               "gnunet.conf", GNoptarg));
+          GNUNET_free_non_null (setConfigurationString ("FILES",
+                                                        "gnunet.conf",
+                                                        GNoptarg));
           break;
         }                       /* end of parsing commandline */
     }
-  FREENONNULL (setConfigurationString ("GNUNETD", "LOGLEVEL", "NOTHING"));
-  return OK;
+  GNUNET_free_non_null (setConfigurationString
+                        ("GNUNETD", "LOGLEVEL", "NOTHING"));
+  return GNUNET_OK;
 }
 
 #define TH "TestHandle"
@@ -49,17 +51,17 @@
   char *ret;
 
   stateUnlinkFromDB (TH);       /* go to defined state */
-  if (SYSERR == stateWriteContent (TH, 5, testString))
+  if (GNUNET_SYSERR == stateWriteContent (TH, 5, testString))
     return 1;
-  if (SYSERR == stateAppendContent (TH, 6, &testString[5]))
+  if (GNUNET_SYSERR == stateAppendContent (TH, 6, &testString[5]))
     return 2;
   ret = NULL;
-  if (SYSERR == stateReadContent (TH, (void **) &ret))
+  if (GNUNET_SYSERR == stateReadContent (TH, (void **) &ret))
     return 3;
   if (0 != strncmp (ret, testString, 11))
     return 4;
-  FREE (ret);
-  if (OK != stateUnlinkFromDB (TH))
+  GNUNET_free (ret);
+  if (GNUNET_OK != stateUnlinkFromDB (TH))
     return 5;
   return 0;
 }

Modified: GNUnet/src/applications/stats/Makefile.am
===================================================================
--- GNUnet/src/applications/stats/Makefile.am   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/stats/Makefile.am   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -20,15 +20,12 @@
 gnunet_stats_SOURCES = \
  gnunet-stats.c        
 gnunet_stats_LDADD = \
-  $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
-  $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
+  $(top_builddir)/src/applications/stats/libgnunetstats_api.la 
 
 libgnunetstats_api_la_SOURCES = \
   clientapi.c 
 libgnunetstats_api_la_LIBADD = \
-  $(top_builddir)/src/util/libgnunetutil.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la
+  $(top_builddir)/src/util/libgnunetutil.la 
 
 libgnunetmodule_stats_la_SOURCES = \
   statistics.c \

Modified: GNUnet/src/applications/stats/clientapi.c
===================================================================
--- GNUnet/src/applications/stats/clientapi.c   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/stats/clientapi.c   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -287,41 +287,43 @@
  * Request statistics from TCP socket.
  * @param sock the socket to use
  * @param processor function to call on each value
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
 STATS_getStatistics (struct GE_Context *ectx,
-                     struct ClientServerConnection *sock,
+                     struct GNUNET_ClientServerConnection *sock,
                      STATS_StatProcessor processor, void *cls)
 {
   CS_stats_reply_MESSAGE *statMsg;
-  MESSAGE_HEADER csHdr;
+  GNUNET_MessageHeader csHdr;
   unsigned int count;
   unsigned int i;
   int mpos;
   int ret;
 
-  ret = OK;
-  csHdr.size = htons (sizeof (MESSAGE_HEADER));
+  ret = GNUNET_OK;
+  csHdr.size = htons (sizeof (GNUNET_MessageHeader));
   csHdr.type = htons (CS_PROTO_stats_GET_STATISTICS);
-  if (SYSERR == connection_write (sock, &csHdr))
-    return SYSERR;
-  statMsg = MALLOC (sizeof (CS_stats_reply_MESSAGE));
+  if (GNUNET_SYSERR == GNUNET_client_connection_write (sock, &csHdr))
+    return GNUNET_SYSERR;
+  statMsg = GNUNET_malloc (sizeof (CS_stats_reply_MESSAGE));
   statMsg->totalCounters = htonl (1);   /* to ensure we enter the loop */
   count = 0;
   while (count < ntohl (statMsg->totalCounters))
     {
-      FREE (statMsg);
+      GNUNET_free (statMsg);
       statMsg = NULL;
       /* printf("reading from socket starting %u of %d\n",
          count, ntohl(statMsg->totalCounters) ); */
-      if (SYSERR == connection_read (sock, (MESSAGE_HEADER **) & statMsg))
-        return SYSERR;
+      if (GNUNET_SYSERR ==
+          GNUNET_client_connection_read (sock,
+                                         (GNUNET_MessageHeader **) & statMsg))
+        return GNUNET_SYSERR;
       if ((ntohs (statMsg->header.size) < sizeof (CS_stats_reply_MESSAGE)) ||
           (((char *) statMsg)[ntohs (statMsg->header.size) - 1] != '\0'))
         {
           GE_BREAK (ectx, 0);
-          ret = SYSERR;
+          ret = GNUNET_SYSERR;
           break;
         }
       mpos = sizeof (unsigned long long) * ntohl (statMsg->statCounters);
@@ -329,9 +331,9 @@
         {
           ret = processor (_("Uptime (seconds)"),
                            (unsigned long long)
-                           ((get_time () -
-                             ntohll (statMsg->startTime)) / cronSECONDS),
-                           cls);
+                           ((GNUNET_get_time () -
+                             GNUNET_ntohll (statMsg->startTime)) /
+                            GNUNET_CRON_SECONDS), cls);
         }
       for (i = 0; i < ntohl (statMsg->statCounters); i++)
         {
@@ -343,18 +345,18 @@
               ntohs (statMsg->header.size) - sizeof (CS_stats_reply_MESSAGE))
             {
               GE_BREAK (ectx, 0);
-              ret = SYSERR;
+              ret = GNUNET_SYSERR;
               break;            /* out of bounds! */
             }
-          if (ret != SYSERR)
+          if (ret != GNUNET_SYSERR)
             {
               ret =
                 processor (&
                            ((char
                              *) (((CS_stats_reply_MESSAGE_GENERIC *)
                                   statMsg)->values))[mpos],
-                           ntohll (((CS_stats_reply_MESSAGE_GENERIC *)
-                                    statMsg)->values[i]), cls);
+                           GNUNET_ntohll (((CS_stats_reply_MESSAGE_GENERIC *)
+                                           statMsg)->values[i]), cls);
             }
           mpos +=
             strlen (&
@@ -363,7 +365,7 @@
         }
       count += ntohl (statMsg->statCounters);
     }                           /* end while */
-  FREE (statMsg);
+  GNUNET_free (statMsg);
   return ret;
 }
 
@@ -372,11 +374,11 @@
  * Request available protocols from TCP socket.
  * @param sock the socket to use
  * @param processor function to call on each value
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
 STATS_getAvailableProtocols (struct GE_Context *ectx,
-                             struct ClientServerConnection *sock,
+                             struct GNUNET_ClientServerConnection *sock,
                              STATS_ProtocolProcessor processor, void *cls)
 {
   CS_stats_get_supported_MESSAGE csStatMsg;
@@ -385,7 +387,7 @@
   int supported;
   int ret;
 
-  ret = OK;
+  ret = GNUNET_OK;
   csStatMsg.header.size = htons (sizeof (CS_stats_get_supported_MESSAGE));
   csStatMsg.header.type = htons (CS_PROTO_stats_GET_P2P_MESSAGE_SUPPORTED);
   for (j = 2; j < 4; j++)
@@ -394,19 +396,21 @@
       for (i = 0; i < 65535; i++)
         {
           csStatMsg.type = htons (i);
-          if (SYSERR == connection_write (sock, &csStatMsg.header))
-            return SYSERR;
-          if (SYSERR == connection_read_result (sock, &supported))
-            return SYSERR;
-          if (supported == YES)
+          if (GNUNET_SYSERR ==
+              GNUNET_client_connection_write (sock, &csStatMsg.header))
+            return GNUNET_SYSERR;
+          if (GNUNET_SYSERR ==
+              GNUNET_client_connection_read_result (sock, &supported))
+            return GNUNET_SYSERR;
+          if (supported == GNUNET_YES)
             {
-              ret = processor (i, (j == 2) ? YES : NO, cls);
-              if (ret != OK)
+              ret = processor (i, (j == 2) ? GNUNET_YES : GNUNET_NO, cls);
+              if (ret != GNUNET_OK)
                 break;
             }
         }
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /* end of clientapi.c */

Modified: GNUnet/src/applications/stats/gnunet-stats.c
===================================================================
--- GNUnet/src/applications/stats/gnunet-stats.c        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/stats/gnunet-stats.c        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -28,11 +28,10 @@
 #include "platform.h"
 #include "gnunet_directories.h"
 #include "gnunet_util.h"
-#include "gnunet_util_boot.h"
 #include "gnunet_stats_lib.h"
 #include "statistics.h"
 
-static int lastIp2p = 42;       /* not YES or NO */
+static int lastIp2p = 42;       /* not GNUNET_YES or GNUNET_NO */
 
 static char *cfgFilename = DEFAULT_CLIENT_CONFIG_FILE;
 
@@ -40,14 +39,14 @@
  * Print statistics received.
  *
  * @param stream where to print the statistics
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
 printStatistics (const char *name, unsigned long long value, void *cls)
 {
   FILE *stream = cls;
   FPRINTF (stream, "%-60s: %16llu\n", dgettext ("GNUnet", name), value);
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
@@ -73,22 +72,22 @@
     fprintf (stream, "\t%d\n", type);
   else
     fprintf (stream, "\t%d\t(%s)\n", type, name);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * All gnunet-transport-check command line options
  */
-static struct CommandLineOption gnunetstatsOptions[] = {
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Print statistics about GNUnet 
operations.")),        /* -h */
-  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+static struct GNUNET_CommandLineOption gnunetstatsOptions[] = {
+       GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
+  GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Print statistics about 
GNUnet operations.")),        /* -h */
+  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'p', "protocols", NULL,
    gettext_noop ("prints supported protocol messages"),
-   0, &gnunet_getopt_configure_set_option, "STATS:PRINT-PROTOCOLS=YES"},
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_END,
+   0, &GNUNET_getopt_configure_set_option, "STATS:PRINT-PROTOCOLS=YES"},
+   GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 
@@ -103,7 +102,7 @@
 main (int argc, char *const *argv)
 {
   int res;
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   struct GC_Configuration *cfg;
   struct GE_Context *ectx;
 
@@ -116,26 +115,27 @@
       GNUNET_fini (ectx, cfg);
       return -1;
     }
-  sock = client_connection_create (ectx, cfg);
+  sock = GNUNET_client_connection_create (ectx, cfg);
   if (sock == NULL)
     {
       fprintf (stderr, _("Error establishing connection with gnunetd.\n"));
       return 1;
     }
   res = STATS_getStatistics (ectx, sock, &printStatistics, stdout);
-  if ((YES == GC_get_configuration_value_yesno (cfg,
-                                                "STATS",
-                                                "PRINT-PROTOCOLS",
-                                                NO)) && (res == OK))
+  if ((GNUNET_YES == GC_get_configuration_value_yesno (cfg,
+                                                       "STATS",
+                                                       "PRINT-PROTOCOLS",
+                                                       GNUNET_NO))
+      && (res == GNUNET_OK))
     {
       res = STATS_getAvailableProtocols (ectx, sock, &printProtocols, stdout);
     }
-  if (res != OK)
+  if (res != GNUNET_OK)
     fprintf (stderr, _("Error reading information from gnunetd.\n"));
-  connection_destroy (sock);
+  GNUNET_client_connection_destroy (sock);
   GNUNET_fini (ectx, cfg);
 
-  return (res == OK) ? 0 : 1;
+  return (res == GNUNET_OK) ? 0 : 1;
 }
 
 /* end of gnunet-stats.c */

Modified: GNUnet/src/applications/stats/sqstats.c
===================================================================
--- GNUnet/src/applications/stats/sqstats.c     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/stats/sqstats.c     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -51,11 +51,11 @@
 };
 
 static int
-iter (const HashCode512 * key, const Datastore_Value * value, void *cls)
+iter (const GNUNET_HashCode * key, const Datastore_Value * value, void *cls)
 {
   struct CD *data = cls;
-  cron_t expire;
-  cron_t now;
+  GNUNET_CronTime expire;
+  GNUNET_CronTime now;
 
   switch (ntohl (value->type))
     {
@@ -108,19 +108,19 @@
       data->stat_prio[2]++;
       break;
     }
-  expire = ntohll (value->expirationTime);
-  now = get_time ();
+  expire = GNUNET_ntohll (value->expirationTime);
+  now = GNUNET_get_time ();
   if (expire <= now)
     data->stat_expire[0]++;
-  else if (expire <= now + 1 * cronHOURS)
+  else if (expire <= now + 1 * GNUNET_CRON_HOURS)
     data->stat_expire[1]++;
-  else if (expire <= now + 1 * cronDAYS)
+  else if (expire <= now + 1 * GNUNET_CRON_DAYS)
     data->stat_expire[2]++;
-  else if (expire <= now + 1 * cronWEEKS)
+  else if (expire <= now + 1 * GNUNET_CRON_WEEKS)
     data->stat_expire[3]++;
-  else if (expire <= now + 1 * cronMONTHS)
+  else if (expire <= now + 1 * GNUNET_CRON_MONTHS)
     data->stat_expire[4]++;
-  return OK;
+  return GNUNET_OK;
 }
 
 static void
@@ -146,7 +146,7 @@
 {
   sq = myCoreAPI->requestService ("sqstore");
   if (sq == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   stat_block[0] = stats->create (gettext_noop ("# Any-Blocks"));
   stat_block[1] = stats->create (gettext_noop ("# DBlocks"));
   stat_block[2] = stats->create (gettext_noop ("# SBlocks"));
@@ -166,7 +166,7 @@
   stat_anon[3] = stats->create (gettext_noop ("# no anonymity"));
   stat_anon[1] = stats->create (gettext_noop ("# anonymity one"));
   stat_anon[2] = stats->create (gettext_noop ("# anonymity larger than one"));
-  return OK;
+  return GNUNET_OK;
 }
 
 static void

Modified: GNUnet/src/applications/stats/statistics.c
===================================================================
--- GNUnet/src/applications/stats/statistics.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/stats/statistics.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -43,17 +43,17 @@
 
 /**
  * Should we generate *very* costly statistics about
- * the SQStore?  Only set to YES for debugging, never
+ * the SQStore?  Only set to GNUNET_YES for debugging, never
  * in production!
  */
-#define HAVE_SQSTATS NO
+#define HAVE_SQSTATS GNUNET_NO
 
 /* *************** service *************** */
 
 /**
  * When did the module start?
  */
-static cron_t startTime;
+static GNUNET_CronTime startTime;
 
 struct StatEntry
 {
@@ -72,7 +72,7 @@
 /**
  * lock for the stat module
  */
-static struct MUTEX *statLock;
+static struct GNUNET_Mutex *statLock;
 
 /**
  * The core API.
@@ -90,18 +90,18 @@
 {
   int i;
   GE_ASSERT (NULL, name != NULL);
-  MUTEX_LOCK (statLock);
+  GNUNET_mutex_lock (statLock);
   for (i = 0; i < statCounters; i++)
     if (0 == strcmp (entries[i].description, name))
       {
-        MUTEX_UNLOCK (statLock);
+        GNUNET_mutex_unlock (statLock);
         return i;
       }
-  GROW (entries, statCounters, statCounters + 1);
-  entries[statCounters - 1].description = STRDUP (name);
+  GNUNET_array_grow (entries, statCounters, statCounters + 1);
+  entries[statCounters - 1].description = GNUNET_strdup (name);
   entries[statCounters - 1].descStrLen = strlen (name);
   entries[statCounters - 1].value = 0;
-  MUTEX_UNLOCK (statLock);
+  GNUNET_mutex_unlock (statLock);
   return statCounters - 1;
 }
 
@@ -115,30 +115,30 @@
 static void
 statSet (const int handle, const unsigned long long value)
 {
-  MUTEX_LOCK (statLock);
+  GNUNET_mutex_lock (statLock);
   if ((handle < 0) || (handle >= statCounters))
     {
       GE_BREAK (NULL, 0);
-      MUTEX_UNLOCK (statLock);
+      GNUNET_mutex_unlock (statLock);
       return;
     }
   entries[handle].value = value;
-  MUTEX_UNLOCK (statLock);
+  GNUNET_mutex_unlock (statLock);
 }
 
 static unsigned long long
 statGet (const int handle)
 {
   unsigned long long ret;
-  MUTEX_LOCK (statLock);
+  GNUNET_mutex_lock (statLock);
   if ((handle < 0) || (handle >= statCounters))
     {
       GE_BREAK (NULL, 0);
-      MUTEX_UNLOCK (statLock);
+      GNUNET_mutex_unlock (statLock);
       return -1;
     }
   ret = entries[handle].value;
-  MUTEX_UNLOCK (statLock);
+  GNUNET_mutex_unlock (statLock);
   return ret;
 }
 
@@ -152,15 +152,15 @@
 static void
 statChange (const int handle, const int delta)
 {
-  MUTEX_LOCK (statLock);
+  GNUNET_mutex_lock (statLock);
   if ((handle < 0) || (handle >= statCounters))
     {
       GE_BREAK (NULL, 0);
-      MUTEX_UNLOCK (statLock);
+      GNUNET_mutex_unlock (statLock);
       return;
     }
   entries[handle].value += delta;
-  MUTEX_UNLOCK (statLock);
+  GNUNET_mutex_unlock (statLock);
 }
 
 
@@ -172,10 +172,10 @@
 {
   int i;
 
-  MUTEX_DESTROY (statLock);
+  GNUNET_mutex_destroy (statLock);
   for (i = 0; i < statCounters; i++)
-    FREE (entries[i].description);
-  GROW (entries, statCounters, 0);
+    GNUNET_free (entries[i].description);
+  GNUNET_array_grow (entries, statCounters, 0);
 }
 
 
@@ -192,8 +192,8 @@
   api.set = &statSet;
   api.change = &statChange;
   api.get = &statGet;
-  startTime = get_time ();
-  statLock = MUTEX_CREATE (YES);
+  startTime = GNUNET_get_time ();
+  statLock = GNUNET_mutex_create (GNUNET_YES);
   return &api;
 }
 
@@ -238,19 +238,22 @@
 #if HAVE_SQSTATS
   update_sqstore_stats ();
 #endif
-  load = os_cpu_get_load (coreAPI->ectx, coreAPI->cfg);
+  load = GNUNET_cpu_get_load (coreAPI->ectx, coreAPI->cfg);
   if (load == -1)
     load = 0;
   statSet (stat_handle_cpu_load, load);
-  load = os_disk_get_load (coreAPI->ectx, coreAPI->cfg);
+  load = GNUNET_disk_get_load (coreAPI->ectx, coreAPI->cfg);
   if (load == -1)
     load = 0;
   statSet (stat_handle_io_load, load);
-  load = os_network_monitor_get_load (coreAPI->load_monitor, Upload);
+  load =
+    GNUNET_network_monitor_get_load (coreAPI->load_monitor, GNUNET_ND_UPLOAD);
   if (load == -1)
     load = 0;
   statSet (stat_handle_network_load_up, load);
-  load = os_network_monitor_get_load (coreAPI->load_monitor, Download);
+  load =
+    GNUNET_network_monitor_get_load (coreAPI->load_monitor,
+                                     GNUNET_ND_DOWNLOAD);
   if (load == -1)
     load = 0;
   statSet (stat_handle_network_load_down, load);
@@ -266,7 +269,7 @@
  */
 static int
 sendStatistics (struct ClientHandle *sock,
-                const MESSAGE_HEADER * originalRequestMessage)
+                const GNUNET_MessageHeader * originalRequestMessage)
 {
   CS_stats_reply_MESSAGE *statMsg;
   int pos;                      /* position in the values-descriptions */
@@ -275,11 +278,11 @@
   int mpos;                     /* postion in the message */
 
   immediateUpdates ();
-  statMsg = MALLOC (MAX_BUFFER_SIZE);
+  statMsg = GNUNET_malloc (GNUNET_MAX_BUFFER_SIZE);
   statMsg->header.type = htons (CS_PROTO_stats_STATISTICS);
   statMsg->totalCounters = htonl (statCounters);
   statMsg->statCounters = htons (0);
-  statMsg->startTime = htonll (startTime);
+  statMsg->startTime = GNUNET_htonll (startTime);
 
   start = 0;
   while (start < statCounters)
@@ -291,7 +294,7 @@
       while ((pos < statCounters) &&
              (mpos + sizeof (unsigned long long)
               + entries[pos].descStrLen + 1
-              < MAX_BUFFER_SIZE - sizeof (CS_stats_reply_MESSAGE)))
+              < GNUNET_MAX_BUFFER_SIZE - sizeof (CS_stats_reply_MESSAGE)))
         {
           mpos += sizeof (unsigned long long);  /* value */
           mpos += entries[pos].descStrLen + 1;
@@ -301,7 +304,7 @@
       /* second pass: copy values and messages to message */
       for (pos = start; pos < end; pos++)
         ((CS_stats_reply_MESSAGE_GENERIC *) statMsg)->values[pos - start] =
-          htonll (entries[pos].value);
+          GNUNET_htonll (entries[pos].value);
       mpos = sizeof (unsigned long long) * (end - start);
       for (pos = start; pos < end; pos++)
         {
@@ -313,18 +316,20 @@
         }
       statMsg->statCounters = htonl (end - start);
       GE_ASSERT (NULL,
-                 mpos + sizeof (CS_stats_reply_MESSAGE) < MAX_BUFFER_SIZE);
+                 mpos + sizeof (CS_stats_reply_MESSAGE) <
+                 GNUNET_MAX_BUFFER_SIZE);
 
       statMsg->header.size = htons (mpos + sizeof (CS_stats_reply_MESSAGE));
       /* printf("writing message of size %d with stats %d to %d out of %d to 
socket\n",
          ntohs(statMsg->header.size),
          start, end, statCounters); */
-      if (SYSERR == coreAPI->sendToClient (sock, &statMsg->header, YES))
+      if (GNUNET_SYSERR ==
+          coreAPI->sendToClient (sock, &statMsg->header, GNUNET_YES))
         break;                  /* abort, socket error! */
       start = end;
     }
-  FREE (statMsg);
-  return OK;
+  GNUNET_free (statMsg);
+  return GNUNET_OK;
 }
 
 /**
@@ -332,7 +337,7 @@
  */
 static int
 handleMessageSupported (struct ClientHandle *sock,
-                        const MESSAGE_HEADER * message)
+                        const GNUNET_MessageHeader * message)
 {
   unsigned short type;
   unsigned short htype;
@@ -342,7 +347,7 @@
   if (ntohs (message->size) != sizeof (CS_stats_get_supported_MESSAGE))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   cmsg = (CS_stats_get_supported_MESSAGE *) message;
   type = ntohs (cmsg->type);
@@ -357,16 +362,16 @@
  *
  * @param client the socket connecting to the client
  * @param msg the request from the client
- * @returns OK if ok, SYSERR if not.
+ * @returns GNUNET_OK if ok, GNUNET_SYSERR if not.
  */
 static int
 processGetConnectionCountRequest (struct ClientHandle *client,
-                                  const MESSAGE_HEADER * msg)
+                                  const GNUNET_MessageHeader * msg)
 {
-  if (ntohs (msg->size) != sizeof (MESSAGE_HEADER))
+  if (ntohs (msg->size) != sizeof (GNUNET_MessageHeader))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   return coreAPI->sendValueToClient
     (client, coreAPI->forAllConnectedNodes (NULL, NULL));
@@ -376,10 +381,11 @@
  * Handler for processing noise.
  */
 static int
-processNoise (const PeerIdentity * sender, const MESSAGE_HEADER * msg)
+processNoise (const GNUNET_PeerIdentity * sender,
+              const GNUNET_MessageHeader * msg)
 {
   statChange (stat_bytes_noise_received, ntohs (msg->size));
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -393,7 +399,7 @@
     {
       GE_BREAK (capi->ectx, 0);
       myCoreAPI = NULL;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   initializeStats ();
   GE_LOG (capi->ectx,
@@ -423,7 +429,7 @@
   init_sqstore_stats ();
 #endif
   immediateUpdates ();
-  return OK;
+  return GNUNET_OK;
 }
 
 int
@@ -445,7 +451,7 @@
   myCoreAPI->releaseService (stats);
   stats = NULL;
   myCoreAPI = NULL;
-  return OK;
+  return GNUNET_OK;
 }
 
 

Modified: GNUnet/src/applications/stats/statistics.h
===================================================================
--- GNUnet/src/applications/stats/statistics.h  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/stats/statistics.h  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -34,13 +34,13 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
   /**
    * For 64-bit alignment...
    */
   int reserved;
   /* timestamp  (network byte order) */
-  cron_t startTime;
+  GNUNET_CronTime startTime;
   /* total number of statistical counters */
   int totalCounters;
   /* number of statistical counters in this message */
@@ -72,7 +72,7 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * The type of the message (XX_CS_PROTO_XXXX)

Modified: GNUnet/src/applications/tbench/Makefile.am
===================================================================
--- GNUnet/src/applications/tbench/Makefile.am  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/tbench/Makefile.am  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -3,10 +3,7 @@
 plugindir = $(libdir)/GNUnet
 
 LDADD = \
-  $(top_builddir)/src/util/libgnunetutil.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
-  $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
+  $(top_builddir)/src/util/libgnunetutil.la 
 
 bin_PROGRAMS = \
   gnunet-tbench
@@ -25,8 +22,6 @@
   tbench.c\
   tbench.h
 libgnunetmodule_tbench_la_LIBADD = \
-  $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 libgnunetmodule_tbench_la_LDFLAGS = \
   -export-dynamic -avoid-version -module
@@ -47,10 +42,6 @@
 tbenchtest_tcp_LDADD = \
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
   $(top_builddir)/src/applications/testing/libgnunettesting_api.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
-  $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 tbenchtest_udp_SOURCES = \
@@ -69,10 +60,6 @@
 tbenchtest_http_LDADD = \
   $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
   $(top_builddir)/src/applications/testing/libgnunettesting_api.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
-  $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 
 EXTRA_DIST = \

Modified: GNUnet/src/applications/tbench/gnunet-tbench.c
===================================================================
--- GNUnet/src/applications/tbench/gnunet-tbench.c      2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/tbench/gnunet-tbench.c      2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -27,13 +27,11 @@
 #include "platform.h"
 #include "gnunet_directories.h"
 #include "gnunet_protocols.h"
-#include "gnunet_util_network_client.h"
-#include "gnunet_util_boot.h"
-#include "gnunet_util_crypto.h"
+#include "gnunet_util.h"
 #include "tbench.h"
 
 #define DEFAULT_MESSAGE_SIZE  10
-#define DEFAULT_TIMEOUT        (2 * cronSECONDS)
+#define DEFAULT_TIMEOUT        (2 * GNUNET_CRON_SECONDS)
 #define DEFAULT_SPACING        0
 
 #define OF_HUMAN_READABLE 0
@@ -49,9 +47,9 @@
 
 static unsigned long long messageTrainSize = 1;
 
-static cron_t messageTimeOut = DEFAULT_TIMEOUT;
+static GNUNET_CronTime messageTimeOut = DEFAULT_TIMEOUT;
 
-static cron_t messageSpacing = DEFAULT_SPACING;
+static GNUNET_CronTime messageSpacing = DEFAULT_SPACING;
 
 static int outputFormat = OF_HUMAN_READABLE;
 
@@ -60,38 +58,38 @@
 /**
  * All gnunet-tbench command line options
  */
-static struct CommandLineOption gnunettbenchOptions[] = {
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Start GNUnet transport benchmarking 
tool.")),        /* -h */
+static struct GNUNET_CommandLineOption gnunettbenchOptions[] = {
+       GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
+       GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Start GNUnet transport 
benchmarking tool.")),        /* -h */
   {'g', "gnuplot", NULL,
    gettext_noop ("output in gnuplot format"), 0,
-   &gnunet_getopt_configure_set_one, &outputFormat},
-  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
+   &GNUNET_getopt_configure_set_one, &outputFormat},
+  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
   {'i', "iterations", "ITER",
    gettext_noop ("number of iterations"), 1,
-   &gnunet_getopt_configure_set_ulong, &messageIterations},
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+   &GNUNET_getopt_configure_set_ulong, &messageIterations},
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'n', "msg", "MESSAGES",
    gettext_noop ("number of messages to use per iteration"), 1,
-   &gnunet_getopt_configure_set_ulong, &messageCnt},
+   &GNUNET_getopt_configure_set_ulong, &messageCnt},
   {'r', "rec", "RECEIVER",
    gettext_noop ("receiver host identifier (ENC file name)"), 1,
-   &gnunet_getopt_configure_set_string, &messageReceiver},
+   &GNUNET_getopt_configure_set_string, &messageReceiver},
   {'s', "size", "SIZE",
    gettext_noop ("message size"), 1,
-   &gnunet_getopt_configure_set_ulong, &messageSize},
+   &GNUNET_getopt_configure_set_ulong, &messageSize},
   {'S', "space", "SPACE",
    gettext_noop ("sleep for SPACE ms after each a message block"), 1,
-   &gnunet_getopt_configure_set_ulong, &messageSpacing},
+   &GNUNET_getopt_configure_set_ulong, &messageSpacing},
   {'t', "timeout", "TIMEOUT",
    gettext_noop ("time to wait for the completion of an iteration (in ms)"),
    1,
-   &gnunet_getopt_configure_set_ulong, &messageTimeOut},
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
+   &GNUNET_getopt_configure_set_ulong, &messageTimeOut},
+   GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
   {'X', "xspace", "COUNT",
    gettext_noop ("number of messages in a message block"), 1,
-   &gnunet_getopt_configure_set_ulong, &messageTrainSize},
-  COMMAND_LINE_OPTION_END,
+   &GNUNET_getopt_configure_set_ulong, &messageTrainSize},
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 
@@ -105,7 +103,7 @@
 int
 main (int argc, char *const *argv)
 {
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   CS_tbench_request_MESSAGE msg;
   CS_tbench_reply_MESSAGE *buffer;
   float messagesPercentLoss;
@@ -122,7 +120,7 @@
       GNUNET_fini (ectx, cfg);
       return -1;
     }
-  sock = client_connection_create (ectx, cfg);
+  sock = GNUNET_client_connection_create (ectx, cfg);
   if (sock == NULL)
     {
       fprintf (stderr, _("Error establishing connection with gnunetd.\n"));
@@ -135,39 +133,42 @@
   msg.msgSize = htonl (messageSize);
   msg.msgCnt = htonl (messageCnt);
   msg.iterations = htonl (messageIterations);
-  msg.intPktSpace = htonll (messageSpacing);
+  msg.intPktSpace = GNUNET_htonll (messageSpacing);
   msg.trainSize = htonl (messageTrainSize);
-  msg.timeOut = htonll (messageTimeOut);
+  msg.timeOut = GNUNET_htonll (messageTimeOut);
   msg.priority = htonl (5);
   if (messageReceiver == NULL)
     {
       fprintf (stderr, _("You must specify a receiver!\n"));
-      connection_destroy (sock);
+      GNUNET_client_connection_destroy (sock);
       GNUNET_fini (ectx, cfg);
       return 1;
     }
-  if (OK != enc2hash (messageReceiver, &msg.receiverId.hashPubKey))
+  if (GNUNET_OK !=
+      GNUNET_enc_to_hash (messageReceiver, &msg.receiverId.hashPubKey))
     {
       fprintf (stderr,
                _
                ("Invalid receiver peer ID specified (`%s' is not valid 
name).\n"),
                messageReceiver);
-      FREE (messageReceiver);
-      connection_destroy (sock);
+      GNUNET_free (messageReceiver);
+      GNUNET_client_connection_destroy (sock);
       GNUNET_fini (ectx, cfg);
       return 1;
     }
-  FREE (messageReceiver);
+  GNUNET_free (messageReceiver);
 
-  if (SYSERR == connection_write (sock, &msg.header))
+  if (GNUNET_SYSERR == GNUNET_client_connection_write (sock, &msg.header))
     {
-      connection_destroy (sock);
+      GNUNET_client_connection_destroy (sock);
       GNUNET_fini (ectx, cfg);
       return -1;
     }
 
   buffer = NULL;
-  if (OK == connection_read (sock, (MESSAGE_HEADER **) & buffer))
+  if (GNUNET_OK ==
+      GNUNET_client_connection_read (sock,
+                                     (GNUNET_MessageHeader **) & buffer))
     {
       GE_ASSERT (ectx,
                  ntohs (buffer->header.size) ==
@@ -186,8 +187,8 @@
         {
         case OF_HUMAN_READABLE:
           printf (_("Time:\n"));
-          PRINTF (_("\tmax      %llums\n"), ntohll (buffer->max_time));
-          PRINTF (_("\tmin      %llums\n"), ntohll (buffer->min_time));
+          PRINTF (_("\tmax      %llums\n"), GNUNET_ntohll (buffer->max_time));
+          PRINTF (_("\tmin      %llums\n"), GNUNET_ntohll (buffer->min_time));
           printf (_("\tmean     %8.4fms\n"), buffer->mean_time);
           printf (_("\tvariance %8.4fms\n"), buffer->variance_time);
 
@@ -203,13 +204,13 @@
         default:
           printf (_("Output format not known, this should not happen.\n"));
         }
-      FREE (buffer);
+      GNUNET_free (buffer);
     }
   else
     printf (_
             ("\nDid not receive the message from gnunetd. Is gnunetd 
running?\n"));
 
-  connection_destroy (sock);
+  GNUNET_client_connection_destroy (sock);
   GNUNET_fini (ectx, cfg);
   return 0;
 }

Modified: GNUnet/src/applications/tbench/tbench.c
===================================================================
--- GNUnet/src/applications/tbench/tbench.c     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/tbench/tbench.c     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -28,11 +28,11 @@
 #include "gnunet_protocols.h"
 #include "tbench.h"
 
-#define DEBUG_TBENCH NO
+#define DEBUG_TBENCH GNUNET_NO
 
 typedef struct
 {
-  cron_t totalTime;
+  GNUNET_CronTime totalTime;
   unsigned char *packetsReceived;
   unsigned int maxPacketNumber;
   unsigned int lossCount;
@@ -45,7 +45,7 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
   unsigned int iterationNum;
   unsigned int packetNum;
   unsigned int priority;
@@ -56,9 +56,9 @@
 /**
  * Lock for access to semaphores.
  */
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
-static struct SEMAPHORE *postsem;
+static struct GNUNET_Semaphore *postsem;
 
 /**
  * What is the current iteration counter? (Used to verify
@@ -69,7 +69,7 @@
 static unsigned int currNounce;
 
 /**
- * Did the current iteration time-out? (YES/NO)
+ * Did the current iteration time-out? (GNUNET_YES/GNUNET_NO)
  */
 static int timeoutOccured;
 
@@ -83,7 +83,7 @@
  * Did we receive the last response for the current iteration
  * before the timeout? If so, when?
  */
-static cron_t earlyEnd;
+static GNUNET_CronTime earlyEnd;
 
 
 /**
@@ -91,9 +91,10 @@
  * around and send it back.
  */
 static int
-handleTBenchReq (const PeerIdentity * sender, const MESSAGE_HEADER * message)
+handleTBenchReq (const GNUNET_PeerIdentity * sender,
+                 const GNUNET_MessageHeader * message)
 {
-  MESSAGE_HEADER *reply;
+  GNUNET_MessageHeader *reply;
   const P2P_tbench_MESSAGE *msg;
 
 #if DEBUG_TBENCH
@@ -102,15 +103,15 @@
   if (ntohs (message->size) < sizeof (P2P_tbench_MESSAGE))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   msg = (const P2P_tbench_MESSAGE *) message;
-  if (crc32N (&msg[1],
-              ntohs (message->size) - sizeof (P2P_tbench_MESSAGE))
+  if (GNUNET_crc32_n (&msg[1],
+                      ntohs (message->size) - sizeof (P2P_tbench_MESSAGE))
       != ntohl (msg->crc))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
 #if DEBUG_TBENCH
@@ -120,20 +121,20 @@
           htonl (msg->packetNum),
           htonl (msg->iterationNum), htonl (msg->nounce));
 #endif
-  reply = MALLOC (ntohs (message->size));
+  reply = GNUNET_malloc (ntohs (message->size));
   memcpy (reply, message, ntohs (message->size));
   reply->type = htons (P2P_PROTO_tbench_REPLY);
   coreAPI->unicast (sender, reply, ntohl (msg->priority), 0);   /* no delay */
-  FREE (reply);
-  return OK;
+  GNUNET_free (reply);
+  return GNUNET_OK;
 }
 
 /**
  * We received a tbench-reply.  Check and count stats.
  */
 static int
-handleTBenchReply (const PeerIdentity * sender,
-                   const MESSAGE_HEADER * message)
+handleTBenchReply (const GNUNET_PeerIdentity * sender,
+                   const GNUNET_MessageHeader * message)
 {
   const P2P_tbench_MESSAGE *pmsg;
   unsigned int lastPacketNumber;
@@ -142,18 +143,18 @@
   if (ntohs (message->size) < sizeof (P2P_tbench_MESSAGE))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   pmsg = (const P2P_tbench_MESSAGE *) message;
-  if (crc32N (&pmsg[1],
-              ntohs (message->size) - sizeof (P2P_tbench_MESSAGE))
+  if (GNUNET_crc32_n (&pmsg[1],
+                      ntohs (message->size) - sizeof (P2P_tbench_MESSAGE))
       != ntohl (pmsg->crc))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  MUTEX_LOCK (lock);
-  if ((timeoutOccured == NO) &&
+  GNUNET_mutex_lock (lock);
+  if ((timeoutOccured == GNUNET_NO) &&
       (postsem != NULL) &&
       (htonl (pmsg->iterationNum) == currIteration) &&
       (htonl (pmsg->nounce) == currNounce))
@@ -166,7 +167,7 @@
             {
               res->lossCount--;
               if (res->lossCount == 0)
-                earlyEnd = get_time ();
+                earlyEnd = GNUNET_get_time ();
             }
           else
             {
@@ -191,8 +192,8 @@
               ntohl (pmsg->iterationNum), currIteration);
 #endif
     }
-  MUTEX_UNLOCK (lock);
-  return OK;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 /**
@@ -201,9 +202,9 @@
 static void
 semaUp (void *cls)
 {
-  struct SEMAPHORE *sem = cls;
-  timeoutOccured = YES;
-  SEMAPHORE_UP (sem);
+  struct GNUNET_Semaphore *sem = cls;
+  timeoutOccured = GNUNET_YES;
+  GNUNET_semaphore_up (sem);
 }
 
 /**
@@ -211,7 +212,7 @@
  */
 static int
 csHandleTBenchRequest (struct ClientHandle *client,
-                       const MESSAGE_HEADER * message)
+                       const GNUNET_MessageHeader * message)
 {
   CS_tbench_request_MESSAGE *msg;
   CS_tbench_reply_MESSAGE reply;
@@ -219,16 +220,16 @@
   unsigned short size;
   unsigned int iteration;
   unsigned int packetNum;
-  cron_t startTime;
-  cron_t endTime;
-  cron_t now;
-  cron_t delay;
+  GNUNET_CronTime startTime;
+  GNUNET_CronTime endTime;
+  GNUNET_CronTime now;
+  GNUNET_CronTime delay;
   unsigned long long sum_loss;
   unsigned int max_loss;
   unsigned int min_loss;
-  cron_t sum_time;
-  cron_t min_time;
-  cron_t max_time;
+  GNUNET_CronTime sum_time;
+  GNUNET_CronTime min_time;
+  GNUNET_CronTime max_time;
   double sum_variance_time;
   double sum_variance_loss;
   unsigned int msgCnt;
@@ -240,13 +241,13 @@
           "Tbench received request from client.\n", msgCnt, size, iterations);
 #endif
   if (ntohs (message->size) != sizeof (CS_tbench_request_MESSAGE))
-    return SYSERR;
+    return GNUNET_SYSERR;
 
   msg = (CS_tbench_request_MESSAGE *) message;
   size = sizeof (P2P_tbench_MESSAGE) + ntohl (msg->msgSize);
   if (size < sizeof (P2P_tbench_MESSAGE))
-    return SYSERR;
-  delay = ntohll (msg->intPktSpace);
+    return GNUNET_SYSERR;
+  delay = GNUNET_ntohll (msg->intPktSpace);
   iterations = ntohl (msg->iterations);
   msgCnt = ntohl (msg->msgCnt);
 #if DEBUG_TBENCH
@@ -255,18 +256,18 @@
           "Tbench runs %u test messages of size %u in %u iterations.\n",
           msgCnt, size, iterations);
 #endif
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   if (results != NULL)
     {
       GE_LOG (ectx,
               GE_WARNING | GE_USER | GE_IMMEDIATE,
               "Cannot run multiple tbench sessions at the same time!\n");
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
-  results = MALLOC (sizeof (IterationData) * iterations);
+  results = GNUNET_malloc (sizeof (IterationData) * iterations);
 
-  p2p = MALLOC (size);
+  p2p = GNUNET_malloc (size);
   memset (p2p, 0, size);
   p2p->header.size = htons (size);
   p2p->header.type = htons (P2P_PROTO_tbench_REQUEST);
@@ -275,31 +276,35 @@
   for (iteration = 0; iteration < iterations; iteration++)
     {
       results[iteration].maxPacketNumber = msgCnt;
-      results[iteration].packetsReceived = MALLOC (msgCnt);
+      results[iteration].packetsReceived = GNUNET_malloc (msgCnt);
       memset (results[iteration].packetsReceived, 0, msgCnt);
       results[iteration].lossCount = msgCnt;
       results[iteration].duplicateCount = 0;
 
       earlyEnd = 0;
-      postsem = SEMAPHORE_CREATE (0);
-      currNounce = weak_randomi (0xFFFFFF);
+      postsem = GNUNET_semaphore_create (0);
+      currNounce = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 0xFFFFFF);
       p2p->nounce = htonl (currNounce);
       currIteration = iteration;
       p2p->iterationNum = htonl (currIteration);
       memset (&p2p[1],
-              weak_randomi (256), size - sizeof (P2P_tbench_MESSAGE));
-      p2p->crc = htonl (crc32N (&p2p[1], size - sizeof (P2P_tbench_MESSAGE)));
-      MUTEX_UNLOCK (lock);      /* allow receiving */
+              GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 256),
+              size - sizeof (P2P_tbench_MESSAGE));
+      p2p->crc =
+        htonl (GNUNET_crc32_n (&p2p[1], size - sizeof (P2P_tbench_MESSAGE)));
+      GNUNET_mutex_unlock (lock);       /* allow receiving */
 
-      startTime = get_time ();
-      endTime = startTime + ntohll (msg->timeOut);
+      startTime = GNUNET_get_time ();
+      endTime = startTime + GNUNET_ntohll (msg->timeOut);
 
-      timeoutOccured = NO;
-      cron_add_job (coreAPI->cron,
-                    &semaUp, ntohll (msg->timeOut) * cronMILLIS, 0, postsem);
+      timeoutOccured = GNUNET_NO;
+      GNUNET_cron_add_job (coreAPI->cron,
+                           &semaUp,
+                           GNUNET_ntohll (msg->timeOut) *
+                           GNUNET_CRON_MILLISECONDS, 0, postsem);
       for (packetNum = 0; packetNum < msgCnt; packetNum++)
         {
-          now = get_time ();
+          now = GNUNET_get_time ();
           p2p->packetNum = htonl (packetNum);
 #if DEBUG_TBENCH
           GE_LOG (ectx,
@@ -311,19 +316,19 @@
           if ((delay != 0) &&
               (htonl (msg->trainSize) != 0) &&
               (packetNum % htonl (msg->trainSize)) == 0)
-            PTHREAD_SLEEP (delay);
+            GNUNET_thread_sleep (delay);
         }
-      SEMAPHORE_DOWN (postsem, YES);
-      MUTEX_LOCK (lock);
+      GNUNET_semaphore_down (postsem, GNUNET_YES);
+      GNUNET_mutex_lock (lock);
       if (earlyEnd == 0)
-        earlyEnd = get_time ();
+        earlyEnd = GNUNET_get_time ();
       results[iteration].totalTime = earlyEnd - startTime;
-      FREE (results[iteration].packetsReceived);
-      SEMAPHORE_DESTROY (postsem);
+      GNUNET_free (results[iteration].packetsReceived);
+      GNUNET_semaphore_destroy (postsem);
       postsem = NULL;
     }
-  MUTEX_UNLOCK (lock);
-  FREE (p2p);
+  GNUNET_mutex_unlock (lock);
+  GNUNET_free (p2p);
 #if DEBUG_TBENCH
   GE_LOG (ectx,
           GE_DEBUG | GE_BULK | GE_USER,
@@ -334,7 +339,7 @@
   sum_time = 0;
   max_loss = 0;
   min_loss = msgCnt;
-  min_time = 1 * cronYEARS;
+  min_time = 1 * GNUNET_CRON_YEARS;
   max_time = 0;
   /* data post-processing */
   for (iteration = 0; iteration < iterations; iteration++)
@@ -371,37 +376,37 @@
   reply.min_loss = htonl (min_loss);
   reply.mean_loss = ((float) sum_loss / (float) iterations);
   reply.mean_time = ((float) sum_time / (float) iterations);
-  reply.max_time = htonll (max_time);
-  reply.min_time = htonll (min_time);
+  reply.max_time = GNUNET_htonll (max_time);
+  reply.min_time = GNUNET_htonll (min_time);
   reply.variance_time = sum_variance_time / (iterations - 1);
   reply.variance_loss = sum_variance_loss / (iterations - 1);
-  FREE (results);
+  GNUNET_free (results);
   results = NULL;
-  return coreAPI->sendToClient (client, &reply.header, YES);
+  return coreAPI->sendToClient (client, &reply.header, GNUNET_YES);
 }
 
 /**
  * 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_tbench (CoreAPIForApplication * capi)
 {
-  int ok = OK;
+  int ok = GNUNET_OK;
 
   ectx = capi->ectx;
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
   coreAPI = capi;
-  if (SYSERR == capi->registerHandler (P2P_PROTO_tbench_REPLY,
-                                       &handleTBenchReply))
-    ok = SYSERR;
-  if (SYSERR == capi->registerHandler (P2P_PROTO_tbench_REQUEST,
-                                       &handleTBenchReq))
-    ok = SYSERR;
-  if (SYSERR == capi->registerClientHandler (CS_PROTO_tbench_REQUEST,
-                                             &csHandleTBenchRequest))
-    ok = SYSERR;
+  if (GNUNET_SYSERR == capi->registerHandler (P2P_PROTO_tbench_REPLY,
+                                              &handleTBenchReply))
+    ok = GNUNET_SYSERR;
+  if (GNUNET_SYSERR == capi->registerHandler (P2P_PROTO_tbench_REQUEST,
+                                              &handleTBenchReq))
+    ok = GNUNET_SYSERR;
+  if (GNUNET_SYSERR == capi->registerClientHandler (CS_PROTO_tbench_REQUEST,
+                                                    &csHandleTBenchRequest))
+    ok = GNUNET_SYSERR;
 
   GE_ASSERT (capi->ectx,
              0 == GC_set_configuration_value_string (capi->cfg,
@@ -421,7 +426,7 @@
   coreAPI->unregisterHandler (P2P_PROTO_tbench_REPLY, &handleTBenchReply);
   coreAPI->unregisterClientHandler (CS_PROTO_tbench_REQUEST,
                                     &csHandleTBenchRequest);
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   lock = NULL;
   coreAPI = NULL;
 }

Modified: GNUnet/src/applications/tbench/tbench.h
===================================================================
--- GNUnet/src/applications/tbench/tbench.h     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/tbench/tbench.h     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -32,7 +32,7 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
   /**
    * How big is each message (plus headers).
    * Note that GNUnet is limited to 64k messages.
@@ -50,17 +50,17 @@
   /**
    * Which peer should receive the messages?
    */
-  PeerIdentity receiverId;
+  GNUNET_PeerIdentity receiverId;
   /**
    * Inter packet space in milliseconds (delay
    * introduced when sending messages).
    */
-  cron_t intPktSpace;
+  GNUNET_CronTime intPktSpace;
   /**
    * Time to wait for the arrival of all repies
    * in one iteration.
    */
-  cron_t timeOut;
+  GNUNET_CronTime timeOut;
   /**
    * intPktSpace delay is only introduced every
    * trainSize messages.
@@ -77,14 +77,14 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
   unsigned int max_loss;
   unsigned int min_loss;
   float mean_loss;
   float variance_loss;
 
-  cron_t max_time;
-  cron_t min_time;
+  GNUNET_CronTime max_time;
+  GNUNET_CronTime min_time;
   float mean_time;
   float variance_time;
 } CS_tbench_reply_MESSAGE;

Modified: GNUnet/src/applications/tbench/tbenchtest.c
===================================================================
--- GNUnet/src/applications/tbench/tbenchtest.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/tbench/tbenchtest.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -35,17 +35,17 @@
 
 #define START_PEERS 1
 
-static PeerIdentity peer1;
-static PeerIdentity peer2;
+static GNUNET_PeerIdentity peer1;
+static GNUNET_PeerIdentity peer2;
 
 static int
-test (struct ClientServerConnection *sock,
+test (struct GNUNET_ClientServerConnection *sock,
       unsigned int messageSize,
       unsigned int messageCnt,
       unsigned int messageIterations,
-      cron_t messageSpacing,
+      GNUNET_CronTime messageSpacing,
       unsigned int messageTrainSize,
-      cron_t messageTimeOut /* in milli-seconds */ )
+      GNUNET_CronTime messageTimeOut /* in milli-seconds */ )
 {
   int ret;
   CS_tbench_request_MESSAGE msg;
@@ -59,18 +59,20 @@
   msg.msgSize = htonl (messageSize);
   msg.msgCnt = htonl (messageCnt);
   msg.iterations = htonl (messageIterations);
-  msg.intPktSpace = htonll (messageSpacing);
+  msg.intPktSpace = GNUNET_htonll (messageSpacing);
   msg.trainSize = htonl (messageTrainSize);
-  msg.timeOut = htonll (messageTimeOut);
+  msg.timeOut = GNUNET_htonll (messageTimeOut);
   msg.priority = htonl (5);
   msg.receiverId = peer2;
 
-  if (SYSERR == connection_write (sock, &msg.header))
+  if (GNUNET_SYSERR == GNUNET_client_connection_write (sock, &msg.header))
     return -1;
   ret = 0;
 
   buffer = NULL;
-  if (OK == connection_read (sock, (MESSAGE_HEADER **) & buffer))
+  if (GNUNET_OK ==
+      GNUNET_client_connection_read (sock,
+                                     (GNUNET_MessageHeader **) & buffer))
     {
       if ((float) buffer->mean_loss <= 0)
         {
@@ -83,8 +85,9 @@
         }
       printf (_
               ("Times: max %16llu  min %16llu  mean %12.3f  variance 
%12.3f\n"),
-              ntohll (buffer->max_time), ntohll (buffer->min_time),
-              buffer->mean_time, buffer->variance_time);
+              GNUNET_ntohll (buffer->max_time),
+              GNUNET_ntohll (buffer->min_time), buffer->mean_time,
+              buffer->variance_time);
       printf (_("Loss:  max %16u  min %16u  mean %12.3f  variance %12.3f\n"),
               ntohl (buffer->max_loss), ntohl (buffer->min_loss),
               buffer->mean_loss, buffer->variance_loss);
@@ -94,7 +97,7 @@
       printf (_("\nFailed to receive reply from gnunetd.\n"));
       ret = -1;
     }
-  FREENONNULL (buffer);
+  GNUNET_free_non_null (buffer);
 
   return ret;
 }
@@ -110,17 +113,17 @@
 main (int argc, char **argv)
 {
 #if START_PEERS
-  struct DaemonContext *peers;
+  struct GNUNET_TESTING_DaemonContext *peers;
 #endif
   int i;
   int ok;
   int ret;
-  struct ClientServerConnection *sock;
+  struct GNUNET_ClientServerConnection *sock;
   struct GC_Configuration *cfg;
 
   ret = 0;
   ok = 1;
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
@@ -128,7 +131,7 @@
     }
 #if START_PEERS
   peers =
-    gnunet_testing_start_daemons (strstr (argv[0], "_") + 1,
+    GNUNET_TESTING_start_daemons (strstr (argv[0], "_") + 1,
                                   "advertising tbench topology stats",
                                   "/tmp/gnunet-tbench-test", 2087, 10000, 2);
   if (peers == NULL)
@@ -139,30 +142,34 @@
 #endif
   peer1 = peers->peer;
   peer2 = peers->next->peer;
-  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;
     }
-  sock = client_connection_create (NULL, cfg);
+  sock = GNUNET_client_connection_create (NULL, cfg);
   printf (_("Running benchmark...\n"));
   /* 'slow' pass: wait for bandwidth negotiation! */
   if (ret == 0)
-    ret = test (sock, 64, 100, 4, 50 * cronMILLIS, 1, 5 * cronSECONDS);
+    ret =
+      test (sock, 64, 100, 4, 50 * GNUNET_CRON_MILLISECONDS, 1,
+            5 * GNUNET_CRON_SECONDS);
   /* 'blast' pass: hit bandwidth limits! */
   for (i = 8; i < 60000; i *= 2)
     {
       if (ret == 0)
         ret =
-          test (sock, i, 1 + 1024 / i, 4, 10 * cronMILLIS, 2,
-                2 * cronSECONDS);
+          test (sock, i, 1 + 1024 / i, 4, 10 * GNUNET_CRON_MILLISECONDS, 2,
+                2 * GNUNET_CRON_SECONDS);
     }
-  ret = test (sock, 32768, 10, 10, 500 * cronMILLIS, 1, 10 * cronSECONDS);
-  connection_destroy (sock);
+  ret =
+    test (sock, 32768, 10, 10, 500 * GNUNET_CRON_MILLISECONDS, 1,
+          10 * GNUNET_CRON_SECONDS);
+  GNUNET_client_connection_destroy (sock);
 #if START_PEERS
-  gnunet_testing_stop_daemons (peers);
+  GNUNET_TESTING_stop_daemons (peers);
 #endif
   if (ok == 0)
     ret = 1;

Modified: GNUnet/src/applications/template/Makefile.am
===================================================================
--- GNUnet/src/applications/template/Makefile.am        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/template/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/network_client/libgnunetutil_network_client.la \
- $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 # change to bin_PROGRAMS for real apps
 noinst_PROGRAMS = \
@@ -22,7 +20,7 @@
   template.c 
 libgnunetmodule_template_la_LDFLAGS = \
   -export-dynamic -avoid-version -module \
-  $(top_builddir)/src/util/libgnunetutil.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la 
+  $(top_builddir)/src/util/libgnunetutil.la 
 
 
+

Modified: GNUnet/src/applications/template/gnunet-template.c
===================================================================
--- GNUnet/src/applications/template/gnunet-template.c  2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/template/gnunet-template.c  2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -25,41 +25,42 @@
  */
 
 #include "gnunet_util.h"
-#include "gnunet_util_network_client.h"
-#include "gnunet_util_boot.h"
+#include "gnunet_util.h"
 #include "platform.h"
 
 #define TEMPLATE_VERSION "0.0.0"
 
-static struct SEMAPHORE *doneSem;
+static struct GNUNET_Semaphore *doneSem;
 
 static char *cfgFilename;
 
 /**
  * All gnunetd command line options
  */
-static struct CommandLineOption gnunettemplateOptions[] = {
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Template description.")),    /* -h 
*/
-  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_END,
+static struct GNUNET_CommandLineOption gnunettemplateOptions[] = {
+       GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
+  GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Template description.")),    
/* -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_END,
 };
 
 static void *
 receiveThread (void *cls)
 {
-  struct ClientServerConnection *sock = cls;
+  struct GNUNET_ClientServerConnection *sock = cls;
   void *buffer;
 
-  buffer = MALLOC (MAX_BUFFER_SIZE);
-  while (OK == connection_read (sock, (MESSAGE_HEADER **) & buffer))
+  buffer = GNUNET_malloc (GNUNET_MAX_BUFFER_SIZE);
+  while (GNUNET_OK ==
+         GNUNET_client_connection_read (sock,
+                                        (GNUNET_MessageHeader **) & buffer))
     {
       /* process */
     }
-  FREE (buffer);
-  SEMAPHORE_UP (doneSem);
+  GNUNET_free (buffer);
+  GNUNET_semaphore_up (doneSem);
   return NULL;
 }
 
@@ -71,8 +72,8 @@
 int
 main (int argc, char *const *argv)
 {
-  struct ClientServerConnection *sock;
-  struct PTHREAD *messageReceiveThread;
+  struct GNUNET_ClientServerConnection *sock;
+  struct GNUNET_ThreadHandle *messageReceiveThread;
   void *unused;
   struct GE_Context *ectx;
   struct GC_Configuration *cfg;
@@ -88,14 +89,15 @@
       return -1;
     }
 
-  sock = client_connection_create (ectx, cfg);
+  sock = GNUNET_client_connection_create (ectx, cfg);
   if (sock == NULL)
     {
       fprintf (stderr, _("Error establishing connection with gnunetd.\n"));
       GNUNET_fini (ectx, cfg);
       return 1;
     }
-  messageReceiveThread = PTHREAD_CREATE (&receiveThread, sock, 128 * 1024);
+  messageReceiveThread =
+    GNUNET_thread_create (&receiveThread, sock, 128 * 1024);
   if (messageReceiveThread == NULL)
     {
       GE_DIE_STRERROR (ectx,
@@ -105,11 +107,11 @@
 
   /* wait for shutdown... */
 
-  connection_close_forever (sock);
-  SEMAPHORE_DOWN (doneSem, YES);
-  SEMAPHORE_DESTROY (doneSem);
-  PTHREAD_JOIN (messageReceiveThread, &unused);
-  connection_destroy (sock);
+  GNUNET_client_connection_close_forever (sock);
+  GNUNET_semaphore_down (doneSem, GNUNET_YES);
+  GNUNET_semaphore_destroy (doneSem);
+  GNUNET_thread_join (messageReceiveThread, &unused);
+  GNUNET_client_connection_destroy (sock);
   GNUNET_fini (ectx, cfg);
   return 0;
 }

Modified: GNUnet/src/applications/template/template.c
===================================================================
--- GNUnet/src/applications/template/template.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/template/template.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -31,35 +31,36 @@
 
 static CoreAPIForApplication *coreAPI = NULL;
 static struct ClientHandle *client;
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 static int
-handlep2pMSG (const PeerIdentity * sender, const MESSAGE_HEADER * message)
+handlep2pMSG (const GNUNET_PeerIdentity * sender,
+              const GNUNET_MessageHeader * message)
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
-csHandle (struct ClientHandle *client, const MESSAGE_HEADER * message)
+csHandle (struct ClientHandle *client, const GNUNET_MessageHeader * message)
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 static void
 clientExitHandler (struct ClientHandle *c)
 {
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   if (c == client)
     client = NULL;
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 int
 initialize_module_template (CoreAPIForApplication * capi)
 {
-  int ok = OK;
+  int ok = GNUNET_OK;
 
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
   client = NULL;
   coreAPI = capi;
 
@@ -67,12 +68,14 @@
           GE_DEBUG | GE_REQUEST | GE_USER,
           _("`%s' registering client handler %d and %d\n"),
           "template", CS_PROTO_MAX_USED, P2P_PROTO_MAX_USED);
-  if (SYSERR == capi->registerHandler (P2P_PROTO_MAX_USED, &handlep2pMSG))
-    ok = SYSERR;
-  if (SYSERR == capi->registerClientExitHandler (&clientExitHandler))
-    ok = SYSERR;
-  if (SYSERR == capi->registerClientHandler (CS_PROTO_MAX_USED, &csHandle))
-    ok = SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerHandler (P2P_PROTO_MAX_USED, &handlep2pMSG))
+    ok = GNUNET_SYSERR;
+  if (GNUNET_SYSERR == capi->registerClientExitHandler (&clientExitHandler))
+    ok = GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerClientHandler (CS_PROTO_MAX_USED, &csHandle))
+    ok = GNUNET_SYSERR;
   return ok;
 }
 
@@ -82,7 +85,7 @@
   coreAPI->unregisterHandler (P2P_PROTO_MAX_USED, &handlep2pMSG);
   coreAPI->unregisterClientExitHandler (&clientExitHandler);
   coreAPI->unregisterClientHandler (CS_PROTO_MAX_USED, &csHandle);
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   coreAPI = NULL;
 }
 

Modified: GNUnet/src/applications/testbed/commands.c
===================================================================
--- GNUnet/src/applications/testbed/commands.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/testbed/commands.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -46,15 +46,15 @@
 typedef struct
 {
   /** IP address of the peer */
-  IPaddr ip;
+  GNUNET_IPv4Address ip;
   /** CS port of the peer */
   unsigned short port;
   /** string describing the peer address */
   char *ips;
   /** socket to communicate with the peer */
-  struct ClientServerConnection sock;
+  struct GNUNET_ClientServerConnection sock;
   /** hello message identifying the peer in the network */
-  P2P_hello_MESSAGE *helo;
+  GNUNET_MessageHello *helo;
   /** if we're using ssh, what is the PID of the
       ssh process? (-1 for unencrypted direct connections) */
   pid_t ssh;
@@ -73,7 +73,7 @@
 /**
  * Should the driver exit?
  */
-int do_quit = NO;
+int do_quit = GNUNET_NO;
 
 /**
  * Convert the strings ss and ds to peer-identifiers (ints) s and d
@@ -114,36 +114,37 @@
     errexit ("Message body too big for sendMessage: %s\n", argSize);
 
   msgsz = sizeof (TESTBED_CS_MESSAGE) + argSize;
-  msg = MALLOC (msgsz);
+  msg = GNUNET_malloc (msgsz);
   msg->header.size = htons (msgsz);
   msg->header.type = htons (CS_PROTO_testbed_REQUEST);
   msg->msgType = htonl (msgType);
   memcpy (&((TESTBED_CS_MESSAGE_GENERIC *) msg)->data[0], arg, argSize);
-  msgsz = connection_write (&nodes[peer].sock, &msg->header);
-  FREE (msg);
-  if (msgsz == SYSERR)
+  msgsz = GNUNET_client_connection_write (&nodes[peer].sock, &msg->header);
+  GNUNET_free (msg);
+  if (msgsz == GNUNET_SYSERR)
     {
       XPRINTF (" Could not send message to peer %s.\n", nodes[peer].ips);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Read a result from the given peer.  Print
  * an error message if the peer fails to respond.
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
 readResult (int peer, int *result)
 {
-  if (OK != connection_read_result (&nodes[peer].sock, result))
+  if (GNUNET_OK !=
+      GNUNET_client_connection_read_result (&nodes[peer].sock, result))
     {
       XPRINTF (" peer %s is not responding.\n", nodes[peer].ips);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /* ****************** individual commands ********** */
@@ -182,8 +183,8 @@
   req.reserved = 0;
   /* connect */
   currindex = nnodes;
-  GROW (nodes, nnodes, nnodes + 1);
-  nodes[currindex].ips = STRDUP (argv[0]);
+  GNUNET_array_grow (nodes, nnodes, nnodes + 1);
+  nodes[currindex].ips = GNUNET_strdup (argv[0]);
   nodes[currindex].port = atoi (argv[1]);
   nodes[currindex].ssh = -1;
 #ifndef MINGW
@@ -192,9 +193,9 @@
   nodes[currindex].ip.addr.S_un.S_addr = inet_addr (argv[0]);
 #endif
 
-  if (SYSERR == initGNUnetClientSocket (nodes[currindex].port,
-                                        nodes[currindex].ips,
-                                        &nodes[currindex].sock))
+  if (GNUNET_SYSERR == initGNUnetClientSocket (nodes[currindex].port,
+                                               nodes[currindex].ips,
+                                               &nodes[currindex].sock))
     {
       XPRINTF (" could not connect to %s:%d.\n",
                nodes[currindex].ips, nodes[currindex].port);
@@ -202,51 +203,53 @@
     }
 
   /* request hello */
-  if (OK != sendMessage (TESTBED_GET_hello,
-                         currindex,
-                         sizeof (TESTBED_GET_hello_MESSAGE) -
-                         sizeof (TESTBED_CS_MESSAGE), &req.proto))
+  if (GNUNET_OK != sendMessage (TESTBED_GET_hello,
+                                currindex,
+                                sizeof (TESTBED_GET_hello_MESSAGE) -
+                                sizeof (TESTBED_CS_MESSAGE), &req.proto))
     {
       /* send message already printed an error message */
       destroySocket (&nodes[currindex].sock);
-      FREE (nodes[currindex].ips);
-      GROW (nodes, nnodes, nnodes - 1);
+      GNUNET_free (nodes[currindex].ips);
+      GNUNET_array_grow (nodes, nnodes, nnodes - 1);
       return -1;
     }
 
   hdr = NULL;
-  if (SYSERR == connection_read (&nodes[currindex].sock,
-                                 (CS_MESSAGE_HEADER **) & hdr))
+  if (GNUNET_SYSERR == GNUNET_client_connection_read (&nodes[currindex].sock,
+                                                      (CS_MESSAGE_HEADER **) &
+                                                      hdr))
     {
       XPRINTF (" peer %s is not responding.\n", nodes[currindex].ips);
       destroySocket (&nodes[currindex].sock);
-      FREE (nodes[currindex].ips);
-      GROW (nodes, nnodes, nnodes - 1);
+      GNUNET_free (nodes[currindex].ips);
+      GNUNET_array_grow (nodes, nnodes, nnodes - 1);
       return -1;
     }
   if ((ntohs (hdr->header.header.type) == CS_PROTO_testbed_REPLY) &&
       (ntohs (hdr->header.header.size) >= sizeof (TESTBED_hello_MESSAGE)) &&
       (ntohl (hdr->header.msgType) == TESTBED_hello_RESPONSE) &&
       (ntohs (hdr->header.header.size) - sizeof (TESTBED_CS_MESSAGE) >=
-       sizeof (P2P_hello_MESSAGE))
+       sizeof (GNUNET_MessageHello))
       && (ntohs (hdr->header.header.size) - sizeof (TESTBED_CS_MESSAGE) ==
-          P2P_hello_MESSAGE_size (&hdr->helo)))
+          GNUNET_sizeof_hello (&hdr->helo)))
     {
-      nodes[currindex].helo = MALLOC (P2P_hello_MESSAGE_size (&hdr->helo));
-      memcpy (nodes[currindex].helo,
-              &hdr->helo, P2P_hello_MESSAGE_size (&hdr->helo));
+      nodes[currindex].helo =
+        GNUNET_malloc (GNUNET_sizeof_hello (&hdr->helo));
+      memcpy (nodes[currindex].helo, &hdr->helo,
+              GNUNET_sizeof_hello (&hdr->helo));
     }
   else
     {
-      FREE (hdr);
+      GNUNET_free (hdr);
       destroySocket (&nodes[currindex].sock);
       XPRINTF (" peer %s did not respond with proper hello.\n",
                nodes[currindex].ips);
-      FREE (nodes[currindex].ips);
-      GROW (nodes, nnodes, nnodes - 1);
+      GNUNET_free (nodes[currindex].ips);
+      GNUNET_array_grow (nodes, nnodes, nnodes - 1);
       return -1;
     }
-  FREE (hdr);
+  GNUNET_free (hdr);
   XPRINTF ("%d\n", currindex);
   return 0;
 }
@@ -333,9 +336,9 @@
       sargv[1] = "-l";
       sargv[2] = argv[0];       /* login */
       sargv[3] = "-L";
-      SNPRINTF (pohopo, 64, "%d:%s:%d", lport,  /* local port */
-                "localhost",    /* loopback on remote host */
-                port /* remote port */ );
+      GNUNET_snprintf (pohopo, 64, "%d:%s:%d", lport,   /* local port */
+                       "localhost",     /* loopback on remote host */
+                       port /* remote port */ );
       sargv[4] = pohopo;
       sargv[5] = argv[1];       /* remote hostname */
       sargv[6] = NULL;          /* last argument */
@@ -355,8 +358,8 @@
   req.reserved = 0;
   /* connect */
   currindex = nnodes;
-  GROW (nodes, nnodes, nnodes + 1);
-  nodes[currindex].ips = STRDUP ("localhost");
+  GNUNET_array_grow (nodes, nnodes, nnodes + 1);
+  nodes[currindex].ips = GNUNET_strdup ("localhost");
   nodes[currindex].port = lport;
   nodes[currindex].ssh = pid;
 #ifndef MINGW
@@ -372,76 +375,78 @@
       ret = initGNUnetClientSocket (nodes[currindex].port,
                                     nodes[currindex].ips,
                                     &nodes[currindex].sock);
-      if (ret == OK)
+      if (ret == GNUNET_OK)
         break;
       rtc++;
-      PTHREAD_SLEEP (cronSECONDS);
+      GNUNET_thread_sleep (GNUNET_CRON_SECONDS);
     }
-  if (ret == SYSERR)
+  if (ret == GNUNET_SYSERR)
     {
       XPRINTF (" could not connect to %s:%d.\n",
                nodes[currindex].ips, nodes[currindex].port);
       kill (nodes[currindex].ssh, SIGTERM);
       waitpid (nodes[currindex].ssh, &status, 0);
-      GROW (nodes, nnodes, nnodes - 1);
+      GNUNET_array_grow (nodes, nnodes, nnodes - 1);
       return -1;
     }
 
   /* request hello */
-  if (OK != sendMessage (TESTBED_GET_hello,
-                         currindex,
-                         sizeof (TESTBED_GET_hello_MESSAGE) -
-                         sizeof (TESTBED_CS_MESSAGE), &req.proto))
+  if (GNUNET_OK != sendMessage (TESTBED_GET_hello,
+                                currindex,
+                                sizeof (TESTBED_GET_hello_MESSAGE) -
+                                sizeof (TESTBED_CS_MESSAGE), &req.proto))
     {
       /* send message already printed an error message */
       destroySocket (&nodes[currindex].sock);
-      FREE (nodes[currindex].ips);
+      GNUNET_free (nodes[currindex].ips);
       /* fixme: check error conditions on kill/waidpid! */
       kill (nodes[currindex].ssh, SIGTERM);
       waitpid (nodes[currindex].ssh, &status, 0);
-      GROW (nodes, nnodes, nnodes - 1);
+      GNUNET_array_grow (nodes, nnodes, nnodes - 1);
       return -1;
     }
 
   hdr = NULL;
-  if (SYSERR == connection_read (&nodes[currindex].sock,
-                                 (CS_MESSAGE_HEADER **) & hdr))
+  if (GNUNET_SYSERR == GNUNET_client_connection_read (&nodes[currindex].sock,
+                                                      (CS_MESSAGE_HEADER **) &
+                                                      hdr))
     {
       XPRINTF (" peer %s is not responding.\n", nodes[currindex].ips);
       destroySocket (&nodes[currindex].sock);
-      FREE (nodes[currindex].ips);
+      GNUNET_free (nodes[currindex].ips);
       /* fixme: check error conditions on kill/waidpid! */
       kill (nodes[currindex].ssh, SIGTERM);
       waitpid (nodes[currindex].ssh, &status, 0);
-      GROW (nodes, nnodes, nnodes - 1);
+      GNUNET_array_grow (nodes, nnodes, nnodes - 1);
       return -1;
     }
   if ((ntohs (hdr->header.header.type) == CS_PROTO_testbed_REPLY) &&
       (ntohs (hdr->header.header.size) >= sizeof (TESTBED_hello_MESSAGE)) &&
       (ntohl (hdr->header.msgType) == TESTBED_hello_RESPONSE) &&
       (ntohs (hdr->header.header.size) - sizeof (TESTBED_CS_MESSAGE) >=
-       sizeof (P2P_hello_MESSAGE))
+       sizeof (GNUNET_MessageHello))
       && (ntohs (hdr->header.header.size) - sizeof (TESTBED_CS_MESSAGE) ==
-          P2P_hello_MESSAGE_size (&hdr->helo)))
+          GNUNET_sizeof_hello (&hdr->helo)))
     {
-      nodes[currindex].helo = MALLOC (P2P_hello_MESSAGE_size (&hdr->helo));
-      memcpy (nodes[currindex].helo,
-              &hdr->helo, P2P_hello_MESSAGE_size (&hdr->helo));
+      nodes[currindex].helo =
+        GNUNET_malloc (GNUNET_sizeof_hello (&hdr->helo));
+      memcpy (nodes[currindex].helo, &hdr->helo,
+              GNUNET_sizeof_hello (&hdr->helo));
     }
   else
     {
-      FREE (hdr);
+      GNUNET_free (hdr);
       destroySocket (&nodes[currindex].sock);
       XPRINTF (" peer %s did not respond with proper hello.\n",
                nodes[currindex].ips);
-      FREE (nodes[currindex].ips);
+      GNUNET_free (nodes[currindex].ips);
       /* fixme: check error conditions on kill/waidpid! */
       kill (nodes[currindex].ssh, SIGTERM);
       waitpid (nodes[currindex].ssh, &status, 0);
-      GROW (nodes, nnodes, nnodes - 1);
+      GNUNET_array_grow (nodes, nnodes, nnodes - 1);
       return -1;
     }
-  FREE (hdr);
+  GNUNET_free (hdr);
   XPRINTF ("%d\n", currindex);
   return 0;
 }
@@ -461,14 +466,14 @@
       return -1;
     }
   CHECK_SRC_DST (src, dst, argv[0], argv[1]);
-  if (OK != sendMessage (TESTBED_DEL_PEER,
-                         src,
-                         sizeof (PeerIdentity),
-                         &nodes[dst].helo->senderIdentity))
+  if (GNUNET_OK != sendMessage (TESTBED_DEL_PEER,
+                                src,
+                                sizeof (GNUNET_PeerIdentity),
+                                &nodes[dst].helo->senderIdentity))
     return -1;
-  if (OK != readResult (src, &ack))
+  if (GNUNET_OK != readResult (src, &ack))
     return -1;
-  if (ack == OK)
+  if (ack == GNUNET_OK)
     {
       XPRINTF ("OK.\n");
       return 0;
@@ -494,11 +499,11 @@
       return -1;
     }
   CHECK_PEER (dst, argv[0]);
-  if (OK != sendMessage (TESTBED_DEL_ALL_PEERS, dst, 0, NULL))
+  if (GNUNET_OK != sendMessage (TESTBED_DEL_ALL_PEERS, dst, 0, NULL))
     return -1;
-  if (OK != readResult (dst, &ack))
+  if (GNUNET_OK != readResult (dst, &ack))
     return -1;
-  if (ack == OK)
+  if (ack == GNUNET_OK)
     {
       XPRINTF ("OK.\n");
       return 0;
@@ -524,14 +529,14 @@
       return -1;
     }
   CHECK_SRC_DST (src, dst, argv[0], argv[1]);
-  if (SYSERR == sendMessage (TESTBED_ADD_PEER,
-                             src,
-                             P2P_hello_MESSAGE_size (nodes[dst].helo),
-                             nodes[dst].helo))
+  if (GNUNET_SYSERR == sendMessage (TESTBED_ADD_PEER,
+                                    src,
+                                    GNUNET_sizeof_hello (nodes[dst].helo),
+                                    nodes[dst].helo))
     return -1;
-  if (OK != readResult (src, &ack))
+  if (GNUNET_OK != readResult (src, &ack))
     return -1;
-  if (ack == OK)
+  if (ack == GNUNET_OK)
     {
       XPRINTF ("OK.\n");
       return 0;
@@ -562,15 +567,15 @@
   value = atoi (argv[2]);
   msg.trust = htonl (value);
   memcpy (&msg.otherPeer,
-          &nodes[dst].helo->senderIdentity, sizeof (PeerIdentity));
-  if (SYSERR == sendMessage (TESTBED_SET_TVALUE,
-                             src,
-                             sizeof (PeerIdentity) + sizeof (unsigned int),
-                             &msg.otherPeer))
+          &nodes[dst].helo->senderIdentity, sizeof (GNUNET_PeerIdentity));
+  if (GNUNET_SYSERR == sendMessage (TESTBED_SET_TVALUE,
+                                    src,
+                                    sizeof (GNUNET_PeerIdentity) +
+                                    sizeof (unsigned int), &msg.otherPeer))
     return -1;
-  if (OK != readResult (src, &ack))
+  if (GNUNET_OK != readResult (src, &ack))
     return -1;
-  if (htonl (ack) != OK)
+  if (htonl (ack) != GNUNET_OK)
     {
       XPRINTF (" peer could not set trust value.\n");
       return -1;
@@ -596,12 +601,12 @@
       return -1;
     }
   CHECK_SRC_DST (src, dst, argv[0], argv[1]);
-  if (SYSERR == sendMessage (TESTBED_GET_TVALUE,
-                             src,
-                             sizeof (PeerIdentity),
-                             &nodes[dst].helo->senderIdentity))
+  if (GNUNET_SYSERR == sendMessage (TESTBED_GET_TVALUE,
+                                    src,
+                                    sizeof (GNUNET_PeerIdentity),
+                                    &nodes[dst].helo->senderIdentity))
     return -1;
-  if (SYSERR == readResult (src, &value))
+  if (GNUNET_SYSERR == readResult (src, &value))
     return -1;
   if (value < 0)
     {
@@ -629,11 +634,11 @@
       return -1;
     }
   CHECK_PEER (dst, argv[0]);
-  if (SYSERR == sendMessage (TESTBED_DISABLE_hello, dst, 0, NULL))
+  if (GNUNET_SYSERR == sendMessage (TESTBED_DISABLE_hello, dst, 0, NULL))
     return -1;
-  if (SYSERR == readResult (dst, &value))
+  if (GNUNET_SYSERR == readResult (dst, &value))
     return -1;
-  if (value != OK)
+  if (value != GNUNET_OK)
     {
       XPRINTF (" could disable hello\n");
       return -1;
@@ -659,11 +664,11 @@
       return -1;
     }
   CHECK_PEER (dst, argv[0]);
-  if (SYSERR == sendMessage (TESTBED_ENABLE_hello, dst, 0, NULL))
+  if (GNUNET_SYSERR == sendMessage (TESTBED_ENABLE_hello, dst, 0, NULL))
     return -1;
-  if (SYSERR == readResult (dst, &value))
+  if (GNUNET_SYSERR == readResult (dst, &value))
     return -1;
-  if (value != OK)
+  if (value != GNUNET_OK)
     {
       XPRINTF (" could enable hello\n");
       return -1;
@@ -689,11 +694,12 @@
       return -1;
     }
   CHECK_PEER (dst, argv[0]);
-  if (SYSERR == sendMessage (TESTBED_DISABLE_AUTOCONNECT, dst, 0, NULL))
+  if (GNUNET_SYSERR ==
+      sendMessage (TESTBED_DISABLE_AUTOCONNECT, dst, 0, NULL))
     return -1;
-  if (SYSERR == readResult (dst, &value))
+  if (GNUNET_SYSERR == readResult (dst, &value))
     return -1;
-  if (value != OK)
+  if (value != GNUNET_OK)
     {
       XPRINTF (" could disable AUTOCONNECT\n");
       return -1;
@@ -719,11 +725,11 @@
       return -1;
     }
   CHECK_PEER (dst, argv[0]);
-  if (SYSERR == sendMessage (TESTBED_ENABLE_AUTOCONNECT, dst, 0, NULL))
+  if (GNUNET_SYSERR == sendMessage (TESTBED_ENABLE_AUTOCONNECT, dst, 0, NULL))
     return -1;
-  if (SYSERR == readResult (dst, &value))
+  if (GNUNET_SYSERR == readResult (dst, &value))
     return -1;
-  if (value != OK)
+  if (value != GNUNET_OK)
     {
       XPRINTF (" could enable AUTOCONNECT\n");
       return -1;
@@ -740,12 +746,13 @@
 allowDenyConnectHelper (unsigned int argc, char *argv[], int type)
 {
   int dst, value;
-  PeerIdentity *list;
+  GNUNET_PeerIdentity *list;
   int i;
   int idx = 0;
 
   CHECK_PEER (dst, argv[0]);
-  if (argc > (65532 - sizeof (TESTBED_CS_MESSAGE)) / sizeof (PeerIdentity))
+  if (argc >
+      (65532 - sizeof (TESTBED_CS_MESSAGE)) / sizeof (GNUNET_PeerIdentity))
     {
       XPRINTF ("Too many peers specified.  Ask a wizard to enlarge limit.\n");
       return -1;
@@ -753,25 +760,27 @@
 
   list = NULL;
   for (i = 1; i < argc; i++)
-    CHECK_PEER (idx, argv[i]);  /* may return, do before MALLOC! */
+    CHECK_PEER (idx, argv[i]);  /* may return, do before GNUNET_malloc! */
   if (argc > 1)
-    list = MALLOC (sizeof (PeerIdentity) * (argc - 1));
+    list = GNUNET_malloc (sizeof (GNUNET_PeerIdentity) * (argc - 1));
   for (i = 1; i < argc; i++)
     {
       CHECK_PEER (idx, argv[i]);
       memcpy (&list[i - 1],
-              &nodes[idx].helo->senderIdentity, sizeof (PeerIdentity));
+              &nodes[idx].helo->senderIdentity, sizeof (GNUNET_PeerIdentity));
     }
-  if (SYSERR == sendMessage (type,
-                             dst, sizeof (PeerIdentity) * (argc - 1), list))
+  if (GNUNET_SYSERR == sendMessage (type,
+                                    dst,
+                                    sizeof (GNUNET_PeerIdentity) * (argc - 1),
+                                    list))
     {
-      FREENONNULL (list);
+      GNUNET_free_non_null (list);
       return -1;
     }
-  FREENONNULL (list);
-  if (SYSERR == readResult (dst, &value))
+  GNUNET_free_non_null (list);
+  if (GNUNET_SYSERR == readResult (dst, &value))
     return -1;
-  if (value != OK)
+  if (value != GNUNET_OK)
     {
       XPRINTF (" could change setting.\n");
       return -1;
@@ -821,11 +830,11 @@
   int ok, dst;
 
   CHECK_PEER (dst, peerId);
-  if (OK != sendMessage (type, dst, strlen (modulename), modulename))
+  if (GNUNET_OK != sendMessage (type, dst, strlen (modulename), modulename))
     return -1;
-  if (OK != readResult (dst, &ok))
+  if (GNUNET_OK != readResult (dst, &ok))
     return -1;
-  if (ok != OK)
+  if (ok != GNUNET_OK)
     {
       XPRINTF (" peer %s refused.\n", nodes[dst].ips);
       return -1;
@@ -886,7 +895,7 @@
   size = 0;
   for (i = 1; i < argc; i++)
     size += 1 + strlen (argv[i]);
-  cmdLine = MALLOC (size);
+  cmdLine = GNUNET_malloc (size);
   pos = 0;
   for (i = 1; i < argc; i++)
     {
@@ -894,15 +903,15 @@
       pos += strlen (argv[i]) + 1;
     }
 
-  if (OK != sendMessage (TESTBED_EXEC, dst, size, cmdLine))
+  if (GNUNET_OK != sendMessage (TESTBED_EXEC, dst, size, cmdLine))
     {
-      FREE (cmdLine);
+      GNUNET_free (cmdLine);
       return -1;
     }
-  FREE (cmdLine);
-  if (OK != readResult (dst, &ack))
+  GNUNET_free (cmdLine);
+  if (GNUNET_OK != readResult (dst, &ack))
     return -1;
-  if (ack != SYSERR)
+  if (ack != GNUNET_SYSERR)
     {
       XPRINTF ("%d\n", ack);
       return 0;
@@ -919,7 +928,7 @@
  * 0 to test if the process is still live.  Use
  * -1 to obtain the return value from a dead
  * process and to free all associated resources.
- * For -1 the return value is printed, otherwise OK.
+ * For -1 the return value is printed, otherwise GNUNET_OK.
  * Note that if the signal is -1 and the process
  * is still running, -1 is returned (which can then
  * NOT be distinguished from the process returning -1)
@@ -939,19 +948,19 @@
   CHECK_PEER (dst, argv[0]);
   msg.pid = htonl (atoi (argv[1]));
   msg.signal = htonl (atoi (argv[2]));
-  if (OK != sendMessage (TESTBED_SIGNAL,
-                         dst,
-                         sizeof (TESTBED_SIGNAL_MESSAGE) -
-                         sizeof (TESTBED_CS_MESSAGE), &msg.pid))
+  if (GNUNET_OK != sendMessage (TESTBED_SIGNAL,
+                                dst,
+                                sizeof (TESTBED_SIGNAL_MESSAGE) -
+                                sizeof (TESTBED_CS_MESSAGE), &msg.pid))
     return -1;
-  if (OK != readResult (dst, &ack))
+  if (GNUNET_OK != readResult (dst, &ack))
     return -1;
   if (ntohl (msg.signal) == -1)
     {
       XPRINTF ("%d\n", ack);
       return 0;
     }
-  if (ack == OK)
+  if (ack == GNUNET_OK)
     {
       XPRINTF ("OK.\n");
       return 0;
@@ -980,11 +989,11 @@
     }
   CHECK_PEER (dst, argv[0]);
   pid = htonl (atoi (argv[1]));
-  if (OK != sendMessage (TESTBED_GET_OUTPUT, dst, sizeof (int), &pid))
+  if (GNUNET_OK != sendMessage (TESTBED_GET_OUTPUT, dst, sizeof (int), &pid))
     return -1;
-  if (OK != readResult (dst, (int *) &ack))
+  if (GNUNET_OK != readResult (dst, (int *) &ack))
     return -1;
-  if (ack != SYSERR)
+  if (ack != GNUNET_SYSERR)
     {
       char *tmp;
       unsigned int pos = 0;
@@ -994,8 +1003,9 @@
           TESTBED_OUTPUT_REPLY_MESSAGE *reply;
 
           reply = NULL;
-          if (SYSERR == connection_read (&nodes[dst].sock,
-                                         (CS_MESSAGE_HEADER **) & reply))
+          if (GNUNET_SYSERR ==
+              GNUNET_client_connection_read (&nodes[dst].sock,
+                                             (CS_MESSAGE_HEADER **) & reply))
             {
               XPRINTF (" peer %s is not responding after %d of %d bytes.\n",
                        nodes[dst].ips, pos, ack);
@@ -1005,14 +1015,14 @@
           size =
             ntohs (reply->header.header.size) -
             sizeof (TESTBED_OUTPUT_REPLY_MESSAGE);
-          tmp = MALLOC (size + 1);
+          tmp = GNUNET_malloc (size + 1);
           memcpy (tmp,
                   &((TESTBED_OUTPUT_REPLY_MESSAGE_GENERIC *) reply)->data[0],
                   size);
           tmp[size] = '\0';
           XPRINTF ("%s", tmp);
-          FREE (tmp);
-          FREE (reply);
+          GNUNET_free (tmp);
+          GNUNET_free (reply);
           pos += size;
         }
       return 0;
@@ -1048,14 +1058,14 @@
     }
   msg.in_bw = htonl (in);
   msg.out_bw = htonl (out);
-  if (SYSERR == sendMessage (TESTBED_SET_BW,
-                             dst,
-                             sizeof (TESTBED_SET_BW_MESSAGE) -
-                             sizeof (TESTBED_CS_MESSAGE), &msg.in_bw))
+  if (GNUNET_SYSERR == sendMessage (TESTBED_SET_BW,
+                                    dst,
+                                    sizeof (TESTBED_SET_BW_MESSAGE) -
+                                    sizeof (TESTBED_CS_MESSAGE), &msg.in_bw))
     return -1;
-  if (OK != readResult (dst, &ack))
+  if (GNUNET_OK != readResult (dst, &ack))
     return -1;
-  if (ack != OK)
+  if (ack != GNUNET_OK)
     {
       XPRINTF (" peer could not set the specified bandwith.\n");
       return -1;
@@ -1086,15 +1096,15 @@
   msg.percentageLossInbound = htonl (atoi (argv[1]));
   msg.percentageLossOutbound = htonl (atoi (argv[2]));
 
-  if (SYSERR == sendMessage (TESTBED_SET_LOSS_RATE,
-                             dst,
-                             sizeof (TESTBED_SET_LOSS_RATE_MESSAGE) -
-                             sizeof (TESTBED_CS_MESSAGE),
-                             &msg.percentageLossInbound))
+  if (GNUNET_SYSERR == sendMessage (TESTBED_SET_LOSS_RATE,
+                                    dst,
+                                    sizeof (TESTBED_SET_LOSS_RATE_MESSAGE) -
+                                    sizeof (TESTBED_CS_MESSAGE),
+                                    &msg.percentageLossInbound))
     return -1;
-  if (OK != readResult (dst, &ack))
+  if (GNUNET_OK != readResult (dst, &ack))
     return -1;
-  if (ack != OK)
+  if (ack != GNUNET_OK)
     {
       XPRINTF (" peer could not set the specified loss rates.\n");
       return -1;
@@ -1111,7 +1121,7 @@
 {
   if (0 == strcmp (name, arg))
     XPRINTF ("%llu\n", value);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -1126,7 +1136,7 @@
 {
   int res, peer, printProtocols;
 
-  printProtocols = NO;
+  printProtocols = GNUNET_NO;
   if (argc != 2)
     {
       XPRINTF ("Syntax: get-stat PEERID STATID\n");
@@ -1135,7 +1145,7 @@
   CHECK_PEER (peer, argv[0]);
   res = requestStatistics (&nodes[peer].sock,
                            (StatisticsProcessor) & printStatistic, argv[1]);
-  if (res == OK)
+  if (res == GNUNET_OK)
     return 0;
   else
     return -1;
@@ -1145,13 +1155,13 @@
  * Print statistics received.
  *
  * @param stream where to print the statistics
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
 printStatistics (const char *name, unsigned long long value, void *unused)
 {
   XPRINTF ("%-60s: %16llu\n", name, value);
-  return OK;
+  return GNUNET_OK;
 }
 
 static int lastIp2p;
@@ -1177,7 +1187,7 @@
     XPRINTF ("\t%d\n", type);
   else
     XPRINTF ("\t%d\t(%s)\n", type, name);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -1192,7 +1202,7 @@
 {
   int res, peer, printProtocolsOpt;
 
-  printProtocolsOpt = NO;
+  printProtocolsOpt = GNUNET_NO;
   if (argc == 2)
     {
       if (strcmp (argv[0], "-P"))
@@ -1200,7 +1210,7 @@
           XPRINTF ("Syntax: get-stats [-P] PEERID\n");
           return -1;
         }
-      printProtocolsOpt = YES;
+      printProtocolsOpt = GNUNET_YES;
       CHECK_PEER (peer, argv[1]);
     }
   else if (argc != 1)
@@ -1212,14 +1222,14 @@
     CHECK_PEER (peer, argv[0]);
   res = requestStatistics (&nodes[peer].sock,
                            (StatisticsProcessor) & printStatistics, NULL);
-  if ((printProtocolsOpt == YES) && (res == OK))
+  if ((printProtocolsOpt == GNUNET_YES) && (res == GNUNET_OK))
     {
-      lastIp2p = 42;            /* not YES or NO */
+      lastIp2p = 42;            /* not GNUNET_YES or GNUNET_NO */
       res = requestAvailableProtocols (&nodes[peer].sock,
                                        (ProtocolProcessor) & printProtocols,
                                        NULL);
     }
-  if (res == OK)
+  if (res == GNUNET_OK)
     return 0;
   else
     return -1;
@@ -1245,20 +1255,20 @@
       return -1;
     }
   CHECK_PEER (peer, argv[0]);
-  opt = getConfigurationOptionValue (&nodes[peer].sock, argv[1], argv[2]);
+  opt = GNUNET_get_daemon_configuration_value (&nodes[peer].sock, argv[1], 
argv[2]);
   if (opt == NULL)
     {
       XPRINTF ("Error sending request to peer %d\n", peer);
       return -1;
     }
   XPRINTF ("%s\n", opt);
-  FREE (opt);
+  GNUNET_free (opt);
   return 0;
 }
 
 
 /**
- * Upload a file to a peer.
+ * GNUNET_ND_UPLOAD a file to a peer.
  */
 static int
 uploadFile (int argc, char *argv[])
@@ -1288,37 +1298,41 @@
       return -1;
     }
 
-  msg = MALLOC (sizeof (TESTBED_UPLOAD_FILE_MESSAGE) + TESTBED_FILE_BLK_SIZE);
-  msg->header.header.size
-    = htons (sizeof (TESTBED_UPLOAD_FILE_MESSAGE) + flen);
+  msg =
+    GNUNET_malloc (sizeof (TESTBED_UPLOAD_FILE_MESSAGE) +
+                   TESTBED_FILE_BLK_SIZE);
+  msg->header.header.size =
+    htons (sizeof (TESTBED_UPLOAD_FILE_MESSAGE) + flen);
   msg->header.header.type = htons (CS_PROTO_testbed_REQUEST);
   msg->header.msgType = htonl (TESTBED_UPLOAD_FILE);
   msg->type = htonl (TESTBED_FILE_DELETE);
   memcpy (((TESTBED_UPLOAD_FILE_MESSAGE_GENERIC *) msg)->buf, argv[2], flen);
 
-  if (SYSERR == connection_write (&nodes[peer].sock, &msg->header.header))
+  if (GNUNET_SYSERR ==
+      GNUNET_client_connection_write (&nodes[peer].sock, &msg->header.header))
     {
       fclose (infile);
-      FREE (msg);
+      GNUNET_free (msg);
       XPRINTF (" Could not send message to peer %s.\n", nodes[peer].ips);
       return -1;
     }
   /* Read ack from the peer */
-  if (OK != connection_read_result (&nodes[peer].sock, &ack))
+  if (GNUNET_OK !=
+      GNUNET_client_connection_read_result (&nodes[peer].sock, &ack))
     {
       fclose (infile);
-      FREE (msg);
+      GNUNET_free (msg);
       XPRINTF ("Peer is not responding\n");
       return -1;
     }
-  if (ack != OK)
+  if (ack != GNUNET_OK)
     {
       fclose (infile);
-      FREE (msg);
+      GNUNET_free (msg);
       XPRINTF (" Peer returned error (delete existing file).\n");
       return -1;
     }
-  msg->type = htonl (TESTBED_FILE_APPEND);
+  msg->type = htonl (TESTBED_FILE_GNUNET_array_append);
   buf = ((TESTBED_UPLOAD_FILE_MESSAGE_GENERIC *) msg)->buf + flen;
   while ((nbytes = GN_FREAD (buf, 1,
                              (TESTBED_FILE_BLK_SIZE -
@@ -1329,23 +1343,25 @@
         break;
       msg->header.header.size = htons (sizeof (TESTBED_UPLOAD_FILE_MESSAGE) +
                                        nbytes + flen);
-      if (SYSERR == connection_write (&nodes[peer].sock, &msg->header.header))
+      if (GNUNET_SYSERR ==
+          GNUNET_client_connection_write (&nodes[peer].sock,
+                                          &msg->header.header))
         {
           fclose (infile);
-          FREE (msg);
+          GNUNET_free (msg);
           XPRINTF (" could not send file to node %s.\n", nodes[peer].ips);
           return -1;
         }
-      if (OK != readResult (peer, &ack))
+      if (GNUNET_OK != readResult (peer, &ack))
         {
           fclose (infile);
-          FREE (msg);
+          GNUNET_free (msg);
           return -1;
         }
-      if (ack != OK)
+      if (ack != GNUNET_OK)
         {
           fclose (infile);
-          FREE (msg);
+          GNUNET_free (msg);
           XPRINTF (" peer returned error.\n");
           return -1;
         }
@@ -1353,12 +1369,12 @@
   if (ferror (infile))
     {
       fclose (infile);
-      FREE (msg);
+      GNUNET_free (msg);
       XPRINTF (" could not read source file. Transmission aborted.\n");
       return -1;
     }
   fclose (infile);
-  FREE (msg);
+  GNUNET_free (msg);
   XPRINTF ("OK.\n");
   return 0;
 }
@@ -1410,7 +1426,7 @@
               return 0;
             }
         }
-      up = MALLOC (end - start + 1);
+      up = GNUNET_malloc (end - start + 1);
       memcpy (up, &buffer[start], end - start);
       up[end - start] = '\0';
       port = 2087;              /* default port */
@@ -1421,8 +1437,9 @@
           char ports[12];
           char ips[128];
           char *argv[2];
-          SNPRINTF (ports, 12, "%d", port);
-          SNPRINTF (ips, 128, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
+          GNUNET_snprintf (ports, 12, "%d", port);
+          GNUNET_snprintf (ips, 128, "%u.%u.%u.%u", ip[0], ip[1], ip[2],
+                           ip[3]);
           argv[0] = ips;
           argv[1] = ports;
           if (0 != addNode (2, argv))
@@ -1431,7 +1448,7 @@
       else
         {
           char *login;
-          login = MALLOC (64);
+          login = GNUNET_malloc (64);
           if (5 <= sscanf (up,
                            "add-node %63s %d %d %d %d %d",
                            login, &ip[0], &ip[1], &ip[2], &ip[3], &port))
@@ -1439,17 +1456,18 @@
               char ports[12];
               char ips[128];
               char *argv[3];
-              SNPRINTF (ports, 12, "%d", port);
-              SNPRINTF (ips, 128, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
+              GNUNET_snprintf (ports, 12, "%d", port);
+              GNUNET_snprintf (ips, 128, "%u.%u.%u.%u", ip[0], ip[1], ip[2],
+                               ip[3]);
               argv[0] = login;
               argv[1] = ips;
               argv[2] = ports;
               if (0 != addSshNode (3, argv))
                 err = 2;
             }
-          FREE (login);
+          GNUNET_free (login);
         }
-      FREE (up);
+      GNUNET_free (up);
       end++;
       start = end;
     }
@@ -1477,7 +1495,7 @@
   int sock;
   size_t ret;
   char *command;
-  cron_t start;
+  GNUNET_CronTime start;
   char c;
   char *buffer;
   int i;
@@ -1485,7 +1503,7 @@
   int k;
   struct sockaddr_in theProxy;
   char *proxy, *proxyPort;
-  IPaddr ip;
+  GNUNET_IPv4Address ip;
   size_t n;
 
   if (argc == 0)
@@ -1498,21 +1516,22 @@
         }
     }
   else
-    reg = STRDUP (argv[0]);
+    reg = GNUNET_strdup (argv[0]);
 
 
 
   proxy = getConfigurationString ("GNUNETD", "HTTP-PROXY");
   if (proxy != NULL)
     {
-      if (OK != get_host_by_name (ectx, proxy, &ip))
+      if (GNUNET_OK != GNUNET_get_host_by_name (ectx, proxy, &ip))
         {
           XPRINTF (" Couldn't resolve name of HTTP proxy '%s'\n", proxy);
           theProxy.sin_addr.s_addr = 0;
         }
       else
         {
-          memcpy (&theProxy.sin_addr.s_addr, &ip, sizeof (IPaddr));
+          memcpy (&theProxy.sin_addr.s_addr, &ip,
+                  sizeof (GNUNET_IPv4Address));
           proxyPort = getConfigurationString ("GNUNETD", "HTTP-PROXY-PORT");
           if (proxyPort == NULL)
             {
@@ -1521,10 +1540,10 @@
           else
             {
               theProxy.sin_port = htons (atoi (proxyPort));
-              FREE (proxyPort);
+              GNUNET_free (proxyPort);
             }
         }
-      FREE (proxy);
+      GNUNET_free (proxy);
     }
   else
     {
@@ -1538,7 +1557,7 @@
     }
   port = 80;                    /* default http port */
 
-  hostname = STRDUP (&reg[strlen (HTTP_URL)]);
+  hostname = GNUNET_strdup (&reg[strlen (HTTP_URL)]);
   buffer = NULL;
   j = -1;
   k = -1;
@@ -1559,13 +1578,13 @@
       char *pstring;
       if (k == -1)
         {
-          pstring = MALLOC (strlen (hostname) - j + 1);
+          pstring = GNUNET_malloc (strlen (hostname) - j + 1);
           memcpy (pstring, &hostname[j], strlen (hostname) - j + 1);
           pstring[strlen (hostname) - j] = '\0';
         }
       else
         {
-          pstring = MALLOC (k - j + 1);
+          pstring = GNUNET_malloc (k - j + 1);
           memcpy (pstring, &hostname[j], k - j);
           pstring[k - j] = '\0';
         }
@@ -1573,12 +1592,12 @@
       if ((port < 0) || (port > 65536))
         {
           XPRINTF (" malformed http URL: %s at %s.\n", reg, buffer);
-          FREE (hostname);
-          FREE (reg);
-          FREE (pstring);
+          GNUNET_free (hostname);
+          GNUNET_free (reg);
+          GNUNET_free (pstring);
           return -1;
         }
-      FREE (pstring);
+      GNUNET_free (pstring);
     }
   hostname[k] = '\0';
 
@@ -1594,8 +1613,8 @@
     {
       XPRINTF (" could not open socket for hostlist download (%s).\n",
                STRERROR (errno));
-      FREE (hostname);
-      FREE (reg);
+      GNUNET_free (hostname);
+      GNUNET_free (reg);
       return -1;
     }
 
@@ -1603,15 +1622,15 @@
   if (theProxy.sin_addr.s_addr == 0)
     {
       /* no proxy */
-      if (OK != get_host_by_name (ectx, hostname, &ip))
+      if (GNUNET_OK != GNUNET_get_host_by_name (ectx, hostname, &ip))
         {
           XPRINTF (" could not download hostlist, host '%s' unknown\n",
                    hostname);
-          FREE (reg);
-          FREE (hostname);
+          GNUNET_free (reg);
+          GNUNET_free (hostname);
           return -1;
         }
-      memcpy (&soaddr.sin_addr.s_addr, &ip, sizeof (IPaddr));
+      memcpy (&soaddr.sin_addr.s_addr, &ip, sizeof (GNUNET_IPv4Address));
       soaddr.sin_port = htons ((unsigned short) port);
     }
   else
@@ -1627,29 +1646,29 @@
     {
       XPRINTF (" failed to send HTTP request to host %s: %s\n",
                hostname, STRERROR (errno));
-      FREE (reg);
-      FREE (hostname);
+      GNUNET_free (reg);
+      GNUNET_free (hostname);
       closefile (sock);
       return -1;
     }
 
   n = strlen (GET_COMMAND) + strlen (reg);
-  command = MALLOC (n);
-  SNPRINTF (command, n, GET_COMMAND, reg);
-  FREE (reg);
+  command = GNUNET_malloc (n);
+  GNUNET_snprintf (command, n, GET_COMMAND, reg);
+  GNUNET_free (reg);
   curpos = strlen (command) + 1;
   curpos = SEND_BLOCKING_ALL (sock, command, curpos);
-  if (SYSERR == (int) curpos)
+  if (GNUNET_SYSERR == (int) curpos)
     {
       XPRINTF (" failed so send HTTP request %s to host %s (%u - %d) - %s\n",
                command, hostname, curpos, sock, STRERROR (errno));
-      FREE (command);
-      FREE (hostname);
+      GNUNET_free (command);
+      GNUNET_free (hostname);
       closefile (sock);
       return -1;
     }
-  FREE (command);
-  FREE (hostname);
+  GNUNET_free (command);
+  GNUNET_free (hostname);
   cronTime (&start);
 
   /* we first have to read out the http_response */
@@ -1659,12 +1678,12 @@
     {
       int success;
 
-      if (start + 5 * cronMINUTES < get_time ())
+      if (start + 5 * GNUNET_CRON_MINUTES < GNUNET_get_time ())
         break;                  /* exit after 5m */
       success = RECV_NONBLOCKING (sock, &c, sizeof (c), &ret);
-      if (success == NO)
+      if (success == GNUNET_NO)
         {
-          PTHREAD_SLEEP (100 * cronMILLIS);
+          GNUNET_thread_sleep (100 * GNUNET_CRON_MILLISECONDS);
           continue;
         }
       if ((ret == 0) || (ret == (size_t) - 1))
@@ -1682,25 +1701,25 @@
     }
 
   /* now read peer list */
-  buffer = MALLOC (65536);
+  buffer = GNUNET_malloc (65536);
 
 
   while (1)
     {
       int success;
 
-      if (start + 300 * cronSECONDS < get_time ())
+      if (start + 300 * GNUNET_CRON_SECONDS < GNUNET_get_time ())
         break;                  /* exit after 300s */
       curpos = 0;
       while (curpos < 65536)
         {
-          if (start + 300 * cronSECONDS < get_time ())
+          if (start + 300 * GNUNET_CRON_SECONDS < GNUNET_get_time ())
             break;              /* exit after 300s */
           success = RECV_NONBLOCKING (sock,
                                       &buffer[curpos], 65536 - curpos, &ret);
-          if (success == NO)
+          if (success == GNUNET_NO)
             {
-              PTHREAD_SLEEP (20);
+              GNUNET_thread_sleep (20);
               continue;
             }
           if ((ret == 0) || (ret == (size_t) - 1))
@@ -1709,7 +1728,7 @@
 
           if (0 != processCommands (buffer, &curpos))
             {
-              FREE (buffer);
+              GNUNET_free (buffer);
               closefile (sock);
               return -1;
             }
@@ -1717,11 +1736,11 @@
     }
   if (0 != processCommands (buffer, &curpos))
     {
-      FREE (buffer);
+      GNUNET_free (buffer);
       closefile (sock);
       return -1;
     }
-  FREE (buffer);
+  GNUNET_free (buffer);
   closefile (sock);
   return 0;
 }
@@ -1744,7 +1763,7 @@
 static int
 doExit (int argc, char *argv[])
 {
-  do_quit = YES;
+  do_quit = GNUNET_YES;
   return 0;
 }
 

Modified: GNUnet/src/applications/testbed/commands.h
===================================================================
--- GNUnet/src/applications/testbed/commands.h  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/testbed/commands.h  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -28,7 +28,7 @@
 #define TESTBED_COMMANDS_H
 
 /**
- * Signature of a command -- just like main()!
+ * GNUNET_RSA_Signature of a command -- just like main()!
  */
 typedef int (*CommandHandler) (int argc, char *argv[]);
 

Modified: GNUnet/src/applications/testbed/gnunet-testbed.c
===================================================================
--- GNUnet/src/applications/testbed/gnunet-testbed.c    2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/testbed/gnunet-testbed.c    2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -26,7 +26,7 @@
  * @author Murali Krishan Ramanathan
  *
  * Todo:
- * - test secure sign-on (and test testbed setup script!)
+ * - test secure GNUNET_RSA_sign-on (and test testbed setup script!)
  * - allow removing of peers (explicitly AND when peer shuts down!)
  *   Problem: what happens to the peer-IDs in that case?
  * - general problem: the way we use tcpio means that any rouge
@@ -78,14 +78,14 @@
  *
  * @param argc the number of options
  * @param argv the option list (including keywords)
- * @return OK on error, SYSERR if we should exit
+ * @return GNUNET_OK on error, GNUNET_SYSERR if we should exit
  */
 static int
 helperParseOptions (int argc, char *argv[])
 {
   int c, option_index;
 
-  FREENONNULL (setConfigurationString ("GNUNETD", "LOGFILE", NULL));
+  GNUNET_free_non_null (setConfigurationString ("GNUNETD", "LOGFILE", NULL));
   while (1)
     {
       static struct GNoption long_options[] = {
@@ -97,14 +97,14 @@
       c = GNgetopt_long (argc, argv, "vhdc:L:", long_options, &option_index);
       if (c == -1)
         break;                  /* No more flags to process */
-      if (YES == parseDefaultOptions (c, GNoptarg))
+      if (GNUNET_YES == parseDefaultOptions (c, GNoptarg))
         continue;
       switch (c)
         {
         case 'v':
           printf ("GNUnet v%s, gnunet-testbed v%s\n",
                   VERSION, TESTBED_VERSION);
-          return SYSERR;
+          return GNUNET_SYSERR;
         case 'h':
           {
             static Help help[] = {
@@ -116,7 +116,7 @@
             };
             formatHelp ("gnunet-testbed ==HELPER== [OPTIONS] [COMMAND]",
                         _("Start GNUnet-testbed helper."), help);
-            return SYSERR;
+            return GNUNET_SYSERR;
           }
         default:
           GE_LOG (ectx, GE_ERROR | GE_IMMEDIATE | GE_USER,
@@ -125,7 +125,7 @@
         }                       /* end of parsing commandline */
     }                           /* while (1) */
   setConfigurationStringList (&argv[GNoptind], argc - GNoptind);
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -147,7 +147,7 @@
   char *buf;
   struct sockaddr_in soaddr;
 
-  if (SYSERR == initUtil (argc, argv, &helperParseOptions))
+  if (GNUNET_SYSERR == initUtil (argc, argv, &helperParseOptions))
     return -1;
 
   argc = getConfigurationStringList (&argv);
@@ -161,7 +161,7 @@
   if (sock == -1)
     {
       LOG_STRERROR (LOG_FAILURE, "socket");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   soaddr.sin_family = AF_INET;
   soaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
@@ -174,19 +174,19 @@
               PORT, STRERROR (errno));
       closefile (sock);
       sock = -1;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
   /* write command to socket */
   socketSend (strlen (argv[0]), SOCKET_BEGIN_COMMAND, argv[0]);
-  FREE (argv[0]);
+  GNUNET_free (argv[0]);
   /* write args to socket */
   for (i = 1; i < argc; i++)
     {
       socketSend (strlen (argv[i]), SOCKET_ADD_ARGUMENT, argv[i]);
-      FREE (argv[i]);
+      GNUNET_free (argv[i]);
     }
-  FREE (argv);
+  GNUNET_free (argv);
   socketSend (0, SOCKET_END_COMMAND, NULL);
 
   /* read result from socket, print to stderr,  obtain retVal */
@@ -194,14 +194,14 @@
   buf = NULL;
   while (i == SOCKET_PRINTF)
     {
-      FREENONNULL (buf);
+      GNUNET_free_non_null (buf);
       buf = NULL;
       i = readSocket (&buf, &len);
       if (i == SOCKET_PRINTF)
         fprintf (stdout, "%.*s", (int) len, buf);
     }
   retVal = *(int *) buf;
-  FREE (buf);
+  GNUNET_free (buf);
   closefile (sock);
   return retVal;
 }
@@ -213,7 +213,7 @@
 static void
 sigChildHandler (int signal, siginfo_t * info, void *extra)
 {
-  do_quit = YES;
+  do_quit = GNUNET_YES;
 }
 
 /**
@@ -257,7 +257,7 @@
         }
       i++;
     }
-  FREE (configFile);
+  GNUNET_free (configFile);
   fclose (aliases);
   doneUtil ();
   execvp (SHELL, argv);
@@ -268,13 +268,13 @@
 /**
  * Configuration...
  */
-static struct CIDRNetwork *trustedNetworks_ = NULL;
+static struct GNUNET_IPv4NetworkSet *trustedNetworks_ = NULL;
 
 /**
  * Is this IP labeled as trusted for CS connections?
  */
 static int
-isWhitelisted (IPaddr ip)
+isWhitelisted (GNUNET_IPv4Address ip)
 {
   return checkIPListed (trustedNetworks_, ip);
 }
@@ -331,7 +331,7 @@
       goto CREATE_SOCKET;
     }
 
-  do_quit = NO;
+  do_quit = GNUNET_NO;
   /* signal handler is needed if the child did exit
      (e.g. with CTRL-D and not with the command 'exit') */
   newAct.sa_sigaction = &sigChildHandler;
@@ -344,7 +344,8 @@
   if (0 != sigprocmask (SIG_UNBLOCK, &set, &oset))
     DIE_STRERROR ("sigprocmask");
   LISTEN (ssock, 5);
-  while ((do_quit == NO) && (0 == waitpid (bash_pid, &status, WNOHANG)))
+  while ((do_quit == GNUNET_NO)
+         && (0 == waitpid (bash_pid, &status, WNOHANG)))
     {
       unsigned int argc;
       char *command;
@@ -354,7 +355,7 @@
       fd_set rset;
       fd_set wset;
       fd_set eset;
-      IPaddr ipaddr;
+      GNUNET_IPv4Address ipaddr;
 
       lenOfIncomingAddr = sizeof (clientAddr);
       /* accept is not interrupted by SIGCHLD,
@@ -374,9 +375,10 @@
           continue;
         }
       /* access control! */
-      GE_ASSERT (ectx, sizeof (struct in_addr) == sizeof (IPaddr));
+      GE_ASSERT (ectx,
+                 sizeof (struct in_addr) == sizeof (GNUNET_IPv4Address));
       memcpy (&ipaddr, &clientAddr.sin_addr, sizeof (struct in_addr));
-      if (NO == isWhitelisted (ipaddr))
+      if (GNUNET_NO == isWhitelisted (ipaddr))
         {
           GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
                   _("Rejected unauthorized connection from %u.%u.%u.%u.\n"),
@@ -396,23 +398,23 @@
                    _("Protocol violation on socket. " "Expected command.\n"));
           return -1;
         }
-      command = MALLOC (len + 1);
+      command = GNUNET_malloc (len + 1);
       memcpy (command, buf, len);
       command[len] = '\0';
       argc = 0;
       args = NULL;
-      FREE (buf);
+      GNUNET_free (buf);
       buf = NULL;
       while (SOCKET_ADD_ARGUMENT == readSocket (&buf, &len))
         {
-          GROW (args, argc, argc + 1);
-          args[argc - 1] = MALLOC (len + 1);
+          GNUNET_array_grow (args, argc, argc + 1);
+          args[argc - 1] = GNUNET_malloc (len + 1);
           memcpy (args[argc - 1], buf, len);
           args[argc - 1][len] = '\0';
-          FREE (buf);
+          GNUNET_free (buf);
           buf = NULL;
         }
-      FREENONNULL (buf);
+      GNUNET_free_non_null (buf);
       i = 0;
       while (commands[i].command != NULL)
         {
@@ -426,8 +428,8 @@
           i++;
         }
       for (i = 0; i < argc; i++)
-        FREE (args[i]);
-      GROW (args, argc, 0);
+        GNUNET_free (args[i]);
+      GNUNET_array_grow (args, argc, 0);
       if (commands[i].command == NULL)
         {
           /* should never happen unless the user
@@ -436,7 +438,7 @@
           PRINTF (_("Command `%s' not found!\n"), command);
           socketSend (sizeof (unsigned int), SOCKET_RETVAL, &i);
         }
-      FREE (command);
+      GNUNET_free (command);
       closefile (sock);
       sock = -1;
     }
@@ -459,14 +461,14 @@
  *
  * @param argc the number of options
  * @param argv the option list (including keywords)
- * @return OK on error, SYSERR if we should exit
+ * @return GNUNET_OK on error, GNUNET_SYSERR if we should exit
  */
 static int
 parseOptions (int argc, char *argv[])
 {
   int c, option_index;
 
-  FREENONNULL (setConfigurationString ("GNUNETD", "LOGFILE", NULL));
+  GNUNET_free_non_null (setConfigurationString ("GNUNETD", "LOGFILE", NULL));
   while (1)
     {
       static struct GNoption long_options[] = {
@@ -478,14 +480,14 @@
       c = GNgetopt_long (argc, argv, "vhdc:L:", long_options, &option_index);
       if (c == -1)
         break;                  /* No more flags to process */
-      if (YES == parseDefaultOptions (c, GNoptarg))
+      if (GNUNET_YES == parseDefaultOptions (c, GNoptarg))
         continue;
       switch (c)
         {
         case 'v':
           printf ("GNUnet v%s, gnunet-testbed v%s\n",
                   VERSION, TESTBED_VERSION);
-          return SYSERR;
+          return GNUNET_SYSERR;
 
         case 'h':
           {
@@ -498,7 +500,7 @@
             };
             formatHelp ("gnunet-testbed [OPTIONS]",
                         _("Start GNUnet testbed controller."), help);
-            return SYSERR;
+            return GNUNET_SYSERR;
           }
         default:
           GE_LOG (ectx, GE_ERROR | GE_IMMEDIATE | GE_USER,
@@ -506,7 +508,7 @@
           return -1;
         }                       /* end of parsing commandline */
     }                           /* while (1) */
-  return OK;
+  return GNUNET_OK;
 }
 
 /* **************** main **************** */
@@ -544,7 +546,7 @@
         }
     }
 
-  if (SYSERR == initUtil (argc, argv, &parseOptions))
+  if (GNUNET_SYSERR == initUtil (argc, argv, &parseOptions))
     return -1;
 
   ch = getConfigurationString ("GNUNET-TESTBED", "TRUSTED");
@@ -559,7 +561,7 @@
         errexit (_
                  ("Malformed entry in the configuration in section %s under 
%s: %s\n"),
                  "GNUNET-TESTBED", "TRUSTED", ch);
-      FREE (ch);
+      GNUNET_free (ch);
     }
 
   /* we are the main testbed process.  Fork of
@@ -570,7 +572,7 @@
     DIE_STRERROR ("fork");
   if (pid == 0)
     {
-      FREE (trustedNetworks_);
+      GNUNET_free (trustedNetworks_);
       bash_main ();
       return 0;                 /* unreached */
     }
@@ -583,9 +585,9 @@
       kill (pid, SIGHUP);
       /* proper shutdown... */
       doneUtil ();
-      FREE (trustedNetworks_);
+      GNUNET_free (trustedNetworks_);
       UNLINK (TB_ALIASES);
-      FREE (testbedArg0);
+      GNUNET_free (testbedArg0);
       return ret;
     }
 #endif

Modified: GNUnet/src/applications/testbed/socket.c
===================================================================
--- GNUnet/src/applications/testbed/socket.c    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/testbed/socket.c    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -32,7 +32,7 @@
 
 /* ********* helper methods to implement primitive commands *********** */
 
-#define DEBUG NO
+#define DEBUG GNUNET_NO
 
 int sock = -1;
 
@@ -72,7 +72,7 @@
 #endif
 
   tlen = len + sizeof (ExchangeBuffer);
-  buf = MALLOC (tlen);
+  buf = GNUNET_malloc (tlen);
   if (len > 0)
     memcpy (&buf->data[0], data, len);
   buf->size = htonl (tlen);
@@ -86,7 +86,7 @@
 #endif
 
   writeAll (sock, (void *) buf, tlen);
-  FREE (buf);
+  GNUNET_free (buf);
 }
 
 /**
@@ -118,7 +118,7 @@
     }
   mlen = ntohl (mlen);
 
-  buf = MALLOC (mlen);
+  buf = GNUNET_malloc (mlen);
   while ((pos < mlen) && (ret >= 0))
     {
       ret = READ (sock, &((char *) buf)[pos], mlen - pos);
@@ -137,9 +137,9 @@
 #endif
 
   type = ntohl (buf->type);
-  *rbuf = MALLOC (mlen - sizeof (ExchangeBuffer));
+  *rbuf = GNUNET_malloc (mlen - sizeof (ExchangeBuffer));
   memcpy (*rbuf, &buf->data[0], mlen - sizeof (ExchangeBuffer));
-  FREE (buf);
+  GNUNET_free (buf);
   *len = mlen - sizeof (ExchangeBuffer);
   return type;
 }
@@ -155,7 +155,7 @@
   unsigned int size = 1024;
   char *p;
 
-  p = MALLOC (size);
+  p = GNUNET_malloc (size);
   while (1)
     {
       /* Try to print in the allocated space. */
@@ -166,14 +166,14 @@
       if ((n > -1) && (n < size))
         {
           socketSend (n, SOCKET_PRINTF, p);
-          FREE (p);
+          GNUNET_free (p);
           return;
         }
       /* Else try again with more space. */
       if (n > -1)               /* glibc 2.1 */
-        GROW (p, size, (unsigned int) n + 1);   /* precisely what is needed */
+        GNUNET_array_grow (p, size, (unsigned int) n + 1);      /* precisely 
what is needed */
       else                      /* glibc 2.0 */
-        GROW (p, size, size * 2);       /* twice the old size */
+        GNUNET_array_grow (p, size, size * 2);  /* twice the old size */
     }
 }
 

Modified: GNUnet/src/applications/testbed/testbed.c
===================================================================
--- GNUnet/src/applications/testbed/testbed.c   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/testbed/testbed.c   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -33,7 +33,7 @@
 #include "gnunet_protocols.h"
 #include "gnunet_identity_service.h"
 
-#define DEBUG_TESTBED YES
+#define DEBUG_TESTBED GNUNET_YES
 
 #define GET_COMMAND "GET %s/%s.php3?trusted=%s&port=%s&secure=%s 
HTTP/1.0\r\n\r\n"
 #define HTTP_URL "http://";
@@ -46,7 +46,7 @@
 static void
 sendAcknowledgement (ClientHandle client, int ack)
 {
-  if (OK != coreAPI->sendValueToClient (client, ack))
+  if (GNUNET_OK != coreAPI->sendValueToClient (client, ack))
     {
       GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
               _("Could not send acknowledgement back to client.\n"));
@@ -70,7 +70,7 @@
 static void
 tb_ADD_PEER (ClientHandle client, TESTBED_CS_MESSAGE * msg)
 {
-  MESSAGE_HEADER noise;
+  GNUNET_MessageHeader noise;
   TESTBED_ADD_PEER_MESSAGE *hm = (TESTBED_ADD_PEER_MESSAGE *) msg;
 
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, " tb_ADD_PEER\n");
@@ -81,7 +81,7 @@
               "ADD_PEER");
       return;
     }
-  if (P2P_hello_MESSAGE_size (&hm->helo) !=
+  if (GNUNET_sizeof_hello (&hm->helo) !=
       ntohs (msg->header.size) - sizeof (TESTBED_CS_MESSAGE))
     {
       GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
@@ -90,10 +90,10 @@
     }
 
   identity->addHost (&hm->helo);
-  noise.size = htons (sizeof (MESSAGE_HEADER));
+  noise.size = htons (sizeof (GNUNET_MessageHeader));
   noise.type = htons (P2P_PROTO_noise);
   coreAPI->unicast (&hm->helo.senderIdentity, &noise, EXTREME_PRIORITY, 0);
-  sendAcknowledgement (client, OK);
+  sendAcknowledgement (client, GNUNET_OK);
 }
 
 /**
@@ -103,11 +103,11 @@
 tb_DEL_PEER (ClientHandle client, TESTBED_DEL_PEER_MESSAGE * msg)
 {
   coreAPI->disconnectFromPeer (&msg->host);
-  sendAcknowledgement (client, OK);
+  sendAcknowledgement (client, GNUNET_OK);
 }
 
 static void
-doDisconnect (const PeerIdentity * id, void *unused)
+doDisconnect (const GNUNET_PeerIdentity * id, void *unused)
 {
   coreAPI->disconnectFromPeer (id);
 }
@@ -119,7 +119,7 @@
 tb_DEL_ALL_PEERS (ClientHandle client, TESTBED_DEL_ALL_PEERS_MESSAGE * msg)
 {
   coreAPI->forAllConnectedNodes (&doDisconnect, NULL);
-  sendAcknowledgement (client, OK);
+  sendAcknowledgement (client, GNUNET_OK);
 }
 
 /**
@@ -128,31 +128,33 @@
 static void
 tb_GET_hello (ClientHandle client, TESTBED_GET_hello_MESSAGE * msg)
 {
-  P2P_hello_MESSAGE *helo;
+  GNUNET_MessageHello *helo;
   unsigned int proto = ntohs (msg->proto);
 
-  helo = identity->identity2Helo (coreAPI->myIdentity, proto, NO);
+  helo = identity->identity2Helo (coreAPI->myIdentity, proto, GNUNET_NO);
   if (NULL == helo)
     {
       GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
               _("TESTBED could not generate hello message for protocol %u\n"),
               proto);
-      sendAcknowledgement (client, SYSERR);
+      sendAcknowledgement (client, GNUNET_SYSERR);
     }
   else
     {
       TESTBED_hello_MESSAGE *reply
-        = MALLOC (ntohs (helo->header.size) + sizeof (TESTBED_CS_MESSAGE));
-      reply->header.header.size
-        = htons (ntohs (helo->header.size) + sizeof (TESTBED_CS_MESSAGE));
+        =
+        GNUNET_malloc (ntohs (helo->header.size) +
+                       sizeof (TESTBED_CS_MESSAGE));
+      reply->header.header.size =
+        htons (ntohs (helo->header.size) + sizeof (TESTBED_CS_MESSAGE));
       reply->header.header.type = htons (CS_PROTO_testbed_REPLY);
       reply->header.msgType = htonl (TESTBED_hello_RESPONSE);
       memcpy (&reply->helo, helo, ntohs (helo->header.size));
       coreAPI->sendToClient (client, &reply->header.header);
       GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
               "%s: returning from sendToClient\n", __FUNCTION__);
-      FREE (helo);
-      FREE (reply);
+      GNUNET_free (helo);
+      GNUNET_free (reply);
     }
 }
 
@@ -166,7 +168,7 @@
 
   trust = ntohl (msg->trust);
   identity->changeHostTrust (&msg->otherPeer, trust);
-  sendAcknowledgement (client, OK);
+  sendAcknowledgement (client, GNUNET_OK);
 }
 
 /**
@@ -192,7 +194,7 @@
   setConfigurationInt ("LOAD", "MAXNETDOWNBPSTOTAL", ntohl (msg->in_bw));
   setConfigurationInt ("LOAD", "MAXNETUPBPSTOTAL", ntohl (msg->out_bw));
   triggerGlobalConfigurationRefresh ();
-  sendAcknowledgement (client, OK);
+  sendAcknowledgement (client, GNUNET_OK);
 }
 
 /**
@@ -215,7 +217,7 @@
 
   if (!testConfigurationString ("TESTBED", "ALLOW_MODULE_LOADING", "YES"))
     {
-      sendAcknowledgement (client, SYSERR);
+      sendAcknowledgement (client, GNUNET_SYSERR);
       return;
     }
 
@@ -230,10 +232,10 @@
       return;
     }
   ok = coreAPI->loadApplicationModule (name);
-  if (ok != OK)
+  if (ok != GNUNET_OK)
     GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
             _("loading module `%s' failed.  Notifying client.\n"), name);
-  FREE (name);
+  GNUNET_free (name);
   sendAcknowledgement (client, ok);
 }
 
@@ -256,7 +258,7 @@
     }
   if (!testConfigurationString ("TESTBED", "ALLOW_MODULE_LOADING", "YES"))
     {
-      sendAcknowledgement (client, SYSERR);
+      sendAcknowledgement (client, GNUNET_SYSERR);
       return;
     }
 
@@ -271,10 +273,10 @@
       return;
     }
   ok = coreAPI->unloadApplicationModule (name);
-  if (ok != OK)
+  if (ok != GNUNET_OK)
     GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
             _("unloading module failed.  Notifying client.\n"));
-  FREE (name);
+  GNUNET_free (name);
   sendAcknowledgement (client, ok);
 }
 
@@ -287,10 +289,11 @@
 tb_DISABLE_AUTOCONNECT (ClientHandle client,
                         TESTBED_DISABLE_AUTOCONNECT_MESSAGE * msg)
 {
-  FREENONNULL (setConfigurationString ("GNUNETD",
-                                       "DISABLE-AUTOCONNECT", "YES"));
+  GNUNET_free_non_null (setConfigurationString ("GNUNETD",
+                                                "DISABLE-AUTOCONNECT",
+                                                "YES"));
   triggerGlobalConfigurationRefresh ();
-  sendAcknowledgement (client, OK);
+  sendAcknowledgement (client, GNUNET_OK);
 }
 
 /**
@@ -302,10 +305,10 @@
 tb_ENABLE_AUTOCONNECT (ClientHandle client,
                        TESTBED_ENABLE_AUTOCONNECT_MESSAGE * msg)
 {
-  FREENONNULL (setConfigurationString ("GNUNETD",
-                                       "DISABLE-AUTOCONNECT", "NO"));
+  GNUNET_free_non_null (setConfigurationString ("GNUNETD",
+                                                "DISABLE-AUTOCONNECT", "NO"));
   triggerGlobalConfigurationRefresh ();
-  sendAcknowledgement (client, OK);
+  sendAcknowledgement (client, GNUNET_OK);
 }
 
 /**
@@ -316,11 +319,13 @@
 static void
 tb_DISABLE_hello (ClientHandle client, TESTBED_DISABLE_hello_MESSAGE * msg)
 {
-  FREENONNULL (setConfigurationString ("NETWORK",
-                                       "DISABLE-ADVERTISEMENTS", "YES"));
-  FREENONNULL (setConfigurationString ("NETWORK", "HELLOEXCHANGE", "NO"));
+  GNUNET_free_non_null (setConfigurationString ("NETWORK",
+                                                "DISABLE-ADVERTISEMENTS",
+                                                "YES"));
+  GNUNET_free_non_null (setConfigurationString
+                        ("NETWORK", "HELLOEXCHANGE", "NO"));
   triggerGlobalConfigurationRefresh ();
-  sendAcknowledgement (client, OK);
+  sendAcknowledgement (client, GNUNET_OK);
 }
 
 /**
@@ -331,11 +336,13 @@
 static void
 tb_ENABLE_hello (ClientHandle client, TESTBED_ENABLE_hello_MESSAGE * msg)
 {
-  FREENONNULL (setConfigurationString ("NETWORK",
-                                       "DISABLE-ADVERTISEMENTS", "NO"));
-  FREENONNULL (setConfigurationString ("NETWORK", "HELLOEXCHANGE", "YES"));
+  GNUNET_free_non_null (setConfigurationString ("NETWORK",
+                                                "DISABLE-ADVERTISEMENTS",
+                                                "NO"));
+  GNUNET_free_non_null (setConfigurationString
+                        ("NETWORK", "HELLOEXCHANGE", "YES"));
   triggerGlobalConfigurationRefresh ();
-  sendAcknowledgement (client, OK);
+  sendAcknowledgement (client, GNUNET_OK);
 }
 
 /**
@@ -348,7 +355,7 @@
   unsigned short size;
   unsigned int count;
   unsigned int i;
-  EncName enc;
+  GNUNET_EncName enc;
 
   size = ntohs (msg->header.header.size);
   if (size <= sizeof (TESTBED_CS_MESSAGE))
@@ -357,8 +364,9 @@
               _("received invalid `%s' message\n"), "ALLOW_CONNECT");
       return;
     }
-  count = (size - sizeof (TESTBED_CS_MESSAGE)) / sizeof (PeerIdentity);
-  if (count * sizeof (PeerIdentity) + sizeof (TESTBED_CS_MESSAGE) != size)
+  count = (size - sizeof (TESTBED_CS_MESSAGE)) / sizeof (GNUNET_PeerIdentity);
+  if (count * sizeof (GNUNET_PeerIdentity) + sizeof (TESTBED_CS_MESSAGE) !=
+      size)
     {
       GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
               _("received invalid `%s' message\n"), "ALLOW_CONNECT");
@@ -370,19 +378,21 @@
     }
   else
     {
-      value = MALLOC (count * sizeof (EncName) + 1);
+      value = GNUNET_malloc (count * sizeof (GNUNET_EncName) + 1);
       value[0] = '\0';
       for (i = 0; i < count; i++)
         {
-          hash2enc (&((TESTBED_ALLOW_CONNECT_MESSAGE_GENERIC *) msg)->
-                    peers[i].hashPubKey, &enc);
+          GNUNET_hash_to_enc (&
+                              ((TESTBED_ALLOW_CONNECT_MESSAGE_GENERIC *)
+                               msg)->peers[i].hashPubKey, &enc);
           strcat (value, (char *) &enc);
         }
     }
-  FREENONNULL (setConfigurationString ("GNUNETD", "LIMIT-ALLOW", value));
-  FREENONNULL (value);
+  GNUNET_free_non_null (setConfigurationString
+                        ("GNUNETD", "LIMIT-ALLOW", value));
+  GNUNET_free_non_null (value);
   triggerGlobalConfigurationRefresh ();
-  sendAcknowledgement (client, OK);
+  sendAcknowledgement (client, GNUNET_OK);
 }
 
 /**
@@ -395,7 +405,7 @@
   unsigned short size;
   unsigned int count;
   unsigned int i;
-  EncName enc;
+  GNUNET_EncName enc;
 
   size = ntohs (msg->header.header.size);
   if (size <= sizeof (TESTBED_CS_MESSAGE))
@@ -404,8 +414,9 @@
               _("received invalid `%s' message\n"), "DENY_CONNECT");
       return;
     }
-  count = (size - sizeof (TESTBED_CS_MESSAGE)) / sizeof (PeerIdentity);
-  if (count * sizeof (PeerIdentity) + sizeof (TESTBED_CS_MESSAGE) != size)
+  count = (size - sizeof (TESTBED_CS_MESSAGE)) / sizeof (GNUNET_PeerIdentity);
+  if (count * sizeof (GNUNET_PeerIdentity) + sizeof (TESTBED_CS_MESSAGE) !=
+      size)
     {
       GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
               _("received invalid `%s' message\n"), "DENY_CONNECT");
@@ -417,19 +428,21 @@
     }
   else
     {
-      value = MALLOC (count * sizeof (EncName) + 1);
+      value = GNUNET_malloc (count * sizeof (GNUNET_EncName) + 1);
       value[0] = '\0';
       for (i = 0; i < count; i++)
         {
-          hash2enc (&((TESTBED_DENY_CONNECT_MESSAGE_GENERIC *) msg)->peers[i].
-                    hashPubKey, &enc);
+          GNUNET_hash_to_enc (&
+                              ((TESTBED_DENY_CONNECT_MESSAGE_GENERIC *) msg)->
+                              peers[i].hashPubKey, &enc);
           strcat (value, (char *) &enc);
         }
     }
-  FREENONNULL (setConfigurationString ("GNUNETD", "LIMIT-DENY", value));
-  FREENONNULL (value);
+  GNUNET_free_non_null (setConfigurationString
+                        ("GNUNETD", "LIMIT-DENY", value));
+  GNUNET_free_non_null (value);
   triggerGlobalConfigurationRefresh ();
-  sendAcknowledgement (client, OK);
+  sendAcknowledgement (client, GNUNET_OK);
 }
 
 /**
@@ -451,7 +464,7 @@
   unsigned int outputSize;
   /** the output of the process */
   char *output;
-  /** did the process exit? (YES/NO) */
+  /** did the process exit? (GNUNET_YES/GNUNET_NO) */
   int hasExited;
   /** if the process did exit, what was the status? (or errno of execve) */
   int exitStatus;
@@ -501,9 +514,9 @@
   if (0 != PIPE (fd))
     {
       LOG_STRERROR (LOG_WARNING, "pipe");
-      pi->pid = SYSERR;
-      SEMAPHORE_UP (pi->sem);
-      MUTEX_UNLOCK (&lock);
+      pi->pid = GNUNET_SYSERR;
+      GNUNET_semaphore_up (pi->sem);
+      GNUNET_mutex_unlock (&lock);
       return -1;
     }
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
@@ -513,12 +526,12 @@
             "exec argument %d is %s\n", i, pi->argv[i]);
   tmp = getConfigurationString ("TESTBED", "UPLOAD-DIR");
   if (tmp == NULL)
-    tmp = STRDUP (DIR_SEPARATOR_STR);
+    tmp = GNUNET_strdup (DIR_SEPARATOR_STR);
   dir = expandFileName (tmp);
-  disk_directory_create (ectx, dir);
-  FREE (tmp);
+  GNUNET_disk_directory_create (ectx, dir);
+  GNUNET_free (tmp);
 
-  MUTEX_LOCK (&lock);
+  GNUNET_mutex_lock (&lock);
   pi->pid = fork ();
   pi->errno_ = errno;
   if (pi->pid == 0)
@@ -534,7 +547,7 @@
         LOG_STRERROR (LOG_ERROR, "dup2");
       closefile (fd[1]);
       CHDIR (dir);
-      FREE (dir);
+      GNUNET_free (dir);
       execvp (pi->argv[0], &pi->argv[0]);
       GE_LOG_STRERROR_FILE (ectx, LOG_ERROR, "execvp", pi->argv[0]);
       fprintf (stderr,
@@ -542,49 +555,49 @@
                "execvp", pi->argv[0], STRERROR (errno));
       exit (errno);
     }                           /* end pi->pid == 0 */
-  FREE (dir);
+  GNUNET_free (dir);
   closefile (fd[1]);
   for (pos = 0; pos < pi->argc; pos++)
-    FREE (pi->argv[pos]);
-  FREE (pi->argv);
+    GNUNET_free (pi->argv[pos]);
+  GNUNET_free (pi->argv);
   if (pi->pid == -1)
     {
       closefile (fd[0]);
-      SEMAPHORE_UP (pi->sem);
-      MUTEX_UNLOCK (&lock);
+      GNUNET_semaphore_up (pi->sem);
+      GNUNET_mutex_unlock (&lock);
       return -1;
     }
   pi->uid = uidCounter++;
   pi->outputPipe = fd[0];
   pi->outputSize = 0;
   pi->output = NULL;
-  pi->hasExited = NO;
+  pi->hasExited = GNUNET_NO;
   pi->exitStatus = 0;
 
-  GROW (pt, ptSize, ptSize + 1);
+  GNUNET_array_grow (pt, ptSize, ptSize + 1);
   pt[ptSize - 1] = pi;
-  SEMAPHORE_UP (pi->sem);
-  MUTEX_UNLOCK (&lock);
+  GNUNET_semaphore_up (pi->sem);
+  GNUNET_mutex_unlock (&lock);
 
 #define PRT_BUFSIZE 65536
-  buffer = MALLOC (PRT_BUFSIZE);
+  buffer = GNUNET_malloc (PRT_BUFSIZE);
   while (ret > 0)
     {
       ret = READ (pi->outputPipe, buffer, PRT_BUFSIZE);
       if (ret <= 0)
         break;
-      MUTEX_LOCK (&lock);
+      GNUNET_mutex_lock (&lock);
       if (pi->outputSize == -1)
         {
-          MUTEX_UNLOCK (&lock);
+          GNUNET_mutex_unlock (&lock);
           break;
         }
-      GROW (pi->output, pi->outputSize, pi->outputSize + ret);
+      GNUNET_array_grow (pi->output, pi->outputSize, pi->outputSize + ret);
       memcpy (&pi->output[pi->outputSize - ret], buffer, ret);
-      MUTEX_UNLOCK (&lock);
+      GNUNET_mutex_unlock (&lock);
     }
   closefile (pi->outputPipe);
-  MUTEX_LOCK (&lock);
+  GNUNET_mutex_lock (&lock);
 
   ret = waitpid (pi->pid, &pi->exitStatus, 0);
   if (ret != pi->pid)
@@ -592,8 +605,8 @@
       LOG_STRERROR (LOG_WARNING, "waitpid");
       pi->exitStatus = errno;
     }
-  pi->hasExited = YES;
-  MUTEX_UNLOCK (&lock);
+  pi->hasExited = GNUNET_YES;
+  GNUNET_mutex_unlock (&lock);
   return 0;
 }
 
@@ -624,59 +637,60 @@
               (size <= sizeof (TESTBED_CS_MESSAGE))
               ? "size smaller or equal than TESTBED_CS_MESSAGE"
               : "last character in command line is not zero-terminator");
-      sendAcknowledgement (client, SYSERR);
+      sendAcknowledgement (client, GNUNET_SYSERR);
       return;
     }
   size -= sizeof (TESTBED_CS_MESSAGE);
-  pi = MALLOC (sizeof (ProcessInfo));
+  pi = GNUNET_malloc (sizeof (ProcessInfo));
   pi->argc = 0;
   for (pos = 0; pos < size; pos++)
     if (((TESTBED_EXEC_MESSAGE_GENERIC *) emsg)->commandLine[pos] == '\0')
       pi->argc++;
   mainName =
-    STRDUP (&((TESTBED_EXEC_MESSAGE_GENERIC *) emsg)->commandLine[0]);
+    GNUNET_strdup (&((TESTBED_EXEC_MESSAGE_GENERIC *) emsg)->commandLine[0]);
   clientConfig = NULL;
   if (0 == strncmp ("gnunet", mainName, strlen ("gnunet")))
     clientConfig = getConfigurationString ("TESTBED", "CLIENTCONFIG");
   if (clientConfig != NULL)
     pi->argc += 2;
   argc2 = pi->argc;
-  pi->argv = MALLOC (sizeof (char *) * (pi->argc + 1));
+  pi->argv = GNUNET_malloc (sizeof (char *) * (pi->argc + 1));
   pi->argv[0] = mainName;
   pi->argv[pi->argc] = NULL;    /* termination! */
   for (pos = size - 2; pos >= 0; pos--)
     if (((TESTBED_EXEC_MESSAGE_GENERIC *) emsg)->commandLine[pos] == '\0')
       pi->argv[--argc2] =
-        STRDUP (&((TESTBED_EXEC_MESSAGE_GENERIC *) emsg)->
-                commandLine[pos + 1]);
+        GNUNET_strdup (&((TESTBED_EXEC_MESSAGE_GENERIC *) emsg)->
+                       commandLine[pos + 1]);
   if (clientConfig != NULL)
     {
       pi->argv[--argc2] = clientConfig;
-      pi->argv[--argc2] = STRDUP ("-c");
+      pi->argv[--argc2] = GNUNET_strdup ("-c");
     }
-  MUTEX_LOCK (&lock);
+  GNUNET_mutex_lock (&lock);
 
-  pi->sem = SEMAPHORE_CREATE (0);
-  if (0 != PTHREAD_CREATE (&pi->reader,
-                           (PThreadMain) & pipeReaderThread, pi, 8 * 1024))
+  pi->sem = GNUNET_semaphore_create (0);
+  if (0 != GNUNET_thread_create (&pi->reader,
+                                 (GNUNET_ThreadMainFunction) &
+                                 pipeReaderThread, pi, 8 * 1024))
     {
       LOG_STRERROR (LOG_WARNING, "pthread_create");
-      SEMAPHORE_DESTROY (pi->sem);
-      MUTEX_UNLOCK (&lock);
-      FREE (pi);
-      sendAcknowledgement (client, SYSERR);
+      GNUNET_semaphore_destroy (pi->sem);
+      GNUNET_mutex_unlock (&lock);
+      GNUNET_free (pi);
+      sendAcknowledgement (client, GNUNET_SYSERR);
       return;
     }
-  MUTEX_UNLOCK (&lock);
-  SEMAPHORE_DOWN (pi->sem);
-  SEMAPHORE_DESTROY (pi->sem);
+  GNUNET_mutex_unlock (&lock);
+  GNUNET_semaphore_down (pi->sem);
+  GNUNET_semaphore_destroy (pi->sem);
   uid = pi->uid;
   if (uid == -1)
     {
       errno = pi->errno_;
       LOG_STRERROR (LOG_WARNING, "fork");
-      FREE (pi);
-      uid = SYSERR;
+      GNUNET_free (pi);
+      uid = GNUNET_SYSERR;
     }
   sendAcknowledgement (client, uid);
 }
@@ -695,10 +709,10 @@
   void *unused;
   ProcessInfo *pi;
 
-  ret = SYSERR;
+  ret = GNUNET_SYSERR;
   uid = ntohl (msg->pid);
   sig = ntohl (msg->signal);
-  MUTEX_LOCK (&lock);
+  GNUNET_mutex_lock (&lock);
   for (i = 0; i < ptSize; i++)
     {
       pi = pt[i];
@@ -706,34 +720,34 @@
         continue;
       if (sig == -1)
         {
-          if (pi->hasExited == NO)
+          if (pi->hasExited == GNUNET_NO)
             {
-              ret = SYSERR;
+              ret = GNUNET_SYSERR;
             }
           else
             {
               ret = WEXITSTATUS (pi->exitStatus);
               /* free resources... */
-              GROW (pi->output, pi->outputSize, 0);
-              PTHREAD_JOIN (&pi->reader, &unused);
-              FREE (pi);
+              GNUNET_array_grow (pi->output, pi->outputSize, 0);
+              GNUNET_thread_join (&pi->reader, &unused);
+              GNUNET_free (pi);
               pt[i] = pt[ptSize - 1];
-              GROW (pt, ptSize, ptSize - 1);
+              GNUNET_array_grow (pt, ptSize, ptSize - 1);
             }
         }
       else
         {
-          if (pi->hasExited == NO)
+          if (pi->hasExited == GNUNET_NO)
             {
               if (0 == kill (pi->pid, ntohl (msg->signal)))
-                ret = OK;
+                ret = GNUNET_OK;
               else
                 LOG_STRERROR (LOG_WARNING, "kill");
             }
         }
       break;
     }
-  MUTEX_UNLOCK (&lock);
+  GNUNET_mutex_unlock (&lock);
   sendAcknowledgement (client, ret);
 }
 
@@ -747,7 +761,7 @@
   unsigned int uid;
 
   uid = ntohl (msg->pid);
-  MUTEX_LOCK (&lock);
+  GNUNET_mutex_lock (&lock);
   for (i = 0; i < ptSize; i++)
     {
       ProcessInfo *pi;
@@ -758,7 +772,7 @@
           unsigned int pos;
           TESTBED_OUTPUT_REPLY_MESSAGE *msg;
 
-          msg = MALLOC (65532);
+          msg = GNUNET_malloc (65532);
           msg->header.header.type = htons (CS_PROTO_testbed_REPLY);
           msg->header.msgType = htonl (TESTBED_OUTPUT_RESPONSE);
 
@@ -776,15 +790,15 @@
               coreAPI->sendToClient (client, &msg->header.header);
               pos += run;
             }
-          FREE (msg);
+          GNUNET_free (msg);
           /* reset output buffer */
-          GROW (pi->output, pi->outputSize, 0);
-          MUTEX_UNLOCK (&lock);
+          GNUNET_array_grow (pi->output, pi->outputSize, 0);
+          GNUNET_mutex_unlock (&lock);
           return;
         }
     }
-  MUTEX_UNLOCK (&lock);
-  sendAcknowledgement (client, SYSERR);
+  GNUNET_mutex_unlock (&lock);
+  sendAcknowledgement (client, GNUNET_SYSERR);
 }
 
 /**
@@ -806,7 +820,7 @@
       GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
               _("size of `%s' message is too short. Ignoring.\n"),
               "UPLOAD_FILE");
-      sendAcknowledgement (client, SYSERR);
+      sendAcknowledgement (client, GNUNET_SYSERR);
       return;
     }
   end = &((char *) msg)[ntohs (msg->header.header.size)];
@@ -826,7 +840,7 @@
       /* filename empty, not allowed! */
       GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
               _("Empty filename for UPLOAD_FILE message is invalid!\n"));
-      sendAcknowledgement (client, SYSERR);
+      sendAcknowledgement (client, GNUNET_SYSERR);
       return;
     }
   if (s == end)
@@ -835,21 +849,21 @@
       GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
               _
               ("Filename for UPLOAD_FILE message is not null-terminated 
(invalid!)\n"));
-      sendAcknowledgement (client, SYSERR);
+      sendAcknowledgement (client, GNUNET_SYSERR);
       return;
     }
   tmp = getConfigurationString ("TESTBED", "UPLOAD-DIR");
   if (tmp == NULL)
     {
       GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER, _("Upload refused!"));
-      sendAcknowledgement (client, SYSERR);
+      sendAcknowledgement (client, GNUNET_SYSERR);
       return;
     }
   gnHome = expandFileName (tmp);
-  FREE (tmp);
-  disk_directory_create (ectx, gnHome);
+  GNUNET_free (tmp);
+  GNUNET_disk_directory_create (ectx, gnHome);
 
-  filename = MALLOC (strlen (filename) + strlen (gnHome) + 2);  /*2: /, \0 */
+  filename = GNUNET_malloc (strlen (filename) + strlen (gnHome) + 2);   /*2: 
/, \0 */
   strcpy (filename, gnHome);
   strcat (filename, DIR_SEPARATOR_STR);
   strncat (filename,
@@ -860,19 +874,19 @@
       if (REMOVE (filename) && errno != ENOENT)
         {
           GE_LOG_STRERROR_FILE (ectx, LOG_WARNING, "remove", filename);
-          ack = SYSERR;
+          ack = GNUNET_SYSERR;
         }
       else
-        ack = OK;
-      FREE (filename);
+        ack = GNUNET_OK;
+      GNUNET_free (filename);
       sendAcknowledgement (client, ack);
       return;
     }
-  if (htonl (msg->type) != TESTBED_FILE_APPEND)
+  if (htonl (msg->type) != TESTBED_FILE_GNUNET_array_append)
     {
       GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
               _("Invalid message received at %s:%d."), __FILE__, __LINE__);
-      FREE (filename);
+      GNUNET_free (filename);
       return;
     }
   outfile = FOPEN (filename, "ab");
@@ -880,19 +894,19 @@
     {
       /* Send nack back to control point. */
       GE_LOG_STRERROR_FILE (ectx, LOG_ERROR, "fopen", filename);
-      sendAcknowledgement (client, SYSERR);
-      FREE (filename);
+      sendAcknowledgement (client, GNUNET_SYSERR);
+      GNUNET_free (filename);
       return;
     }
-  FREE (filename);
+  GNUNET_free (filename);
   s = ((TESTBED_UPLOAD_FILE_MESSAGE_GENERIC *) msg)->buf + strlen 
(((TESTBED_UPLOAD_FILE_MESSAGE_GENERIC *) msg)->buf) + 1;     /* \0 added */
   size = ntohs (msg->header.header.size) -
     sizeof (TESTBED_UPLOAD_FILE_MESSAGE) -
     (strlen (((TESTBED_UPLOAD_FILE_MESSAGE_GENERIC *) msg)->buf) + 1);
   if (GN_FWRITE (s, 1, size, outfile) != size)
-    ack = SYSERR;
+    ack = GNUNET_SYSERR;
   else
-    ack = OK;
+    ack = GNUNET_OK;
   fclose (outfile);
   sendAcknowledgement (client, ack);
 }
@@ -1031,7 +1045,7 @@
   long int port;
   char *hostname;
   unsigned int curpos;
-  IPaddr ip_info;
+  GNUNET_IPv4Address ip_info;
   struct sockaddr_in soaddr;
   int sock;
   size_t ret;
@@ -1040,7 +1054,7 @@
   char *trusted;
   unsigned short tport;
   char sport[6];
-  cron_t start;
+  GNUNET_CronTime start;
   char c;
   char *buffer;
   int i;
@@ -1061,7 +1075,7 @@
   proxy = getConfigurationString ("GNUNETD", "HTTP-PROXY");
   if (proxy != NULL)
     {
-      if (OK != get_host_by_name (ectx, proxy, &ip_info))
+      if (GNUNET_OK != GNUNET_get_host_by_name (ectx, proxy, &ip_info))
         {
           GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
                   _("Could not resolve name of HTTP proxy `%s'.\n"), proxy);
@@ -1069,7 +1083,8 @@
         }
       else
         {
-          memcpy (&theProxy.sin_addr.s_addr, &ip_info, sizeof (IPaddr));
+          memcpy (&theProxy.sin_addr.s_addr, &ip_info,
+                  sizeof (GNUNET_IPv4Address));
           proxyPort = getConfigurationString ("GNUNETD", "HTTP-PROXY-PORT");
           if (proxyPort == NULL)
             {
@@ -1078,10 +1093,10 @@
           else
             {
               theProxy.sin_port = htons (atoi (proxyPort));
-              FREE (proxyPort);
+              GNUNET_free (proxyPort);
             }
         }
-      FREE (proxy);
+      GNUNET_free (proxy);
     }
   else
     {
@@ -1096,7 +1111,7 @@
     }
   port = 80;                    /* default http port */
 
-  hostname = STRDUP (&reg[strlen (HTTP_URL)]);
+  hostname = GNUNET_strdup (&reg[strlen (HTTP_URL)]);
   buffer = NULL;
   j = -1;
   k = -1;
@@ -1117,13 +1132,13 @@
       char *pstring;
       if (k == -1)
         {
-          pstring = MALLOC (strlen (hostname) - j + 1);
+          pstring = GNUNET_malloc (strlen (hostname) - j + 1);
           memcpy (pstring, &hostname[j], strlen (hostname) - j + 1);
           pstring[strlen (hostname) - j] = '\0';
         }
       else
         {
-          pstring = MALLOC (k - j + 1);
+          pstring = GNUNET_malloc (k - j + 1);
           memcpy (pstring, &hostname[j], k - j);
           pstring[k - j] = '\0';
         }
@@ -1134,12 +1149,12 @@
                   _
                   ("Malformed http URL: `%s' at `%s'.  Testbed-client not 
registered.\n"),
                   reg, buffer);
-          FREE (hostname);
-          FREE (reg);
-          FREE (pstring);
+          GNUNET_free (hostname);
+          GNUNET_free (reg);
+          GNUNET_free (pstring);
           return;
         }
-      FREE (pstring);
+      GNUNET_free (pstring);
     }
   hostname[k] = '\0';
 
@@ -1154,8 +1169,8 @@
   if (sock < 0)
     {
       LOG_STRERROR (LOG_ERROR, "socket");
-      FREE (hostname);
-      FREE (reg);
+      GNUNET_free (hostname);
+      GNUNET_free (reg);
       return;
     }
 
@@ -1163,16 +1178,16 @@
   if (theProxy.sin_addr.s_addr == 0)
     {
       /* no proxy */
-      if (OK != get_host_by_name (ectx, hostname, &ip_info))
+      if (GNUNET_OK != GNUNET_get_host_by_name (ectx, hostname, &ip_info))
         {
           GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
                   _("Could not register testbed, host `%s' unknown\n"),
                   hostname);
-          FREE (reg);
-          FREE (hostname);
+          GNUNET_free (reg);
+          GNUNET_free (hostname);
           return;
         }
-      memcpy (&soaddr.sin_addr.s_addr, &ip_info, sizeof (IPaddr));
+      memcpy (&soaddr.sin_addr.s_addr, &ip_info, sizeof (GNUNET_IPv4Address));
       soaddr.sin_port = htons ((unsigned short) port);
     }
   else
@@ -1189,8 +1204,8 @@
       GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
               _("Failed to send HTTP request to host `%s': %s\n"),
               hostname, STRERROR (errno));
-      FREE (reg);
-      FREE (hostname);
+      GNUNET_free (reg);
+      GNUNET_free (hostname);
       closefile (sock);
       return;
     }
@@ -1198,7 +1213,7 @@
 
   trusted = getConfigurationString ("NETWORK", "TRUSTED");
   if (trusted == NULL)
-    trusted = STRDUP ("127.0.0.0/8;");
+    trusted = GNUNET_strdup ("127.0.0.0/8;");
   i = 0;
   while (trusted[i] != '\0')
     {
@@ -1207,32 +1222,32 @@
       i++;
     }
   tport = getGNUnetPort ();
-  SNPRINTF (sport, 6, "%u", tport);
+  GNUNET_snprintf (sport, 6, "%u", tport);
   secure = getConfigurationString ("TESTBED", "LOGIN");
   if (secure == NULL)
-    secure = STRDUP ("");
+    secure = GNUNET_strdup ("");
   n = strlen (GET_COMMAND)
     + strlen (cmd)
     + strlen (reg) + strlen (trusted) + strlen (sport) + strlen (secure) + 1;
-  command = MALLOC (n);
-  SNPRINTF (command, n, GET_COMMAND, reg, cmd, trusted, sport, secure);
-  FREE (trusted);
-  FREE (secure);
-  FREE (reg);
+  command = GNUNET_malloc (n);
+  GNUNET_snprintf (command, n, GET_COMMAND, reg, cmd, trusted, sport, secure);
+  GNUNET_free (trusted);
+  GNUNET_free (secure);
+  GNUNET_free (reg);
   curpos = strlen (command) + 1;
   curpos = SEND_BLOCKING_ALL (sock, command, curpos);
-  if (SYSERR == (int) curpos)
+  if (GNUNET_SYSERR == (int) curpos)
     {
       GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
               _("Failed so send HTTP request `%s' to host `%s': %s\n"),
               command, hostname, STRERROR (errno));
-      FREE (command);
-      FREE (hostname);
+      GNUNET_free (command);
+      GNUNET_free (hostname);
       closefile (sock);
       return;
     }
-  FREE (command);
-  FREE (hostname);
+  GNUNET_free (command);
+  GNUNET_free (hostname);
   cronTime (&start);
 
   /* we first have to read out the http_response */
@@ -1242,12 +1257,12 @@
     {
       int success;
 
-      if (start + 5 * cronMINUTES < get_time ())
+      if (start + 5 * GNUNET_CRON_MINUTES < GNUNET_get_time ())
         break;                  /* exit after 5m */
       success = RECV_NONBLOCKING (sock, &c, sizeof (c), &ret);
-      if (success == NO)
+      if (success == GNUNET_NO)
         {
-          PTHREAD_SLEEP (100 * cronMILLIS);
+          GNUNET_thread_sleep (100 * GNUNET_CRON_MILLISECONDS);
           continue;
         }
       if ((ret == 0) || (ret == (size_t) - 1))
@@ -1266,7 +1281,8 @@
 #if DEBUG_TESTBED
   GE_LOG (ectx, GE_INFO | GE_REQUEST | GE_USER,
           "Exit register (%d seconds before timeout)\n",
-          (int) (start + 300 * cronSECONDS - get_time ()) / cronSECONDS);
+          (int) (start + 300 * GNUNET_CRON_SECONDS -
+                 GNUNET_get_time ()) / GNUNET_CRON_SECONDS);
 #endif
 }
 
@@ -1282,17 +1298,17 @@
 
   pding = 0;
   /* kill all processes */
-  MUTEX_LOCK (&lock);
+  GNUNET_mutex_lock (&lock);
   for (i = ptSize - 1; i >= 0; i--)
     {
       if (pt[i]->client == client)
         {
           pding++;
-          if (pt[i]->hasExited == NO)
+          if (pt[i]->hasExited == GNUNET_NO)
             kill (pt[i]->pid, SIGKILL); /* die NOW */
         }
     }
-  MUTEX_UNLOCK (&lock);
+  GNUNET_mutex_unlock (&lock);
   /* join on all pthreads, but since they may be
      blocking on the same lock, unlock from time
      to time for a while to let them leave...
@@ -1301,19 +1317,19 @@
   while (pding > 0)
     {
       pding = 0;
-      PTHREAD_SLEEP (50);
-      MUTEX_LOCK (&lock);
+      GNUNET_thread_sleep (50);
+      GNUNET_mutex_lock (&lock);
       for (i = ptSize - 1; i >= 0; i--)
         {
           if (pt[i]->client == client)
             {
-              if (pt[i]->hasExited == YES)
+              if (pt[i]->hasExited == GNUNET_YES)
                 {
-                  PTHREAD_JOIN (&pt[i]->reader, &unused);
-                  GROW (pt[i]->output, pt[i]->outputSize, 0);
-                  FREE (pt[i]);
+                  GNUNET_thread_join (&pt[i]->reader, &unused);
+                  GNUNET_array_grow (pt[i]->output, pt[i]->outputSize, 0);
+                  GNUNET_free (pt[i]);
                   pt[i] = pt[ptSize - 1];
-                  GROW (pt, ptSize, ptSize - 1);
+                  GNUNET_array_grow (pt, ptSize, ptSize - 1);
                 }
               else
                 {
@@ -1321,14 +1337,14 @@
                 }
             }
         }
-      MUTEX_UNLOCK (&lock);
+      GNUNET_mutex_unlock (&lock);
     }
 }
 
 /**
  * Initialize the TESTBED 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_testbed (CoreAPIForApplication * capi)
@@ -1342,19 +1358,20 @@
   GE_ASSERT (ectx, handlers[TESTBED_MAX_MSG].handler == NULL);
   identity = capi->requestService ("identity");
   if (identity == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
 
-  MUTEX_CREATE (&lock);
+  GNUNET_mutex_create (&lock);
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "TESTBED registering handler %d!\n", CS_PROTO_testbed_REQUEST);
   coreAPI = capi;
   GE_ASSERT (ectx,
-             SYSERR !=
+             GNUNET_SYSERR !=
              capi->registerClientExitHandler (&testbedClientExitHandler));
   GE_ASSERT (ectx,
-             SYSERR != capi->registerClientHandler (CS_PROTO_testbed_REQUEST,
-                                                    (CSHandler) &
-                                                    csHandleTestbedRequest));
+             GNUNET_SYSERR !=
+             capi->registerClientHandler (CS_PROTO_testbed_REQUEST,
+                                          (CSHandler) &
+                                          csHandleTestbedRequest));
   httpRegister ("startup");
 
   GE_ASSERT (capi->ectx,
@@ -1365,7 +1382,7 @@
                                                      gettext_noop
                                                      ("allows construction of 
a P2P-testbed"
                                                       " (incomplete)")));
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -1383,16 +1400,16 @@
       void *unused;
 
       pi = pt[i];
-      if (pi->hasExited != NO)
+      if (pi->hasExited != GNUNET_NO)
         kill (pi->pid, SIGKILL);
-      PTHREAD_JOIN (&pi->reader, &unused);
-      FREENONNULL (pi->output);
-      FREE (pi);
+      GNUNET_thread_join (&pi->reader, &unused);
+      GNUNET_free_non_null (pi->output);
+      GNUNET_free (pi);
     }
-  GROW (pt, ptSize, 0);
+  GNUNET_array_grow (pt, ptSize, 0);
 
   httpRegister ("shutdown");
-  MUTEX_DESTROY (&lock);
+  GNUNET_mutex_destroy (&lock);
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "TESTBED unregistering handler %d\n", CS_PROTO_testbed_REQUEST);
   coreAPI->unregisterClientHandler (CS_PROTO_testbed_REQUEST,

Modified: GNUnet/src/applications/testbed/testbed.h
===================================================================
--- GNUnet/src/applications/testbed/testbed.h   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/testbed/testbed.h   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -44,7 +44,7 @@
 #define TESTBED_SET_LOSS_RATE  9       /* Set the drop probability of a 
connection             */
 #define TESTBED_LOAD_MODULE     10      /* load a module                       
                 */
 #define TESTBED_UNLOAD_MODULE   11      /* unload a module                     
                 */
-#define TESTBED_UPLOAD_FILE    12      /* Upload a file to a peer              
                */
+#define TESTBED_UPLOAD_FILE    12      /* GNUNET_ND_UPLOAD a file to a peer    
                          */
 #define TESTBED_DISABLE_hello    13     /* stop sending hellos */
 #define TESTBED_ENABLE_hello     14     /* start sending hellos */
 #define TESTBED_DISABLE_AUTOCONNECT    15       /* stop automatically 
connecting to other peers */
@@ -65,7 +65,7 @@
 /*
   TODO LIST:
   Make loss rate to work. (CG: DONE)
-  Upload a file to a specific machine.  (RF: DONE)
+  GNUNET_ND_UPLOAD a file to a specific machine.  (RF: DONE)
   Revisit statistics (don't re-invent that wheel!)
   AFS download a file on a specific machine.
   AFS insert a file on a specific machine.
@@ -105,19 +105,19 @@
 typedef struct
 {
   TESTBED_CS_MESSAGE header;
-  P2P_hello_MESSAGE helo;
+  GNUNET_MessageHello helo;
 } TESTBED_hello_MESSAGE;
 
 typedef struct
 {
   TESTBED_CS_MESSAGE header;
-  P2P_hello_MESSAGE helo;
+  GNUNET_MessageHello helo;
 } TESTBED_ADD_PEER_MESSAGE;
 
 typedef struct
 {
   TESTBED_CS_MESSAGE header;
-  PeerIdentity host;
+  GNUNET_PeerIdentity host;
 } TESTBED_DEL_PEER_MESSAGE;
 
 typedef struct
@@ -128,20 +128,20 @@
 typedef struct
 {
   TESTBED_CS_MESSAGE header;
-  PeerIdentity otherPeer;
+  GNUNET_PeerIdentity otherPeer;
 } TESTBED_GET_TVALUE_MESSAGE;
 
 typedef struct
 {
   TESTBED_CS_MESSAGE header;
-  PeerIdentity otherPeer;
+  GNUNET_PeerIdentity otherPeer;
   unsigned int trust;
 } TESTBED_SET_TVALUE_MESSAGE;
 
 typedef struct
 {
   TESTBED_CS_MESSAGE header;
-  PeerIdentity otherPeer;
+  GNUNET_PeerIdentity otherPeer;
 } TESTBED_BLACKLIST_MESSAGE;
 
 typedef struct
@@ -173,7 +173,7 @@
   char modulename[1];
 } TESTBED_UNLOAD_MODULE_MESSAGE_GENERIC;
 
-#define TESTBED_FILE_APPEND    1
+#define TESTBED_FILE_GNUNET_array_append       1
 #define TESTBED_FILE_DELETE    2
 
 #define TESTBED_FILE_BLK_SIZE  1400
@@ -218,7 +218,7 @@
 typedef struct
 {
   TESTBED_ALLOW_CONNECT_MESSAGE allow_connect_message;
-  PeerIdentity peers[1];
+  GNUNET_PeerIdentity peers[1];
 } TESTBED_ALLOW_CONNECT_MESSAGE_GENERIC;
 
 typedef struct
@@ -229,7 +229,7 @@
 typedef struct
 {
   TESTBED_DENY_CONNECT_MESSAGE deny_connect_message;
-  PeerIdentity peers[1];
+  GNUNET_PeerIdentity peers[1];
 } TESTBED_DENY_CONNECT_MESSAGE_GENERIC;
 
 typedef struct

Modified: GNUnet/src/applications/testing/Makefile.am
===================================================================
--- GNUnet/src/applications/testing/Makefile.am 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/testing/Makefile.am 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -9,9 +9,6 @@
   testing.c 
 libgnunettesting_api_la_LIBADD = \
   $(top_builddir)/src/util/libgnunetutil.la \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
-  $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
   $(top_builddir)/src/applications/identity/libgnunetidentity_api.la 
 
 

Modified: GNUnet/src/applications/testing/testing.c
===================================================================
--- GNUnet/src/applications/testing/testing.c   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/testing/testing.c   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -27,7 +27,7 @@
 #include "platform.h"
 #include "gnunet_protocols.h"
 #include "gnunet_identity_lib.h"
-#include "gnunet_util_config_impl.h"
+#include "gnunet_util.h"
 #include "gnunet_testing_lib.h"
 
 static void
@@ -36,9 +36,9 @@
 {
   unsigned long long old;
 
-  if ((YES == GC_have_configuration_value (cfg,
-                                           section,
-                                           "PORT")) &&
+  if ((GNUNET_YES == GC_have_configuration_value (cfg,
+                                                  section,
+                                                  "PORT")) &&
       (0 == GC_get_configuration_value_number (cfg,
                                                section,
                                                "PORT",
@@ -63,49 +63,49 @@
  * @param applications application services that should be loaded
  * @param pid of the process (set)
  * @param peer identity of the peer (set)
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-gnunet_testing_start_daemon (unsigned short app_port,
+GNUNET_TESTING_start_daemon (unsigned short app_port,
                              unsigned short tra_offset,
                              const char *gnunetd_home,
                              const char *transports,
                              const char *applications,
                              pid_t * pid,
-                             PeerIdentity * peer, char **configFile)
+                             GNUNET_PeerIdentity * peer, char **configFile)
 {
   int ret;
   char *ipath;
   char *dpath;
   struct GC_Configuration *cfg;
   char host[128];
-  struct ClientServerConnection *sock;
-  P2P_hello_MESSAGE *hello;
+  struct GNUNET_ClientServerConnection *sock;
+  GNUNET_MessageHello *hello;
   int round;
 
   fprintf (stderr, "Starting peer on port %u\n", app_port);
 #if 0
   /* do not usually do this -- may easily
      exhaust entropy pool for hostkey generation... */
-  disk_directory_remove (NULL, gnunetd_home);
+  GNUNET_disk_directory_remove (NULL, gnunetd_home);
 #endif
-  ipath = os_get_installation_path (IPK_DATADIR);
+  ipath = GNUNET_get_installation_path (GNUNET_IPK_DATADIR);
   if (ipath == NULL)
-    return SYSERR;
-  dpath = MALLOC (strlen (ipath) + 128);
+    return GNUNET_SYSERR;
+  dpath = GNUNET_malloc (strlen (ipath) + 128);
   strcpy (dpath, ipath);
-  FREE (ipath);
+  GNUNET_free (ipath);
   strcat (dpath, DIR_SEPARATOR_STR "gnunet-testing.conf");
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, dpath))
     {
       fprintf (stderr,
                "Failed to read default configuration file `%s'\n", dpath);
       GC_free (cfg);
-      FREE (dpath);
-      return SYSERR;
+      GNUNET_free (dpath);
+      return GNUNET_SYSERR;
     }
-  FREE (dpath);
+  GNUNET_free (dpath);
   updatePort (cfg, "TCP", tra_offset);
   updatePort (cfg, "TCP6", tra_offset);
   updatePort (cfg, "UDP", tra_offset);
@@ -125,38 +125,38 @@
                                        "GNUNETD",
                                        "APPLICATIONS", applications);
   GC_set_configuration_value_number (cfg, NULL, "NETWORK", "PORT", app_port);
-  dpath = STRDUP ("/tmp/gnunet-config.XXXXXX");
+  dpath = GNUNET_strdup ("/tmp/gnunet-config.XXXXXX");
   ret = mkstemp (dpath);
   if (ret == -1)
     {
       GE_LOG_STRERROR_FILE (NULL,
                             GE_ERROR | GE_USER | GE_BULK, "mkstemp", dpath);
-      FREE (dpath);
+      GNUNET_free (dpath);
       GC_free (cfg);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   CLOSE (ret);
   if (0 != GC_write_configuration (cfg, dpath))
     {
       fprintf (stderr,
                "Failed to write peer configuration file `%s'\n", dpath);
-      FREE (dpath);
+      GNUNET_free (dpath);
       GC_free (cfg);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   GC_free (cfg);
 
-  cfg = GC_create_C_impl ();
-  /* cfg is now client CFG for os_daemon_start */
-  SNPRINTF (host, 128, "localhost:%u", app_port);
+  cfg = GC_create ();
+  /* cfg is now client CFG for GNUNET_daemon_start */
+  GNUNET_snprintf (host, 128, "localhost:%u", app_port);
   GC_set_configuration_value_string (cfg, NULL, "NETWORK", "HOST", host);
 
-  ret = os_daemon_start (NULL, cfg, dpath, NO);
+  ret = GNUNET_daemon_start (NULL, cfg, dpath, GNUNET_NO);
   if (ret == -1)
     {
       fprintf (stderr, "Failed to start daemon!\n");
       GC_free (cfg);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   *pid = ret;
 
@@ -164,35 +164,37 @@
   /* we need to wait quite a while since the peers
      maybe creating public keys and waiting for
      entropy! */
-  if (OK != connection_wait_for_running (NULL, cfg, 15 * cronMINUTES))
+  if (GNUNET_OK !=
+      GNUNET_wait_for_daemon_running (NULL, cfg, 15 * GNUNET_CRON_MINUTES))
     {
       fprintf (stderr, "Failed to confirm daemon running!\n");
       GC_free (cfg);
       UNLINK (dpath);
-      FREE (dpath);
-      return SYSERR;
+      GNUNET_free (dpath);
+      return GNUNET_SYSERR;
     }
   *configFile = dpath;
   dpath = NULL;
   round = 0;
-  ret = SYSERR;
-  while ((round++ < 10) && (ret == SYSERR))
+  ret = GNUNET_SYSERR;
+  while ((round++ < 10) && (ret == GNUNET_SYSERR))
     {
-      sock = client_connection_create (NULL, cfg);
-      ret = gnunet_identity_get_self (sock, &hello);
-      if (ret == OK)
+      sock = GNUNET_client_connection_create (NULL, cfg);
+      ret = GNUNET_IDENTITY_get_self (sock, &hello);
+      if (ret == GNUNET_OK)
         {
-          hash (&hello->publicKey, sizeof (PublicKey), &peer->hashPubKey);
-          FREE (hello);
+          GNUNET_hash (&hello->publicKey, sizeof (GNUNET_RSA_PublicKey),
+                       &peer->hashPubKey);
+          GNUNET_free (hello);
         }
       else
         {
-          PTHREAD_SLEEP (2 * cronSECONDS);
+          GNUNET_thread_sleep (2 * GNUNET_CRON_SECONDS);
         }
-      connection_destroy (sock);
+      GNUNET_client_connection_destroy (sock);
     }
   GC_free (cfg);
-  if (ret == SYSERR)
+  if (ret == GNUNET_SYSERR)
     fprintf (stderr,
              "Failed to obtain daemon's identity (is a transport loaded?)!\n");
 
@@ -206,69 +208,72 @@
  *
  * @param port1 client port of the first daemon
  * @param port2 client port of the second daemon
- * @return OK on success, SYSERR on failure
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
 int
-gnunet_testing_connect_daemons (unsigned short port1, unsigned short port2)
+GNUNET_TESTING_connect_daemons (unsigned short port1, unsigned short port2)
 {
   char host[128];
-  GC_Configuration *cfg1 = GC_create_C_impl ();
-  GC_Configuration *cfg2 = GC_create_C_impl ();
-  struct ClientServerConnection *sock1;
-  struct ClientServerConnection *sock2;
+  struct GC_Configuration *cfg1 = GC_create ();
+  struct GC_Configuration *cfg2 = GC_create ();
+  struct GNUNET_ClientServerConnection *sock1;
+  struct GNUNET_ClientServerConnection *sock2;
   int ret;
-  P2P_hello_MESSAGE *h1;
-  P2P_hello_MESSAGE *h2;
+  GNUNET_MessageHello *h1;
+  GNUNET_MessageHello *h2;
 
-  ret = SYSERR;
-  SNPRINTF (host, 128, "localhost:%u", port1);
+  ret = GNUNET_SYSERR;
+  GNUNET_snprintf (host, 128, "localhost:%u", port1);
   GC_set_configuration_value_string (cfg1, NULL, "NETWORK", "HOST", host);
-  SNPRINTF (host, 128, "localhost:%u", port2);
+  GNUNET_snprintf (host, 128, "localhost:%u", port2);
   GC_set_configuration_value_string (cfg2, NULL, "NETWORK", "HOST", host);
-  if ((OK == connection_wait_for_running (NULL,
-                                          cfg1,
-                                          300 * cronSECONDS)) &&
-      (OK == connection_wait_for_running (NULL, cfg2, 300 * cronSECONDS)))
+  if ((GNUNET_OK == GNUNET_wait_for_daemon_running (NULL,
+                                                    cfg1,
+                                                    300 *
+                                                    GNUNET_CRON_SECONDS))
+      && (GNUNET_OK ==
+          GNUNET_wait_for_daemon_running (NULL, cfg2,
+                                          300 * GNUNET_CRON_SECONDS)))
     {
-      sock1 = client_connection_create (NULL, cfg1);
-      sock2 = client_connection_create (NULL, cfg2);
+      sock1 = GNUNET_client_connection_create (NULL, cfg1);
+      sock2 = GNUNET_client_connection_create (NULL, cfg2);
       ret = -10;
       fprintf (stderr, _("Waiting for peers to connect"));
-      while ((ret++ < -1) && (GNUNET_SHUTDOWN_TEST () == NO))
+      while ((ret++ < -1) && (GNUNET_shutdown_test () == GNUNET_NO))
         {
           h1 = NULL;
           h2 = NULL;
-          if ((OK == gnunet_identity_get_self (sock1,
-                                               &h1)) &&
-              (OK == gnunet_identity_get_self (sock2,
-                                               &h2)) &&
-              (OK == gnunet_identity_peer_add (sock1,
-                                               h2)) &&
-              (OK == gnunet_identity_peer_add (sock2, h1)))
+          if ((GNUNET_OK == GNUNET_IDENTITY_get_self (sock1,
+                                                      &h1)) &&
+              (GNUNET_OK == GNUNET_IDENTITY_get_self (sock2,
+                                                      &h2)) &&
+              (GNUNET_OK == GNUNET_IDENTITY_peer_add (sock1,
+                                                      h2)) &&
+              (GNUNET_OK == GNUNET_IDENTITY_peer_add (sock2, h1)))
             {
               fprintf (stderr, ".");
-              if (YES == gnunet_identity_request_connect (sock1,
-                                                          &h2->
-                                                          senderIdentity))
+              if (GNUNET_YES == GNUNET_IDENTITY_request_connect (sock1,
+                                                                 &h2->
+                                                                 
senderIdentity))
                 {
-                  ret = OK;
+                  ret = GNUNET_OK;
                   break;
                 }
-              if (YES == gnunet_identity_request_connect (sock2,
-                                                          &h1->
-                                                          senderIdentity))
+              if (GNUNET_YES == GNUNET_IDENTITY_request_connect (sock2,
+                                                                 &h1->
+                                                                 
senderIdentity))
                 {
-                  ret = OK;
+                  ret = GNUNET_OK;
                   break;
                 }
-              PTHREAD_SLEEP (100 * cronMILLIS);
+              GNUNET_thread_sleep (100 * GNUNET_CRON_MILLISECONDS);
             }
-          FREENONNULL (h1);
-          FREENONNULL (h2);
+          GNUNET_free_non_null (h1);
+          GNUNET_free_non_null (h2);
         }
-      fprintf (stderr, "%s\n", ret == OK ? "!" : "?");
-      connection_destroy (sock1);
-      connection_destroy (sock2);
+      fprintf (stderr, "%s\n", ret == GNUNET_OK ? "!" : "?");
+      GNUNET_client_connection_destroy (sock1);
+      GNUNET_client_connection_destroy (sock2);
     }
   else
     {
@@ -284,14 +289,14 @@
  * Shutdown the GNUnet daemon waiting on the given port
  * and running under the given pid.
  *
- * @return OK on success, SYSERR on failure
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
 int
-gnunet_testing_stop_daemon (unsigned short port, pid_t pid)
+GNUNET_TESTING_stop_daemon (unsigned short port, pid_t pid)
 {
-  if (os_daemon_stop (NULL, pid) != YES)
-    return SYSERR;
-  return OK;
+  if (GNUNET_daemon_stop (NULL, pid) != GNUNET_YES)
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 /**
@@ -302,39 +307,38 @@
  *
  * @return handle used to stop the daemons, NULL on error
  */
-struct DaemonContext *
-gnunet_testing_start_daemons (const char *transports,
+struct GNUNET_TESTING_DaemonContext *
+GNUNET_TESTING_start_daemons (const char *transports,
                               const char *applications,
                               const char *gnunetd_home_prefix,
                               unsigned short app_baseport,
                               unsigned short delta, unsigned int count)
 {
-  struct DaemonContext *ret;
-  struct DaemonContext *nxt;
+  struct GNUNET_TESTING_DaemonContext *ret;
+  struct GNUNET_TESTING_DaemonContext *nxt;
   unsigned int pos;
   char *home;
   size_t max;
   pid_t pid;
-  PeerIdentity peer;
+  GNUNET_PeerIdentity peer;
   char *cf;
 
   ret = NULL;
   max = strlen (gnunetd_home_prefix) + 14;
-  home = MALLOC (max);
+  home = GNUNET_malloc (max);
   for (pos = 0; pos < count; pos++)
     {
-      SNPRINTF (home, max, "%s.%u", gnunetd_home_prefix, pos);
-      if (OK != gnunet_testing_start_daemon (app_baseport + pos * delta,
-                                             delta * pos,
-                                             home,
-                                             transports,
-                                             applications, &pid, &peer, &cf))
+      GNUNET_snprintf (home, max, "%s.%u", gnunetd_home_prefix, pos);
+      if (GNUNET_OK !=
+          GNUNET_TESTING_start_daemon (app_baseport + pos * delta,
+                                       delta * pos, home, transports,
+                                       applications, &pid, &peer, &cf))
         {
-          gnunet_testing_stop_daemons (ret);
+          GNUNET_TESTING_stop_daemons (ret);
           ret = NULL;
           break;
         }
-      nxt = MALLOC (sizeof (struct DaemonContext));
+      nxt = GNUNET_malloc (sizeof (struct GNUNET_TESTING_DaemonContext));
       nxt->next = ret;
       nxt->pid = pid;
       nxt->peer = peer;
@@ -342,25 +346,25 @@
       nxt->port = app_baseport + pos * delta;
       ret = nxt;
     }
-  FREE (home);
+  GNUNET_free (home);
   return ret;
 }
 
 int
-gnunet_testing_stop_daemons (struct DaemonContext *peers)
+GNUNET_TESTING_stop_daemons (struct GNUNET_TESTING_DaemonContext *peers)
 {
-  struct DaemonContext *next;
+  struct GNUNET_TESTING_DaemonContext *next;
   int ret;
 
-  ret = OK;
+  ret = GNUNET_OK;
   while (peers != NULL)
     {
       next = peers->next;
-      if (OK != gnunet_testing_stop_daemon (peers->port, peers->pid))
-        ret = SYSERR;
+      if (GNUNET_OK != GNUNET_TESTING_stop_daemon (peers->port, peers->pid))
+        ret = GNUNET_SYSERR;
       UNLINK (peers->configFile);
-      FREE (peers->configFile);
-      FREE (peers);
+      GNUNET_free (peers->configFile);
+      GNUNET_free (peers);
       peers = next;
     }
   return ret;

Modified: GNUnet/src/applications/testing/testingtest.c
===================================================================
--- GNUnet/src/applications/testing/testingtest.c       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/testing/testingtest.c       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -37,41 +37,41 @@
 {
   pid_t daemon1;
   pid_t daemon2;
-  PeerIdentity p1;
-  PeerIdentity p2;
+  GNUNET_PeerIdentity p1;
+  GNUNET_PeerIdentity p2;
   char *c1 = NULL;
   char *c2 = NULL;
   int ret = 0;
 
-  if (OK != gnunet_testing_start_daemon (12087,
-                                         10000,
-                                         "/tmp/gnunet-testing-1",
-                                         "tcp",
-                                         "advertising stats",
-                                         &daemon1, &p1, &c1))
+  if (GNUNET_OK != GNUNET_TESTING_start_daemon (12087,
+                                                10000,
+                                                "/tmp/gnunet-testing-1",
+                                                "tcp",
+                                                "advertising stats",
+                                                &daemon1, &p1, &c1))
     ret |= 1;
-  if (OK != gnunet_testing_start_daemon (22087,
-                                         20000,
-                                         "/tmp/gnunet-testing-2",
-                                         "tcp",
-                                         "advertising stats",
-                                         &daemon2, &p2, &c2))
+  if (GNUNET_OK != GNUNET_TESTING_start_daemon (22087,
+                                                20000,
+                                                "/tmp/gnunet-testing-2",
+                                                "tcp",
+                                                "advertising stats",
+                                                &daemon2, &p2, &c2))
     ret |= 2;
-  if (OK != gnunet_testing_connect_daemons (12087, 22087))
+  if (GNUNET_OK != GNUNET_TESTING_connect_daemons (12087, 22087))
     ret |= 4;
-  if (OK != gnunet_testing_stop_daemon (12087, daemon1))
+  if (GNUNET_OK != GNUNET_TESTING_stop_daemon (12087, daemon1))
     ret |= 8;
-  if (OK != gnunet_testing_stop_daemon (22087, daemon2))
+  if (GNUNET_OK != GNUNET_TESTING_stop_daemon (22087, daemon2))
     ret |= 16;
   if (c1 != NULL)
     {
       UNLINK (c1);
-      FREE (c1);
+      GNUNET_free (c1);
     }
   if (c2 != NULL)
     {
       UNLINK (c2);
-      FREE (c2);
+      GNUNET_free (c2);
     }
   return ret;
 }

Modified: GNUnet/src/applications/topology_default/Makefile.am
===================================================================
--- GNUnet/src/applications/topology_default/Makefile.am        2007-11-23 
11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/topology_default/Makefile.am        2007-11-23 
11:51:54 UTC (rev 5742)
@@ -8,8 +8,6 @@
 libgnunetmodule_topology_default_la_SOURCES = \
   topology.c 
 libgnunetmodule_topology_default_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_topology_default_la_LDFLAGS = \
   -export-dynamic -avoid-version -module

Modified: GNUnet/src/applications/topology_default/topology.c
===================================================================
--- GNUnet/src/applications/topology_default/topology.c 2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/topology_default/topology.c 2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -39,9 +39,9 @@
 #include "gnunet_transport_service.h"
 #include "gnunet_pingpong_service.h"
 
-#define DEBUG_TOPOLOGY NO
+#define DEBUG_TOPOLOGY GNUNET_NO
 
-#define DEBUG_LIVENESS NO
+#define DEBUG_LIVENESS GNUNET_NO
 
 /**
  * After 2 minutes on an inactive connection, probe the other
@@ -54,7 +54,7 @@
  * How often should the cron-job scan for free slots (to establish
  * new connections)?
  */
-#define LIVE_SCAN_FREQUENCY 500 * cronMILLIS
+#define LIVE_SCAN_FREQUENCY 500 * GNUNET_CRON_MILLISECONDS
 
 /**
  * Value > 1 that determines the chance (1:LSE) that the cron job
@@ -92,7 +92,7 @@
   unsigned int index;
   unsigned int matchCount;
   long long costSelector;
-  PeerIdentity match;
+  GNUNET_PeerIdentity match;
 } IndexMatch;
 
 /**
@@ -105,23 +105,23 @@
  * @param im updated structure used to select the peer
  */
 static int
-scanHelperCount (const PeerIdentity * id,
+scanHelperCount (const GNUNET_PeerIdentity * id,
                  unsigned short proto, int confirmed, void *data)
 {
   IndexMatch *im = data;
 
-  if (0 == memcmp (coreAPI->myIdentity, id, sizeof (PeerIdentity)))
-    return OK;
+  if (0 == memcmp (coreAPI->myIdentity, id, sizeof (GNUNET_PeerIdentity)))
+    return GNUNET_OK;
   if (coreAPI->computeIndex (id) != im->index)
-    return OK;
-  if (OK == coreAPI->queryPeerStatus (id, NULL, NULL))
-    return OK;
-  if (YES == transport->isAvailable (proto))
+    return GNUNET_OK;
+  if (GNUNET_OK == coreAPI->queryPeerStatus (id, NULL, NULL))
+    return GNUNET_OK;
+  if (GNUNET_YES == transport->isAvailable (proto))
     {
       im->matchCount++;
       im->costSelector += transport->getCost (proto);
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -133,28 +133,28 @@
  * @param im structure responsible for the selection process
  */
 static int
-scanHelperSelect (const PeerIdentity * id,
+scanHelperSelect (const GNUNET_PeerIdentity * id,
                   unsigned short proto, int confirmed, void *data)
 {
   IndexMatch *im = data;
 
-  if (0 == memcmp (coreAPI->myIdentity, id, sizeof (PeerIdentity)))
-    return OK;
+  if (0 == memcmp (coreAPI->myIdentity, id, sizeof (GNUNET_PeerIdentity)))
+    return GNUNET_OK;
   if (coreAPI->computeIndex (id) != im->index)
-    return OK;
-  if (OK == coreAPI->queryPeerStatus (id, NULL, NULL))
-    return OK;
-  if (YES == transport->isAvailable (proto))
+    return GNUNET_OK;
+  if (GNUNET_OK == coreAPI->queryPeerStatus (id, NULL, NULL))
+    return GNUNET_OK;
+  if (GNUNET_YES == transport->isAvailable (proto))
     {
       im->costSelector -= transport->getCost (proto);
       if ((im->matchCount == 0) || (im->costSelector < 0))
         {
           im->match = *id;
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       im->matchCount--;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -169,15 +169,16 @@
 scanForHosts (unsigned int index)
 {
   IndexMatch indexMatch;
-  cron_t now;
+  GNUNET_CronTime now;
 #if DEBUG_TOPOLOGY
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
-  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;                     /* bandwidth saturated, do not
                                    push it higher! */
-  now = get_time ();
+  now = GNUNET_get_time ();
   indexMatch.index = index;
   indexMatch.matchCount = 0;
   indexMatch.costSelector = 0;
@@ -192,18 +193,19 @@
       return;                   /* no matching peers found! */
     }
   if (indexMatch.costSelector > 0)
-    indexMatch.costSelector = weak_randomi64 (indexMatch.costSelector);
+    indexMatch.costSelector =
+      GNUNET_random_u64 (GNUNET_RANDOM_QUALITY_WEAK, indexMatch.costSelector);
   indexMatch.match = *(coreAPI->myIdentity);
   identity->forEachHost (now, &scanHelperSelect, &indexMatch);
   if (0 == memcmp (coreAPI->myIdentity,
-                   &indexMatch.match, sizeof (PeerIdentity)))
+                   &indexMatch.match, sizeof (GNUNET_PeerIdentity)))
     return;                     /* should happen really rarely */
   if (coreAPI->computeIndex (&indexMatch.match) != index)
     {
       GE_BREAK (NULL, 0);       /* should REALLY not happen */
       return;
     }
-  if (OK == coreAPI->queryPeerStatus (&indexMatch.match, NULL, NULL))
+  if (GNUNET_OK == coreAPI->queryPeerStatus (&indexMatch.match, NULL, NULL))
     {
       GE_BREAK (NULL, 0);       /* should REALLY not happen */
       return;
@@ -212,86 +214,88 @@
 #if DEBUG_TOPOLOGY
   IF_GELOG (coreAPI->ectx,
             GE_DEBUG | GE_REQUEST | GE_USER | GE_DEVELOPER,
-            hash2enc (&indexMatch.match.hashPubKey, &enc));
+            GNUNET_hash_to_enc (&indexMatch.match.hashPubKey, &enc));
   GE_LOG (coreAPI->ectx,
           GE_DEBUG | GE_REQUEST | GE_USER | GE_DEVELOPER,
           "Trying to connect to peer `%s'\n", &enc);
 #endif
-  if (NO == identity->isBlacklisted (&indexMatch.match, YES))
+  if (GNUNET_NO == identity->isBlacklisted (&indexMatch.match, GNUNET_YES))
     {
       coreAPI->unicast (&indexMatch.match, NULL, 0, 0);
       identity->blacklistHost (&indexMatch.match, (unsigned int) (saturation * 
5 * 60 * 60),    /* 5 hours at full saturation */
-                               NO);
+                               GNUNET_NO);
     }
 }
 
 /**
- * We received a sign of life from this host.
+ * We received a GNUNET_RSA_sign of life from this host.
  *
- * @param hostId the peer that gave a sign of live
+ * @param hostId the peer that gave a GNUNET_RSA_sign of live
  */
 static void
 notifyPONG (void *cls)
 {
-  PeerIdentity *hostId = cls;
+  GNUNET_PeerIdentity *hostId = cls;
 #if DEBUG_TOPOLOGY || DEBUG_LIVENESS
-  EncName enc;
+  GNUNET_EncName enc;
 
   IF_GELOG (coreAPI->ectx,
             GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
-            hash2enc (&hostId->hashPubKey, &enc));
+            GNUNET_hash_to_enc (&hostId->hashPubKey, &enc));
   GE_LOG (coreAPI->ectx,
           GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
           "Received liveness confirmation from `%s'.\n", &enc);
 #endif
 
   coreAPI->confirmSessionUp (hostId);
-  FREE (hostId);
+  GNUNET_free (hostId);
 }
 
 /**
  * Check the liveness of the peer and possibly ping it.
  */
 static void
-checkNeedForPing (const PeerIdentity * peer, void *unused)
+checkNeedForPing (const GNUNET_PeerIdentity * peer, void *unused)
 {
-  cron_t now;
-  cron_t act;
-  PeerIdentity *hi;
+  GNUNET_CronTime now;
+  GNUNET_CronTime act;
+  GNUNET_PeerIdentity *hi;
   int ran;
 
-  ran = weak_randomi (LIVE_PING_EFFECTIVENESS);
+  ran =
+    GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, LIVE_PING_EFFECTIVENESS);
   if (ran != 0)
     return;
-  now = get_time ();
-  if (SYSERR == coreAPI->getLastActivityOf (peer, &act))
+  now = GNUNET_get_time ();
+  if (GNUNET_SYSERR == coreAPI->getLastActivityOf (peer, &act))
     {
       GE_BREAK (coreAPI->ectx, 0);
       return;                   /* this should not happen... */
     }
 
-  if (now - act > SECONDS_PINGATTEMPT * cronSECONDS)
+  if (now - act > SECONDS_PINGATTEMPT * GNUNET_CRON_SECONDS)
     {
       /* if we have less than 75% of the number of connections
          that we would like to have, try ping-ing the other side
          to keep the connection open instead of hanging up */
 #if DEBUG_TOPOLOGY || DEBUG_LIVENESS
-      EncName enc;
+      GNUNET_EncName enc;
 
       IF_GELOG (coreAPI->ectx,
                 GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
-                hash2enc (&peer->hashPubKey, &enc));
+                GNUNET_hash_to_enc (&peer->hashPubKey, &enc));
       GE_LOG (coreAPI->ectx,
               GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
               "Peer `%s' was inactive for %llus.  Sending PING.\n",
-              &enc, (now - act) / cronSECONDS);
+              &enc, (now - act) / GNUNET_CRON_SECONDS);
 #endif
 
 
-      hi = MALLOC (sizeof (PeerIdentity));
+      hi = GNUNET_malloc (sizeof (GNUNET_PeerIdentity));
       *hi = *peer;
-      if (OK != pingpong->ping (peer, &notifyPONG, hi, NO, rand ()))
-        FREE (hi);
+      if (GNUNET_OK !=
+          pingpong->ping (peer, &notifyPONG, hi, GNUNET_NO, rand ()))
+        GNUNET_free (hi);
     }
 }
 
@@ -313,9 +317,10 @@
 
   autoconnect = GC_get_configuration_value_yesno (coreAPI->cfg,
                                                   "GNUNETD",
-                                                  "DISABLE-AUTOCONNECT", NO);
+                                                  "DISABLE-AUTOCONNECT",
+                                                  GNUNET_NO);
   slotCount = coreAPI->getSlotCount ();
-  if ((NO == autoconnect) && (saturation < 1))
+  if ((GNUNET_NO == autoconnect) && (saturation < 1))
     {
       if (saturation * MAX_PEERS_PER_SLOT >= 1)
         minint = (unsigned int) (1 / saturation);
@@ -323,7 +328,8 @@
         minint = MAX_PEERS_PER_SLOT;    /* never put more than 10 peers into a 
slot */
       for (i = slotCount - 1; i >= 0; i--)
         {
-          if (weak_randomi (LIVE_SCAN_EFFECTIVENESS) != 0)
+          if (GNUNET_random_u32
+              (GNUNET_RANDOM_QUALITY_WEAK, LIVE_SCAN_EFFECTIVENESS) != 0)
             continue;
           if (minint > coreAPI->isSlotUsed (i))
             scanForHosts (i);
@@ -375,12 +381,12 @@
 }
 
 static int
-allowConnection (const PeerIdentity * peer)
+allowConnection (const GNUNET_PeerIdentity * peer)
 {
   if ((coreAPI->myIdentity != NULL) &&
-      (0 == memcmp (coreAPI->myIdentity, peer, sizeof (PeerIdentity))))
-    return SYSERR;              /* disallow connections to self */
-  return OK;                    /* allow everything else */
+      (0 == memcmp (coreAPI->myIdentity, peer, sizeof (GNUNET_PeerIdentity))))
+    return GNUNET_SYSERR;       /* disallow connections to self */
+  return GNUNET_OK;             /* allow everything else */
 }
 
 Topology_ServiceAPI *
@@ -413,9 +419,9 @@
       transport = NULL;
       return NULL;
     }
-  cron_add_job (capi->cron,
-                &cronCheckLiveness,
-                LIVE_SCAN_FREQUENCY, LIVE_SCAN_FREQUENCY, NULL);
+  GNUNET_cron_add_job (capi->cron,
+                       &cronCheckLiveness,
+                       LIVE_SCAN_FREQUENCY, LIVE_SCAN_FREQUENCY, NULL);
   api.estimateNetworkSize = &estimateNetworkSize;
   api.getSaturation = &estimateSaturation;
   api.allowConnectionFrom = &allowConnection;
@@ -425,7 +431,8 @@
 int
 release_module_topology_default ()
 {
-  cron_del_job (coreAPI->cron, &cronCheckLiveness, LIVE_SCAN_FREQUENCY, NULL);
+  GNUNET_cron_del_job (coreAPI->cron, &cronCheckLiveness, LIVE_SCAN_FREQUENCY,
+                       NULL);
   coreAPI->releaseService (identity);
   identity = NULL;
   coreAPI->releaseService (transport);
@@ -433,7 +440,7 @@
   coreAPI->releaseService (pingpong);
   pingpong = NULL;
   coreAPI = NULL;
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -465,7 +472,7 @@
                                                      "topology",
                                                      gettext_noop
                                                      ("maintains GNUnet 
default mesh topology")));
-  return OK;
+  return GNUNET_OK;
 }
 
 void

Modified: GNUnet/src/applications/topology_f2f/Makefile.am
===================================================================
--- GNUnet/src/applications/topology_f2f/Makefile.am    2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/topology_f2f/Makefile.am    2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -8,8 +8,6 @@
 libgnunetmodule_topology_f2f_la_SOURCES = \
   topology.c 
 libgnunetmodule_topology_f2f_la_LIBADD = \
-  $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
   $(top_builddir)/src/util/libgnunetutil.la 
 libgnunetmodule_topology_f2f_la_LDFLAGS = \
   -export-dynamic -avoid-version -module

Modified: GNUnet/src/applications/topology_f2f/topology.c
===================================================================
--- GNUnet/src/applications/topology_f2f/topology.c     2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/topology_f2f/topology.c     2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -39,7 +39,7 @@
 #include "gnunet_transport_service.h"
 #include "gnunet_pingpong_service.h"
 
-#define DEBUG_TOPOLOGY NO
+#define DEBUG_TOPOLOGY GNUNET_NO
 
 /**
  * After 2 minutes on an inactive connection, probe the other
@@ -53,7 +53,7 @@
  * How often should the cron-job scan for free slots (to establish
  * new connections)?
  */
-#define LIVE_SCAN_FREQUENCY 500 * cronMILLIS
+#define LIVE_SCAN_FREQUENCY 500 * GNUNET_CRON_MILLISECONDS
 
 /**
  * Value > 1 that determines the chance (1:LSE) that the cron job
@@ -93,24 +93,24 @@
   unsigned int index;
   unsigned int matchCount;
   long long costSelector;
-  PeerIdentity match;
+  GNUNET_PeerIdentity match;
 } IndexMatch;
 
-static PeerIdentity *friends;
+static GNUNET_PeerIdentity *friends;
 static unsigned int friendCount;
 
 static int
-allowConnection (const PeerIdentity * peer)
+allowConnection (const GNUNET_PeerIdentity * peer)
 {
   int i;
 
   if ((coreAPI->myIdentity != NULL) &&
-      (0 == memcmp (coreAPI->myIdentity, peer, sizeof (PeerIdentity))))
-    return SYSERR;              /* disallow connections to self */
+      (0 == memcmp (coreAPI->myIdentity, peer, sizeof (GNUNET_PeerIdentity))))
+    return GNUNET_SYSERR;       /* disallow connections to self */
   for (i = friendCount - 1; i >= 0; i--)
-    if (0 == memcmp (&friends[i], peer, sizeof (PeerIdentity)))
-      return OK;
-  return SYSERR;
+    if (0 == memcmp (&friends[i], peer, sizeof (GNUNET_PeerIdentity)))
+      return GNUNET_OK;
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -123,23 +123,24 @@
  * @param im updated structure used to select the peer
  */
 static int
-scanHelperCount (const PeerIdentity * id,
+scanHelperCount (const GNUNET_PeerIdentity * id,
                  unsigned short proto, int confirmed, void *cls)
 {
   IndexMatch *im = cls;
 
-  if (0 == memcmp (coreAPI->myIdentity, id, sizeof (PeerIdentity)))
-    return OK;
+  if (0 == memcmp (coreAPI->myIdentity, id, sizeof (GNUNET_PeerIdentity)))
+    return GNUNET_OK;
   if (coreAPI->computeIndex (id) != im->index)
-    return OK;
-  if (OK == coreAPI->queryPeerStatus (id, NULL, NULL))
-    return OK;
-  if ((YES == transport->isAvailable (proto)) && (OK == allowConnection (id)))
+    return GNUNET_OK;
+  if (GNUNET_OK == coreAPI->queryPeerStatus (id, NULL, NULL))
+    return GNUNET_OK;
+  if ((GNUNET_YES == transport->isAvailable (proto))
+      && (GNUNET_OK == allowConnection (id)))
     {
       im->matchCount++;
       im->costSelector += transport->getCost (proto);
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -151,27 +152,28 @@
  * @param im structure responsible for the selection process
  */
 static int
-scanHelperSelect (const PeerIdentity * id,
+scanHelperSelect (const GNUNET_PeerIdentity * id,
                   const unsigned short proto, int confirmed, void *cls)
 {
   IndexMatch *im = cls;
-  if (0 == memcmp (coreAPI->myIdentity, id, sizeof (PeerIdentity)))
-    return OK;
+  if (0 == memcmp (coreAPI->myIdentity, id, sizeof (GNUNET_PeerIdentity)))
+    return GNUNET_OK;
   if (coreAPI->computeIndex (id) != im->index)
-    return OK;
-  if (OK == coreAPI->queryPeerStatus (id, NULL, NULL))
-    return OK;
-  if ((OK == allowConnection (id)) && (YES == transport->isAvailable (proto)))
+    return GNUNET_OK;
+  if (GNUNET_OK == coreAPI->queryPeerStatus (id, NULL, NULL))
+    return GNUNET_OK;
+  if ((GNUNET_OK == allowConnection (id))
+      && (GNUNET_YES == transport->isAvailable (proto)))
     {
       im->costSelector -= transport->getCost (proto);
       if ((im->matchCount == 0) || (im->costSelector < 0))
         {
           im->match = *id;
-          return SYSERR;        /* abort iteration */
+          return GNUNET_SYSERR; /* abort iteration */
         }
       im->matchCount--;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -185,12 +187,12 @@
 scanForHosts (unsigned int index)
 {
   IndexMatch indexMatch;
-  cron_t now;
+  GNUNET_CronTime now;
 #if DEBUG_TOPOLOGY
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
-  now = get_time ();
+  now = GNUNET_get_time ();
   indexMatch.index = index;
   indexMatch.matchCount = 0;
   indexMatch.costSelector = 0;
@@ -198,11 +200,13 @@
   if (indexMatch.matchCount == 0)
     return;                     /* no matching peers found! */
   if (indexMatch.costSelector > 0)
-    indexMatch.costSelector = weak_randomi (indexMatch.costSelector / 4) * 4;
+    indexMatch.costSelector =
+      GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+                         indexMatch.costSelector / 4) * 4;
   indexMatch.match = *(coreAPI->myIdentity);
   identity->forEachHost (now, &scanHelperSelect, &indexMatch);
   if (0 == memcmp (coreAPI->myIdentity,
-                   &indexMatch.match, sizeof (PeerIdentity)))
+                   &indexMatch.match, sizeof (GNUNET_PeerIdentity)))
     {
       GE_BREAK (ectx, 0);       /* should not happen, at least not often... */
       return;
@@ -215,77 +219,79 @@
 #if DEBUG_TOPOLOGY
   IF_GELOG (ectx,
             GE_DEBUG | GE_REQUEST | GE_USER,
-            hash2enc (&indexMatch.match.hashPubKey, &enc));
+            GNUNET_hash_to_enc (&indexMatch.match.hashPubKey, &enc));
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Topology: trying to connect to `%s'.\n", &enc);
 #endif
-  if (NO == identity->isBlacklisted (&indexMatch.match, YES))
+  if (GNUNET_NO == identity->isBlacklisted (&indexMatch.match, GNUNET_YES))
     {
       coreAPI->unicast (&indexMatch.match, NULL, 0, 0);
       identity->blacklistHost (&indexMatch.match, (unsigned int) 5 * 60 * 60 * 
saturation,      /* 5h at full saturation */
-                               NO);
+                               GNUNET_NO);
     }
 }
 
 /**
- * We received a sign of life from this host.
+ * We received a GNUNET_RSA_sign of life from this host.
  *
- * @param hostId the peer that gave a sign of live
+ * @param hostId the peer that gave a GNUNET_RSA_sign of live
  */
 static void
 notifyPONG (void *cls)
 {
-  PeerIdentity *hostId = cls;
+  GNUNET_PeerIdentity *hostId = cls;
 #if DEBUG_TOPOLOGY
-  EncName enc;
+  GNUNET_EncName enc;
 
-  hash2enc (&hostId->hashPubKey, &enc);
+  GNUNET_hash_to_enc (&hostId->hashPubKey, &enc);
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "Received pong from `%s', telling core that peer is still alive.\n",
           (char *) &enc);
 #endif
   coreAPI->confirmSessionUp (hostId);
-  FREE (hostId);
+  GNUNET_free (hostId);
 }
 
 /**
  * Check the liveness of the ping and possibly ping it.
  */
 static void
-checkNeedForPing (const PeerIdentity * peer, void *unused)
+checkNeedForPing (const GNUNET_PeerIdentity * peer, void *unused)
 {
-  cron_t now;
-  cron_t act;
+  GNUNET_CronTime now;
+  GNUNET_CronTime act;
 #if DEBUG_TOPOLOGY
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
-  if (weak_randomi (LIVE_PING_EFFECTIVENESS) != 0)
+  if (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, LIVE_PING_EFFECTIVENESS)
+      != 0)
     return;
-  now = get_time ();
-  if (SYSERR == coreAPI->getLastActivityOf (peer, &act))
+  now = GNUNET_get_time ();
+  if (GNUNET_SYSERR == coreAPI->getLastActivityOf (peer, &act))
     {
       GE_BREAK (ectx, 0);
       return;                   /* this should not happen... */
     }
 
-  if (now - act > SECONDS_PINGATTEMPT * cronSECONDS)
+  if (now - act > SECONDS_PINGATTEMPT * GNUNET_CRON_SECONDS)
     {
       /* if we have less than 75% of the number of connections
          that we would like to have, try ping-ing the other side
          to keep the connection open instead of hanging up */
-      PeerIdentity *hi = MALLOC (sizeof (PeerIdentity));
+      GNUNET_PeerIdentity *hi = GNUNET_malloc (sizeof (GNUNET_PeerIdentity));
       *hi = *peer;
 #if DEBUG_TOPOLOGY
-      hash2enc (&hi->hashPubKey, &enc);
+      GNUNET_hash_to_enc (&hi->hashPubKey, &enc);
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
               "Sending ping to `%s' to prevent connection timeout.\n",
               (char *) &enc);
 #endif
-      if (OK != pingpong->ping (peer, &notifyPONG, hi, NO, rand ()))
-        FREE (hi);
+      if (GNUNET_OK !=
+          pingpong->ping (peer, &notifyPONG, hi, GNUNET_NO, rand ()))
+        GNUNET_free (hi);
     }
 }
 
@@ -304,13 +310,15 @@
 
   autoconnect = GC_get_configuration_value_yesno (coreAPI->cfg,
                                                   "GNUNETD",
-                                                  "DISABLE-AUTOCONNECT", NO);
+                                                  "DISABLE-AUTOCONNECT",
+                                                  GNUNET_NO);
   slotCount = coreAPI->getSlotCount ();
-  if ((NO == autoconnect) && (saturation < 1))
+  if ((GNUNET_NO == autoconnect) && (saturation < 1))
     {
       for (i = slotCount - 1; i >= 0; i--)
         {
-          if (weak_randomi (LIVE_SCAN_EFFECTIVENESS) != 0)
+          if (GNUNET_random_u32
+              (GNUNET_RANDOM_QUALITY_WEAK, LIVE_SCAN_EFFECTIVENESS) != 0)
             continue;
           if (0 == coreAPI->isSlotUsed (i))
             scanForHosts (i);
@@ -345,44 +353,44 @@
   char *data;
   unsigned long long size;
   size_t pos;
-  EncName enc;
-  HashCode512 hc;
+  GNUNET_EncName enc;
+  GNUNET_HashCode hc;
 
   if (0 != strcmp (section, "F2F"))
     return 0;
-  GROW (friends, friendCount, 0);
+  GNUNET_array_grow (friends, friendCount, 0);
   fn = NULL;
   GC_get_configuration_value_filename (cfg,
                                        "F2F",
                                        "FRIENDS",
                                        VAR_DAEMON_DIRECTORY "/friends", &fn);
-  if ((0 == disk_file_test (ectx, fn)) ||
-      (OK != disk_file_size (ectx, fn, &size, YES)))
+  if ((0 == GNUNET_disk_file_test (ectx, fn)) ||
+      (GNUNET_OK != GNUNET_disk_file_size (ectx, fn, &size, GNUNET_YES)))
     {
       GE_LOG (ectx,
               GE_USER | GE_ADMIN | GE_ERROR | GE_IMMEDIATE,
               "Could not read friends list `%s'\n", fn);
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
-  data = MALLOC (size);
-  if (size != disk_file_read (ectx, fn, size, data))
+  data = GNUNET_malloc (size);
+  if (size != GNUNET_disk_file_read (ectx, fn, size, data))
     {
       GE_LOG (ectx,
               GE_ERROR | GE_BULK | GE_USER,
               _("Failed to read friends list from `%s'\n"), fn);
-      FREE (fn);
-      FREE (data);
-      return SYSERR;
+      GNUNET_free (fn);
+      GNUNET_free (data);
+      return GNUNET_SYSERR;
     }
-  FREE (fn);
+  GNUNET_free (fn);
   pos = 0;
   while ((pos < size) && isspace (data[pos]))
     pos++;
-  while (pos <= size - sizeof (EncName))
+  while (pos <= size - sizeof (GNUNET_EncName))
     {
-      memcpy (&enc, &data[pos], sizeof (EncName));
-      if (!isspace (enc.encoding[sizeof (EncName) - 1]))
+      memcpy (&enc, &data[pos], sizeof (GNUNET_EncName));
+      if (!isspace (enc.encoding[sizeof (GNUNET_EncName) - 1]))
         {
           GE_LOG (ectx,
                   GE_WARNING | GE_BULK | GE_USER,
@@ -390,10 +398,10 @@
                   ("Syntax error in topology specification, skipping 
bytes.\n"));
           continue;
         }
-      enc.encoding[sizeof (EncName) - 1] = '\0';
-      if (OK == enc2hash ((char *) &enc, &hc))
+      enc.encoding[sizeof (GNUNET_EncName) - 1] = '\0';
+      if (GNUNET_OK == GNUNET_enc_to_hash ((char *) &enc, &hc))
         {
-          GROW (friends, friendCount, friendCount + 1);
+          GNUNET_array_grow (friends, friendCount, friendCount + 1);
           friends[friendCount - 1].hashPubKey = hc;
         }
       else
@@ -404,7 +412,7 @@
                   ("Syntax error in topology specification, skipping bytes 
`%s'.\n"),
                   &enc);
         }
-      pos = pos + sizeof (EncName);
+      pos = pos + sizeof (GNUNET_EncName);
       while ((pos < size) && isspace (data[pos]))
         pos++;
     }
@@ -455,9 +463,9 @@
       return NULL;
     }
 
-  cron_add_job (coreAPI->cron,
-                &cronCheckLiveness,
-                LIVE_SCAN_FREQUENCY, LIVE_SCAN_FREQUENCY, NULL);
+  GNUNET_cron_add_job (coreAPI->cron,
+                       &cronCheckLiveness,
+                       LIVE_SCAN_FREQUENCY, LIVE_SCAN_FREQUENCY, NULL);
   api.estimateNetworkSize = &estimateNetworkSize;
   api.getSaturation = &estimateSaturation;
   api.allowConnectionFrom = &allowConnection;
@@ -467,7 +475,8 @@
 int
 release_module_topology_f2f ()
 {
-  cron_del_job (coreAPI->cron, &cronCheckLiveness, LIVE_SCAN_FREQUENCY, NULL);
+  GNUNET_cron_del_job (coreAPI->cron, &cronCheckLiveness, LIVE_SCAN_FREQUENCY,
+                       NULL);
   GC_detach_change_listener (coreAPI->cfg, &rereadConfiguration, NULL);
   coreAPI->releaseService (identity);
   identity = NULL;
@@ -476,8 +485,8 @@
   coreAPI->releaseService (pingpong);
   pingpong = NULL;
   coreAPI = NULL;
-  GROW (friends, friendCount, 0);
-  return OK;
+  GNUNET_array_grow (friends, friendCount, 0);
+  return GNUNET_OK;
 }
 
 /**
@@ -509,7 +518,7 @@
                                                      "topology",
                                                      gettext_noop
                                                      ("maintains a 
friend-to-friend restricted topology")));
-  return OK;
+  return GNUNET_OK;
 }
 
 void

Modified: GNUnet/src/applications/tracekit/Makefile.am
===================================================================
--- GNUnet/src/applications/tracekit/Makefile.am        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/tracekit/Makefile.am        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -3,11 +3,7 @@
 plugindir = $(libdir)/GNUnet
 
 LDADD =  \
-  $(top_builddir)/src/util/libgnunetutil.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
-  $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
-  $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
-  $(top_builddir)/src/util/cron/libgnunetutil_cron.la 
+  $(top_builddir)/src/util/libgnunetutil.la 
 
 bin_PROGRAMS = \
   gnunet-tracekit

Modified: GNUnet/src/applications/tracekit/gnunet-tracekit.c
===================================================================
--- GNUnet/src/applications/tracekit/gnunet-tracekit.c  2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/tracekit/gnunet-tracekit.c  2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -26,12 +26,10 @@
 
 #include "platform.h"
 #include "gnunet_protocols.h"
-#include "gnunet_util_network_client.h"
-#include "gnunet_util_boot.h"
-#include "gnunet_util_crypto.h"
+#include "gnunet_util.h"
 #include "tracekit.h"
 
-static struct SEMAPHORE *doneSem;
+static struct GNUNET_Semaphore *doneSem;
 
 static char *cfgFilename;
 
@@ -42,27 +40,27 @@
 /**
  * All gnunet-tracekit command line options
  */
-static struct CommandLineOption gnunettracekitOptions[] = {
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
+static struct GNUNET_CommandLineOption gnunettracekitOptions[] = {
+       GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
   {'D', "depth", "DEPTH",
    gettext_noop ("probe network to the given DEPTH"), 1,
-   &gnunet_getopt_configure_set_option, "GNUNET-TRACEKIT:HOPS"},
+   &GNUNET_getopt_configure_set_option, "GNUNET-TRACEKIT:HOPS"},
   {'F', "format", "FORMAT",
    gettext_noop
    ("specify output format; 0 for human readable output, 1 for dot, 2 for 
vcg"),
    1,
-   &gnunet_getopt_configure_set_option, "GNUNET-TRACEKIT:FORMAT"},
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Start GNUnet transport benchmarking 
tool.")),        /* -h */
-  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+   &GNUNET_getopt_configure_set_option, "GNUNET-TRACEKIT:FORMAT"},
+   GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Start GNUnet transport 
benchmarking tool.")),        /* -h */
+  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'P', "priority", "PRIO",
    gettext_noop ("use PRIO for the priority of the trace request"), 1,
-   &gnunet_getopt_configure_set_option, "GNUNET-TRACEKIT:PRIORITY"},
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
+   &GNUNET_getopt_configure_set_option, "GNUNET-TRACEKIT:PRIORITY"},
+   GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
   {'W', "wait", "DELAY",
    gettext_noop ("wait DELAY seconds for replies"), 1,
-   &gnunet_getopt_configure_set_option, "GNUNET-TRACEKIT:WAIT"},
-  COMMAND_LINE_OPTION_END,
+   &GNUNET_getopt_configure_set_option, "GNUNET-TRACEKIT:WAIT"},
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 static unsigned int
@@ -77,19 +75,19 @@
 static void
 run_shutdown (void *unused)
 {
-  GNUNET_SHUTDOWN_INITIATE ();
+  GNUNET_shutdown_initiate ();
 }
 
 static void *
 receiveThread (void *cls)
 {
-  struct ClientServerConnection *sock = cls;
+  struct GNUNET_ClientServerConnection *sock = cls;
   CS_tracekit_reply_MESSAGE *buffer;
   unsigned long long format;
-  PeerIdentity *peersSeen;
+  GNUNET_PeerIdentity *peersSeen;
   unsigned int psCount;
   unsigned int psSize;
-  PeerIdentity *peersResponding;
+  GNUNET_PeerIdentity *peersResponding;
   unsigned int prCount;
   unsigned int prSize;
   int i;
@@ -98,11 +96,11 @@
 
   psCount = 0;
   psSize = 1;
-  peersSeen = MALLOC (psSize * sizeof (PeerIdentity));
+  peersSeen = GNUNET_malloc (psSize * sizeof (GNUNET_PeerIdentity));
   prCount = 0;
   prSize = 1;
-  peersResponding = MALLOC (prSize * sizeof (PeerIdentity));
-  buffer = MALLOC (MAX_BUFFER_SIZE);
+  peersResponding = GNUNET_malloc (prSize * sizeof (GNUNET_PeerIdentity));
+  buffer = GNUNET_malloc (GNUNET_MAX_BUFFER_SIZE);
   if (-1 ==
       GC_get_configuration_value_number (cfg,
                                          "GNUNET-TRACEKIT",
@@ -110,20 +108,22 @@
     {
       printf (_("Format specification invalid. "
                 "Use 0 for user-readable, 1 for dot, 2 for vcg.\n"));
-      SEMAPHORE_UP (doneSem);
-      FREE (peersResponding);
-      FREE (peersSeen);
-      FREE (buffer);
+      GNUNET_semaphore_up (doneSem);
+      GNUNET_free (peersResponding);
+      GNUNET_free (peersSeen);
+      GNUNET_free (buffer);
       return NULL;
     }
   if (format == 1)
     printf ("digraph G {\n");
   if (format == 2)
     printf ("graph: {\n");
-  while (OK == connection_read (sock, (MESSAGE_HEADER **) & buffer))
+  while (GNUNET_OK ==
+         GNUNET_client_connection_read (sock,
+                                        (GNUNET_MessageHeader **) & buffer))
     {
       int count;
-      EncName enc;
+      GNUNET_EncName enc;
 
       count =
         ntohs (buffer->header.size) - sizeof (CS_tracekit_reply_MESSAGE);
@@ -132,22 +132,25 @@
           GE_BREAK (ectx, 0);
           break;                /* faulty reply */
         }
-      hash2enc (&buffer->responderId.hashPubKey, &enc);
-      match = NO;
+      GNUNET_hash_to_enc (&buffer->responderId.hashPubKey, &enc);
+      match = GNUNET_NO;
       for (j = 0; j < prCount; j++)
-        if (equalsHashCode512 (&buffer->responderId.hashPubKey,
-                               &peersResponding[j].hashPubKey))
-          match = YES;
-      if (match == NO)
+        if (0 == memcmp (&buffer->responderId.hashPubKey,
+                         &peersResponding[j].hashPubKey,
+                         sizeof (GNUNET_HashCode)))
+          match = GNUNET_YES;
+      if (match == GNUNET_NO)
         {
           if (prCount == prSize)
-            GROW (peersResponding, prSize, prSize * 2);
+            GNUNET_array_grow (peersResponding, prSize, prSize * 2);
           memcpy (&peersResponding[prCount++],
-                  &buffer->responderId.hashPubKey, sizeof (PeerIdentity));
+                  &buffer->responderId.hashPubKey,
+                  sizeof (GNUNET_PeerIdentity));
         }
-      count = count / sizeof (PeerIdentity);
+      count = count / sizeof (GNUNET_PeerIdentity);
       if (ntohs (buffer->header.size) !=
-          sizeof (CS_tracekit_reply_MESSAGE) + count * sizeof (PeerIdentity))
+          sizeof (CS_tracekit_reply_MESSAGE) +
+          count * sizeof (GNUNET_PeerIdentity))
         {
           GE_BREAK (ectx, 0);
           break;
@@ -170,27 +173,30 @@
         }
       else
         {
-          EncName other;
+          GNUNET_EncName other;
 
           for (i = 0; i < count; i++)
             {
-              match = NO;
+              match = GNUNET_NO;
               for (j = 0; j < psCount; j++)
-                if (equalsHashCode512
-                    (&((CS_tracekit_reply_MESSAGE_GENERIC *) buffer)->
-                     peerList[i].hashPubKey, &peersSeen[j].hashPubKey))
-                  match = YES;
-              if (match == NO)
+                if (0 ==
+                    memcmp (&((CS_tracekit_reply_MESSAGE_GENERIC *) buffer)->
+                            peerList[i].hashPubKey, &peersSeen[j].hashPubKey,
+                            sizeof (GNUNET_HashCode)))
+                  match = GNUNET_YES;
+              if (match == GNUNET_NO)
                 {
                   if (psCount == psSize)
-                    GROW (peersSeen, psSize, psSize * 2);
+                    GNUNET_array_grow (peersSeen, psSize, psSize * 2);
                   memcpy (&peersSeen[psCount++],
                           &((CS_tracekit_reply_MESSAGE_GENERIC *) buffer)->
-                          peerList[i].hashPubKey, sizeof (PeerIdentity));
+                          peerList[i].hashPubKey,
+                          sizeof (GNUNET_PeerIdentity));
                 }
 
-              hash2enc (&((CS_tracekit_reply_MESSAGE_GENERIC *) buffer)->
-                        peerList[i].hashPubKey, &other);
+              GNUNET_hash_to_enc (&
+                                  ((CS_tracekit_reply_MESSAGE_GENERIC *)
+                                   buffer)->peerList[i].hashPubKey, &other);
               switch (format)
                 {
                 case 0:
@@ -214,22 +220,22 @@
             }
         }
     }
-  FREE (buffer);
+  GNUNET_free (buffer);
   for (i = 0; i < psCount; i++)
     {
-      EncName enc;
+      GNUNET_EncName enc;
 
-      match = NO;
+      match = GNUNET_NO;
       for (j = 0; j < prCount; j++)
-        if (equalsHashCode512 (&peersResponding[j].hashPubKey,
-                               &peersSeen[i].hashPubKey))
+        if (0 == memcmp (&peersResponding[j].hashPubKey,
+                         &peersSeen[i].hashPubKey, sizeof (GNUNET_HashCode)))
           {
-            match = YES;
+            match = GNUNET_YES;
             break;
           }
-      if (match == NO)
+      if (match == GNUNET_NO)
         {
-          hash2enc (&peersSeen[i].hashPubKey, &enc);
+          GNUNET_hash_to_enc (&peersSeen[i].hashPubKey, &enc);
           switch (format)
             {
             case 0:
@@ -253,7 +259,7 @@
           switch (format)
             {
             case 2:
-              hash2enc (&peersSeen[i].hashPubKey, &enc);
+              GNUNET_hash_to_enc (&peersSeen[i].hashPubKey, &enc);
               printf ("\tnode: { title: \"%s\" label: \"%.*s\" }\n",
                       (char *) &enc, 4, (char *) &enc);
               break;
@@ -277,9 +283,9 @@
     printf ("}\n");
   if (format == 2)
     printf ("}\n");
-  SEMAPHORE_UP (doneSem);
-  FREE (peersResponding);
-  FREE (peersSeen);
+  GNUNET_semaphore_up (doneSem);
+  GNUNET_free (peersResponding);
+  GNUNET_free (peersSeen);
   return NULL;
 }
 
@@ -291,13 +297,13 @@
 int
 main (int argc, char *const *argv)
 {
-  struct ClientServerConnection *sock;
-  struct PTHREAD *messageReceiveThread;
+  struct GNUNET_ClientServerConnection *sock;
+  struct GNUNET_ThreadHandle *messageReceiveThread;
   void *unused;
   CS_tracekit_probe_MESSAGE probe;
   int sleepTime;
   struct GE_Context *ectx;
-  struct CronManager *cron;
+  struct GNUNET_CronManager *cron;
   int res;
 
   res = GNUNET_init (argc,
@@ -309,7 +315,7 @@
       GNUNET_fini (ectx, cfg);
       return -1;
     }
-  sock = client_connection_create (ectx, cfg);
+  sock = GNUNET_client_connection_create (ectx, cfg);
   if (sock == NULL)
     {
       fprintf (stderr, _("Error establishing connection with gnunetd.\n"));
@@ -317,8 +323,9 @@
       return 1;
     }
 
-  doneSem = SEMAPHORE_CREATE (0);
-  messageReceiveThread = PTHREAD_CREATE (&receiveThread, sock, 128 * 1024);
+  doneSem = GNUNET_semaphore_create (0);
+  messageReceiveThread =
+    GNUNET_thread_create (&receiveThread, sock, 128 * 1024);
   if (messageReceiveThread == NULL)
     GE_DIE_STRERROR (ectx,
                      GE_FATAL | GE_IMMEDIATE | GE_ADMIN, "pthread_create");
@@ -329,7 +336,7 @@
     = htonl (getConfigurationInt ("GNUNET-TRACEKIT", "HOPS", 0xFFFFFFFF));
   probe.priority
     = htonl (getConfigurationInt ("GNUNET-TRACEKIT", "PRIORITY", 0xFFFFFFFF));
-  if (SYSERR == connection_write (sock, &probe.header))
+  if (GNUNET_SYSERR == GNUNET_client_connection_write (sock, &probe.header))
     {
       GE_LOG (ectx,
               GE_ERROR | GE_BULK | GE_USER,
@@ -337,19 +344,20 @@
       return -1;
     }
   cron = cron_create (ectx);
-  cron_start (cron);
+  GNUNET_cron_start (cron);
   sleepTime = getConfigurationInt ("GNUNET-TRACEKIT", "WAIT", 0xFFFFFFFF);
   if (sleepTime == 0)
     sleepTime = 5;
-  cron_add_job (cron, &run_shutdown, cronSECONDS * sleepTime, 0, NULL);
-  GNUNET_SHUTDOWN_WAITFOR ();
-  connection_close_forever (sock);
-  SEMAPHORE_DOWN (doneSem, YES);
-  SEMAPHORE_DESTROY (doneSem);
-  PTHREAD_JOIN (messageReceiveThread, &unused);
-  connection_destroy (sock);
-  cron_stop (cron);
-  cron_destroy (cron);
+  GNUNET_cron_add_job (cron, &run_shutdown, GNUNET_CRON_SECONDS * sleepTime,
+                       0, NULL);
+  GNUNET_shutdown_wait_for ();
+  GNUNET_client_connection_close_forever (sock);
+  GNUNET_semaphore_down (doneSem, GNUNET_YES);
+  GNUNET_semaphore_destroy (doneSem);
+  GNUNET_thread_join (messageReceiveThread, &unused);
+  GNUNET_client_connection_destroy (sock);
+  GNUNET_cron_stop (cron);
+  GNUNET_cron_destroy (cron);
   GNUNET_fini (ectx, cfg);
   return 0;
 }

Modified: GNUnet/src/applications/tracekit/tracekit.c
===================================================================
--- GNUnet/src/applications/tracekit/tracekit.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/tracekit/tracekit.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -31,7 +31,7 @@
 
 static CoreAPIForApplication *coreAPI;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 static unsigned int clientCount;
 
@@ -41,9 +41,9 @@
 
 typedef struct
 {
-  PeerIdentity initiator;
-  PeerIdentity replyTo;
-  TIME_T timestamp;
+  GNUNET_PeerIdentity initiator;
+  GNUNET_PeerIdentity replyTo;
+  GNUNET_Int32Time timestamp;
   unsigned int priority;
 } RTE;
 
@@ -52,49 +52,52 @@
 static RTE *routeTable[MAXROUTE];
 
 static int
-handlep2pReply (const PeerIdentity * sender, const MESSAGE_HEADER * message)
+handlep2pReply (const GNUNET_PeerIdentity * sender,
+                const GNUNET_MessageHeader * message)
 {
   unsigned int i;
   unsigned int hostCount;
   P2P_tracekit_reply_MESSAGE *reply;
-  EncName initiator;
-  EncName sen;
+  GNUNET_EncName initiator;
+  GNUNET_EncName sen;
 
-  hash2enc (&sender->hashPubKey, &sen);
+  GNUNET_hash_to_enc (&sender->hashPubKey, &sen);
   hostCount =
     (ntohs (message->size) -
-     sizeof (P2P_tracekit_reply_MESSAGE)) / sizeof (PeerIdentity);
+     sizeof (P2P_tracekit_reply_MESSAGE)) / sizeof (GNUNET_PeerIdentity);
   if (ntohs (message->size) !=
-      sizeof (P2P_tracekit_reply_MESSAGE) + hostCount * sizeof (PeerIdentity))
+      sizeof (P2P_tracekit_reply_MESSAGE) +
+      hostCount * sizeof (GNUNET_PeerIdentity))
     {
       GE_LOG (ectx,
               GE_WARNING | GE_BULK | GE_USER,
               _("Received invalid `%s' message from `%s'.\n"),
               "P2P_tracekit_probe_MESSAGE", &sen);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   reply = (P2P_tracekit_reply_MESSAGE *) message;
-  hash2enc (&reply->initiatorId.hashPubKey, &initiator);
+  GNUNET_hash_to_enc (&reply->initiatorId.hashPubKey, &initiator);
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "TRACEKIT: Sending reply back to initiator `%s'.\n", &initiator);
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < MAXROUTE; i++)
     {
       if (routeTable[i] == NULL)
         continue;
       if ((routeTable[i]->timestamp ==
-           (TIME_T) ntohl (reply->initiatorTimestamp))
+           (GNUNET_Int32Time) ntohl (reply->initiatorTimestamp))
           && (0 ==
               memcmp (&routeTable[i]->initiator.hashPubKey,
-                      &reply->initiatorId.hashPubKey, sizeof (HashCode512))))
+                      &reply->initiatorId.hashPubKey,
+                      sizeof (GNUNET_HashCode))))
         {
           GE_LOG (ectx,
                   GE_DEBUG | GE_REQUEST | GE_USER,
                   "TRACEKIT: found matching entry in routing table\n");
           if (0 == memcmp (&coreAPI->myIdentity->hashPubKey,
                            &routeTable[i]->replyTo.hashPubKey,
-                           sizeof (HashCode512)))
+                           sizeof (GNUNET_HashCode)))
             {
               unsigned int idx;
               CS_tracekit_reply_MESSAGE *csReply;
@@ -118,27 +121,28 @@
                 }
 
               csReply =
-                MALLOC (sizeof (CS_tracekit_reply_MESSAGE) +
-                        hostCount * sizeof (PeerIdentity));
+                GNUNET_malloc (sizeof (CS_tracekit_reply_MESSAGE) +
+                               hostCount * sizeof (GNUNET_PeerIdentity));
               /* build msg */
               csReply->header.size
                 =
                 htons (sizeof (CS_tracekit_reply_MESSAGE) +
-                       hostCount * sizeof (PeerIdentity));
+                       hostCount * sizeof (GNUNET_PeerIdentity));
               csReply->header.type = htons (CS_PROTO_tracekit_REPLY);
               csReply->responderId = reply->responderId;
               memcpy (&((CS_tracekit_reply_MESSAGE_GENERIC *) csReply)->
                       peerList[0],
                       &((P2P_tracekit_reply_MESSAGE_GENERIC *) reply)->
-                      peerList[0], hostCount * sizeof (PeerIdentity));
-              coreAPI->sendToClient (clients[idx], &csReply->header, YES);
-              FREE (csReply);
+                      peerList[0], hostCount * sizeof (GNUNET_PeerIdentity));
+              coreAPI->sendToClient (clients[idx], &csReply->header,
+                                     GNUNET_YES);
+              GNUNET_free (csReply);
             }
           else
             {
-              EncName hop;
+              GNUNET_EncName hop;
 
-              hash2enc (&routeTable[i]->replyTo.hashPubKey, &hop);
+              GNUNET_hash_to_enc (&routeTable[i]->replyTo.hashPubKey, &hop);
               GE_LOG (ectx,
                       GE_DEBUG | GE_REQUEST | GE_USER,
                       "TRACEKIT: forwarding to next hop `%s'\n", &hop);
@@ -147,25 +151,25 @@
             }
         }
     }
-  MUTEX_UNLOCK (lock);
-  return OK;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 
 typedef struct
 {
-  PeerIdentity *peers;
+  GNUNET_PeerIdentity *peers;
   unsigned int max;
   int pos;
 } Tracekit_Collect_Trace_Closure;
 
 static void
-getPeerCallback (const PeerIdentity * id, void *cls)
+getPeerCallback (const GNUNET_PeerIdentity * id, void *cls)
 {
   Tracekit_Collect_Trace_Closure *closure = cls;
   if (closure->pos == closure->max)
     {
-      GROW (closure->peers, closure->max, closure->max + 32);
+      GNUNET_array_grow (closure->peers, closure->max, closure->max + 32);
     }
   if (closure->pos < closure->max)
     {
@@ -175,15 +179,16 @@
 }
 
 static void
-transmit (const PeerIdentity * id, void *cls)
+transmit (const GNUNET_PeerIdentity * id, void *cls)
 {
   P2P_tracekit_probe_MESSAGE *pro = cls;
-  if (0 != memcmp (id, &pro->initiatorId, sizeof (PeerIdentity)))
+  if (0 != memcmp (id, &pro->initiatorId, sizeof (GNUNET_PeerIdentity)))
     coreAPI->unicast (id, &pro->header, ntohl (pro->priority), 0);
 }
 
 static int
-handlep2pProbe (const PeerIdentity * sender, const MESSAGE_HEADER * message)
+handlep2pProbe (const GNUNET_PeerIdentity * sender,
+                const GNUNET_MessageHeader * message)
 {
   P2P_tracekit_reply_MESSAGE *reply;
   P2P_tracekit_probe_MESSAGE *msg;
@@ -191,51 +196,53 @@
   int i;
   int sel;
   int hops;
-  TIME_T oldest;
+  GNUNET_Int32Time oldest;
   int count;
   unsigned int size;
-  EncName init;
-  EncName sen;
-  TIME_T now;
+  GNUNET_EncName init;
+  GNUNET_EncName sen;
+  GNUNET_Int32Time now;
 
-  hash2enc (&sender->hashPubKey, &sen);
+  GNUNET_hash_to_enc (&sender->hashPubKey, &sen);
   if (ntohs (message->size) != sizeof (P2P_tracekit_probe_MESSAGE))
     {
       GE_LOG (ectx,
               GE_WARNING | GE_BULK | GE_USER,
               _("Received invalid `%s' message from `%s'.\n"),
               "P2P_tracekit_probe_MESSAGE", &sen);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER, "TRACEKIT: received probe\n");
-  TIME (&now);
+  GNUNET_get_time_int32 (&now);
   msg = (P2P_tracekit_probe_MESSAGE *) message;
-  if ((TIME_T) ntohl (msg->timestamp) > 3600 + now)
+  if ((GNUNET_Int32Time) ntohl (msg->timestamp) > 3600 + now)
     {
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
               "TRACEKIT: probe has timestamp in the far future (%d > %d), 
dropping\n",
               ntohl (msg->timestamp), 3600 + now);
-      return SYSERR;            /* Timestamp is more than 1h in the future. 
Invalid! */
+      return GNUNET_SYSERR;     /* Timestamp is more than 1h in the future. 
Invalid! */
     }
-  hash2enc (&msg->initiatorId.hashPubKey, &init);
-  MUTEX_LOCK (lock);
+  GNUNET_hash_to_enc (&msg->initiatorId.hashPubKey, &init);
+  GNUNET_mutex_lock (lock);
   /* test if already processed */
   for (i = 0; i < MAXROUTE; i++)
     {
       if (routeTable[i] == NULL)
         continue;
-      if ((routeTable[i]->timestamp == (TIME_T) ntohl (msg->timestamp)) &&
-          0 == memcmp (&routeTable[i]->initiator.hashPubKey,
-                       &msg->initiatorId.hashPubKey, sizeof (HashCode512)))
+      if ((routeTable[i]->timestamp ==
+           (GNUNET_Int32Time) ntohl (msg->timestamp))
+          && 0 == memcmp (&routeTable[i]->initiator.hashPubKey,
+                          &msg->initiatorId.hashPubKey,
+                          sizeof (GNUNET_HashCode)))
         {
           GE_LOG (ectx,
                   GE_DEBUG | GE_REQUEST | GE_USER,
                   "TRACEKIT-PROBE %d from `%s' received twice (slot %d), 
ignored\n",
                   ntohl (msg->timestamp), &init, i);
-          MUTEX_UNLOCK (lock);
-          return OK;
+          GNUNET_mutex_unlock (lock);
+          return GNUNET_OK;
         }
     }
   /* no, find and kill oldest entry */
@@ -257,25 +264,25 @@
       if (routeTable[i]->timestamp < now - 3600)
         {
           /* side-effect: drop very old entries */
-          FREE (routeTable[i]);
+          GNUNET_free (routeTable[i]);
           routeTable[i] = NULL;
         }
     }
   if (sel == -1)
     {
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       GE_LOG (ectx,
               GE_INFO | GE_REQUEST | GE_USER,
               _("TRACEKIT: routing table full, trace request dropped\n"));
-      return OK;
+      return GNUNET_OK;
     }
   if (routeTable[sel] == NULL)
-    routeTable[sel] = MALLOC (sizeof (RTE));
+    routeTable[sel] = GNUNET_malloc (sizeof (RTE));
   routeTable[sel]->timestamp = ntohl (msg->timestamp);
   routeTable[sel]->priority = ntohl (msg->priority);
   routeTable[sel]->initiator = msg->initiatorId;
   routeTable[sel]->replyTo = *sender;
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "TRACEKIT-PROBE started at %d by peer `%s' received, processing in 
slot %d with %u hops\n",
@@ -295,11 +302,12 @@
   while (closure.pos > 0)
     {
       count = closure.pos;
-      if (count > 60000 / sizeof (PeerIdentity))
-        count = 60000 / sizeof (PeerIdentity);
+      if (count > 60000 / sizeof (GNUNET_PeerIdentity))
+        count = 60000 / sizeof (GNUNET_PeerIdentity);
       size =
-        sizeof (P2P_tracekit_reply_MESSAGE) + count * sizeof (PeerIdentity);
-      reply = MALLOC (size);
+        sizeof (P2P_tracekit_reply_MESSAGE) +
+        count * sizeof (GNUNET_PeerIdentity);
+      reply = GNUNET_malloc (size);
       reply->header.size = htons (size);
       reply->header.type = htons (P2P_PROTO_tracekit_REPLY);
       reply->initiatorId = msg->initiatorId;
@@ -308,9 +316,9 @@
       reply->clientId = msg->clientId;
       memcpy (&reply[1],
               &closure.peers[closure.pos - count],
-              count * sizeof (PeerIdentity));
-      if (equalsHashCode512 (&coreAPI->myIdentity->hashPubKey,
-                             &sender->hashPubKey))
+              count * sizeof (GNUNET_PeerIdentity));
+      if (0 == memcmp (&coreAPI->myIdentity->hashPubKey,
+                       &sender->hashPubKey, sizeof (GNUNET_HashCode)))
         {
           handlep2pReply (coreAPI->myIdentity, &reply->header);
         }
@@ -319,14 +327,14 @@
           coreAPI->unicast (sender, &reply->header, ntohl (msg->priority), 0);
         }
       closure.pos -= count;
-      FREE (reply);
+      GNUNET_free (reply);
     }
-  GROW (closure.peers, closure.max, 0);
-  return OK;
+  GNUNET_array_grow (closure.peers, closure.max, 0);
+  return GNUNET_OK;
 }
 
 static int
-csHandle (struct ClientHandle *client, const MESSAGE_HEADER * message)
+csHandle (struct ClientHandle *client, const GNUNET_MessageHeader * message)
 {
   int i;
   int idx;
@@ -345,10 +353,10 @@
               GE_WARNING | GE_BULK | GE_USER,
               _("TRACEKIT: received invalid `%s' message\n"),
               "CS_tracekit_probe_MESSAGE");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   idx = -1;
   for (i = 0; i < clientCount; i++)
     {
@@ -365,11 +373,11 @@
     }
   if (idx == -1)
     {
-      GROW (clients, clientCount, clientCount + 1);
+      GNUNET_array_grow (clients, clientCount, clientCount + 1);
       idx = clientCount - 1;
     }
   clients[idx] = client;
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "TRACEKIT: client joins in slot %u.\n", idx);
@@ -378,11 +386,12 @@
   p2pProbe.header.type = htons (P2P_PROTO_tracekit_PROBE);
   p2pProbe.clientId = htonl (idx);
   p2pProbe.hopsToGo = csProbe->hops;
-  p2pProbe.timestamp = htonl (TIME (NULL));
+  p2pProbe.timestamp = htonl (GNUNET_get_time_int32 (NULL));
   p2pProbe.priority = csProbe->priority;
-  memcpy (&p2pProbe.initiatorId, coreAPI->myIdentity, sizeof (PeerIdentity));
+  memcpy (&p2pProbe.initiatorId, coreAPI->myIdentity,
+          sizeof (GNUNET_PeerIdentity));
   handlep2pProbe (coreAPI->myIdentity, &p2pProbe.header);       /* FIRST send 
to myself! */
-  return OK;
+  return GNUNET_OK;
 }
 
 static void
@@ -390,7 +399,7 @@
 {
   int i;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < clientCount; i++)
     if (clients[i] == c)
       {
@@ -405,17 +414,17 @@
     i--;
   i++;
   if (i != clientCount)
-    GROW (clients, clientCount, i);
-  MUTEX_UNLOCK (lock);
+    GNUNET_array_grow (clients, clientCount, i);
+  GNUNET_mutex_unlock (lock);
 }
 
 int
 initialize_module_tracekit (CoreAPIForApplication * capi)
 {
-  int ok = OK;
+  int ok = GNUNET_OK;
 
   ectx = capi->ectx;
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
   coreAPI = capi;
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
@@ -423,17 +432,17 @@
           P2P_PROTO_tracekit_PROBE,
           P2P_PROTO_tracekit_REPLY, CS_PROTO_tracekit_PROBE);
   memset (routeTable, 0, MAXROUTE * sizeof (RTE *));
-  if (SYSERR == capi->registerHandler (P2P_PROTO_tracekit_PROBE,
-                                       &handlep2pProbe))
-    ok = SYSERR;
-  if (SYSERR == capi->registerHandler (P2P_PROTO_tracekit_REPLY,
-                                       &handlep2pReply))
-    ok = SYSERR;
-  if (SYSERR == capi->registerClientExitHandler (&clientExitHandler))
-    ok = SYSERR;
-  if (SYSERR == capi->registerClientHandler (CS_PROTO_tracekit_PROBE,
-                                             (CSHandler) & csHandle))
-    ok = SYSERR;
+  if (GNUNET_SYSERR == capi->registerHandler (P2P_PROTO_tracekit_PROBE,
+                                              &handlep2pProbe))
+    ok = GNUNET_SYSERR;
+  if (GNUNET_SYSERR == capi->registerHandler (P2P_PROTO_tracekit_REPLY,
+                                              &handlep2pReply))
+    ok = GNUNET_SYSERR;
+  if (GNUNET_SYSERR == capi->registerClientExitHandler (&clientExitHandler))
+    ok = GNUNET_SYSERR;
+  if (GNUNET_SYSERR == capi->registerClientHandler (CS_PROTO_tracekit_PROBE,
+                                                    (CSHandler) & csHandle))
+    ok = GNUNET_SYSERR;
   GE_ASSERT (capi->ectx,
              0 == GC_set_configuration_value_string (capi->cfg,
                                                      capi->ectx,
@@ -455,11 +464,11 @@
   coreAPI->unregisterClientHandler (CS_PROTO_tracekit_PROBE, &csHandle);
   for (i = 0; i < MAXROUTE; i++)
     {
-      FREENONNULL (routeTable[i]);
+      GNUNET_free_non_null (routeTable[i]);
       routeTable[i] = NULL;
     }
-  GROW (clients, clientCount, 0);
-  MUTEX_DESTROY (lock);
+  GNUNET_array_grow (clients, clientCount, 0);
+  GNUNET_mutex_destroy (lock);
   lock = NULL;
   coreAPI = NULL;
 }

Modified: GNUnet/src/applications/tracekit/tracekit.h
===================================================================
--- GNUnet/src/applications/tracekit/tracekit.h 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/tracekit/tracekit.h 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -30,12 +30,12 @@
 
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * When was this probe started? (NBO)
    */
-  TIME_T timestamp;
+  GNUNET_Int32Time timestamp;
 
   /**
    * How many more hops should this probe go (NBO)
@@ -56,31 +56,31 @@
    * Which peer is the ultimate receiver of this
    * information?
    */
-  PeerIdentity initiatorId;
+  GNUNET_PeerIdentity initiatorId;
 
 } P2P_tracekit_probe_MESSAGE;
 
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * Which peer is the ultimate receiver of this
    * information?
    */
-  PeerIdentity initiatorId;
+  GNUNET_PeerIdentity initiatorId;
 
   /**
    * Which peer is the ultimate responder responsible
    * for sending this reply?
    */
-  PeerIdentity responderId;
+  GNUNET_PeerIdentity responderId;
 
   /**
    * At what time was the initator sending the
    * request?
    */
-  TIME_T initiatorTimestamp;
+  GNUNET_Int32Time initiatorTimestamp;
 
   /**
    * Internal client Id of the sender.
@@ -97,13 +97,13 @@
    * List of peers that the responder is
    * currently connected to.
    */
-  PeerIdentity peerList[1];
+  GNUNET_PeerIdentity peerList[1];
 } P2P_tracekit_reply_MESSAGE_GENERIC;
 
 
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * How many more hops should this probe go (NBO)
@@ -118,13 +118,13 @@
 
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * Which peer is the ultimate responder responsible
    * for sending this reply?
    */
-  PeerIdentity responderId;
+  GNUNET_PeerIdentity responderId;
 
 } CS_tracekit_reply_MESSAGE;
 
@@ -136,7 +136,7 @@
    * List of peers that the responder is
    * currently connected to.
    */
-  PeerIdentity peerList[1];
+  GNUNET_PeerIdentity peerList[1];
 } CS_tracekit_reply_MESSAGE_GENERIC;
 
 #endif

Modified: GNUnet/src/applications/traffic/Makefile.am
===================================================================
--- GNUnet/src/applications/traffic/Makefile.am 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/traffic/Makefile.am 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -12,8 +12,7 @@
 libgnunettraffic_api_la_SOURCES = \
   clientapi.c 
 libgnunettraffic_api_la_LIBADD = \
-  $(top_builddir)/src/util/libgnunetutil.la \
-  $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la
+  $(top_builddir)/src/util/libgnunetutil.la 
 
 
 libgnunetmodule_traffic_la_SOURCES = \

Modified: GNUnet/src/applications/traffic/clientapi.c
===================================================================
--- GNUnet/src/applications/traffic/clientapi.c 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/traffic/clientapi.c 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -41,10 +41,10 @@
  * @param count set to number of messages
  * @param avg_size set to average size
  * @param peers set to number of peers involved
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-gnunet_traffic_poll (struct ClientServerConnection *sock,
+GNUNET_traffic_poll (struct GNUNET_ClientServerConnection *sock,
                      unsigned int timeframe,
                      unsigned short type,
                      unsigned short direction,
@@ -59,11 +59,12 @@
   req.header.size = htons (sizeof (CS_traffic_request_MESSAGE));
   req.header.type = htons (CS_PROTO_traffic_QUERY);
   req.timePeriod = htonl (timeframe);
-  if (SYSERR == connection_write (sock, &req.header))
-    return SYSERR;
+  if (GNUNET_SYSERR == GNUNET_client_connection_write (sock, &req.header))
+    return GNUNET_SYSERR;
   info = NULL;
-  if (SYSERR == connection_read (sock, (MESSAGE_HEADER **) & info))
-    return SYSERR;
+  if (GNUNET_SYSERR ==
+      GNUNET_client_connection_read (sock, (GNUNET_MessageHeader **) & info))
+    return GNUNET_SYSERR;
   if ((ntohs (info->header.type) !=
        CS_PROTO_traffic_INFO) ||
       (ntohs (info->header.size) !=
@@ -71,7 +72,7 @@
        ntohl (info->count) * sizeof (TRAFFIC_COUNTER)))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
   for (i = ntohl (info->count) - 1; i >= 0; i--)
@@ -86,8 +87,8 @@
           *time = ntohl (tc->time_slots);
         }                       /* end if received */
     }                           /* end for all counters */
-  FREE (info);
-  return OK;
+  GNUNET_free (info);
+  return GNUNET_OK;
 }
 
 /* end of clientapi.c */

Modified: GNUnet/src/applications/traffic/traffic.c
===================================================================
--- GNUnet/src/applications/traffic/traffic.c   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/traffic/traffic.c   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -101,7 +101,7 @@
   /**
    * When was this record last updated?
    */
-  cron_t lastUpdate;
+  GNUNET_CronTime lastUpdate;
 
   /**
    * Time slots for processing (shifted bitvector)
@@ -147,7 +147,7 @@
 /**
  * Lock to synchronize access.
  */
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 /**
  * Highest message type seen so far.
@@ -174,8 +174,8 @@
 updateUse (DirectedTrafficCounter * dtc,
            unsigned short size, int peerId, int expireOnly)
 {
-  cron_t now;
-  cron_t delta;
+  GNUNET_CronTime now;
+  GNUNET_CronTime delta;
   unsigned int unitNow;
   unsigned int deltaUnits;
   unsigned int minPeerId;
@@ -183,13 +183,13 @@
   unsigned int i;
   unsigned int slot;
 
-  now = get_time ();
+  now = GNUNET_get_time ();
   unitNow = now / TRAFFIC_TIME_UNIT;
   delta = now - dtc->lastUpdate;
   dtc->lastUpdate = now;
   deltaUnits = delta / TRAFFIC_TIME_UNIT;
 
-  if (NO == expireOnly)
+  if (GNUNET_NO == expireOnly)
     {
       /* update peer identities */
       minPeerTime = 0;
@@ -218,7 +218,7 @@
       dtc->avgSize[HS_SLOT (unitNow - HISTORY_SIZE - i)] = 0.0;
     }
 
-  if (NO == expireOnly)
+  if (GNUNET_NO == expireOnly)
     {
       int devideBy;
 
@@ -255,13 +255,13 @@
 {
   unsigned int i;
   unsigned short peerCount;
-  cron_t now;
+  GNUNET_CronTime now;
   unsigned int unitNow;
   unsigned int msgCount;
   unsigned long long totalMsgSize;
 
-  updateUse (dtc, 0, 0, YES);   /* expire old entries */
-  now = get_time ();
+  updateUse (dtc, 0, 0, GNUNET_YES);    /* expire old entries */
+  now = GNUNET_get_time ();
   unitNow = now / TRAFFIC_TIME_UNIT;
 
   /* count number of peers that we interacted with in
@@ -301,7 +301,7 @@
   unsigned int count;
   unsigned int i;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   count = 0;
   for (i = 0; i < max_message_type; i++)
     if (counters[i] != NULL)
@@ -311,8 +311,8 @@
         if (counters[i]->receive.slots != 0)
           count++;
       }
-  reply = MALLOC (sizeof (CS_traffic_info_MESSAGE) +
-                  count * sizeof (TRAFFIC_COUNTER));
+  reply = GNUNET_malloc (sizeof (CS_traffic_info_MESSAGE) +
+                         count * sizeof (TRAFFIC_COUNTER));
   reply->header.type = htons (CS_PROTO_traffic_INFO);
   reply->header.size = htons (sizeof (CS_traffic_info_MESSAGE) +
                               count * sizeof (TRAFFIC_COUNTER));
@@ -331,24 +331,24 @@
                         countTimeUnits, i);
       }
 
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return reply;
 }
 
 static int
 trafficQueryHandler (struct ClientHandle *sock,
-                     const MESSAGE_HEADER * message)
+                     const GNUNET_MessageHeader * message)
 {
   const CS_traffic_request_MESSAGE *msg;
   CS_traffic_info_MESSAGE *reply;
   int ret;
 
   if (sizeof (CS_traffic_request_MESSAGE) != ntohs (message->size))
-    return SYSERR;
+    return GNUNET_SYSERR;
   msg = (const CS_traffic_request_MESSAGE *) message;
   reply = buildReply (ntohl (msg->timePeriod));
-  ret = coreAPI->sendToClient (sock, &reply->header, YES);
-  FREE (reply);
+  ret = coreAPI->sendToClient (sock, &reply->header, GNUNET_YES);
+  GNUNET_free (reply);
   return ret;
 }
 
@@ -366,7 +366,7 @@
  * @param peerCount number of peers engaged (set)
  * @param timeDistribution bit-vector giving times of interactions,
  *        highest bit is current time-unit, bit 1 is 32 time-units ago (set)
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
 getTrafficStats (unsigned int timePeriod,
@@ -383,24 +383,24 @@
 
   if (timePeriod > HISTORY_SIZE)
     timePeriod = HISTORY_SIZE;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   if ((messageType >= max_message_type) || (counters[messageType] == NULL))
     {
       *avgMessageSize = 0;
       *messageCount = 0;
       *peerCount = 0;
       *timeDistribution = 0;
-      MUTEX_UNLOCK (lock);
-      return OK;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_OK;
     }
 
   if (sendReceive == TC_SENT)
     dtc = &counters[messageType]->send;
   else
     dtc = &counters[messageType]->receive;
-  updateUse (dtc, 0, 0, YES);
+  updateUse (dtc, 0, 0, GNUNET_YES);
 
-  nowUnit = get_time () / TRAFFIC_TIME_UNIT;
+  nowUnit = GNUNET_get_time () / TRAFFIC_TIME_UNIT;
   *peerCount = 0;
   *messageCount = 0;
   totSize = 0;
@@ -420,8 +420,8 @@
   else
     *avgMessageSize = 0;
   *timeDistribution = dtc->slots;
-  MUTEX_UNLOCK (lock);
-  return OK;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 
@@ -434,10 +434,10 @@
 checkPort (unsigned short port)
 {
   if (port >= max_message_type)
-    GROW (counters, max_message_type, port + 1);
+    GNUNET_array_grow (counters, max_message_type, port + 1);
   if (counters[port] == NULL)
     {
-      counters[port] = MALLOC (sizeof (TrafficCounter));
+      counters[port] = GNUNET_malloc (sizeof (TrafficCounter));
       memset (counters[port], 0, sizeof (TrafficCounter));
     }
 }
@@ -450,10 +450,10 @@
   if (0 == stat_traffic_transmitted_by_type[ptyp])
     {
       char *s;
-      s = MALLOC (256);
-      SNPRINTF (s, 256, _("# bytes transmitted of type %d"), ptyp);
+      s = GNUNET_malloc (256);
+      GNUNET_snprintf (s, 256, _("# bytes transmitted of type %d"), ptyp);
       stat_traffic_transmitted_by_type[ptyp] = stats->create (s);
-      FREE (s);
+      GNUNET_free (s);
     }
   stats->change (stat_traffic_transmitted_by_type[ptyp], plen);
 }
@@ -466,10 +466,10 @@
       if (0 == stat_traffic_received_by_type[ptyp])
         {
           char *s;
-          s = MALLOC (256);
-          SNPRINTF (s, 256, _("# bytes received of type %d"), ptyp);
+          s = GNUNET_malloc (256);
+          GNUNET_snprintf (s, 256, _("# bytes received of type %d"), ptyp);
           stat_traffic_received_by_type[ptyp] = stats->create (s);
-          FREE (s);
+          GNUNET_free (s);
         }
       stats->change (stat_traffic_received_by_type[ptyp], plen);
     }
@@ -484,11 +484,12 @@
       if (0 == stat_pt_traffic_received_by_type[ptyp])
         {
           char *s;
-          s = MALLOC (256);
-          SNPRINTF (s,
-                    256, _("# bytes received in plaintext of type %d"), ptyp);
+          s = GNUNET_malloc (256);
+          GNUNET_snprintf (s,
+                           256, _("# bytes received in plaintext of type %d"),
+                           ptyp);
           stat_pt_traffic_received_by_type[ptyp] = stats->create (s);
-          FREE (s);
+          GNUNET_free (s);
         }
       stats->change (stat_pt_traffic_received_by_type[ptyp], plen);
     }
@@ -501,18 +502,19 @@
  * @param sender the identity of the sender
  */
 static int
-trafficReceive (const PeerIdentity * sender, const MESSAGE_HEADER * header)
+trafficReceive (const GNUNET_PeerIdentity * sender,
+                const GNUNET_MessageHeader * header)
 {
   unsigned short port;
 
   port = ntohs (header->type);
   updateTrafficReceiveCounter (port, ntohs (header->size));
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   checkPort (port);
   updateUse (&counters[port]->receive,
-             ntohs (header->size), sender->hashPubKey.bits[0], NO);
-  MUTEX_UNLOCK (lock);
-  return OK;
+             ntohs (header->size), sender->hashPubKey.bits[0], GNUNET_NO);
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 
@@ -523,19 +525,20 @@
  * @param receiver the identity of the receiver
  */
 static int
-trafficSend (const PeerIdentity * receiver, const MESSAGE_HEADER * header)
+trafficSend (const GNUNET_PeerIdentity * receiver,
+             const GNUNET_MessageHeader * header)
 {
   unsigned short port;
 
   port = ntohs (MAKE_UNALIGNED (header->type));
   updateTrafficSendCounter (port, ntohs (MAKE_UNALIGNED (header->size)));
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   checkPort (port);
   updateUse (&counters[port]->send,
              ntohs (MAKE_UNALIGNED (header->size)),
-             receiver->hashPubKey.bits[0], NO);
-  MUTEX_UNLOCK (lock);
-  return OK;
+             receiver->hashPubKey.bits[0], GNUNET_NO);
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 /**
@@ -545,8 +548,8 @@
  * @param receiver the identity of the receiver
  */
 static int
-plaintextReceive (const PeerIdentity * receiver,
-                  const MESSAGE_HEADER * header, TSession * session)
+plaintextReceive (const GNUNET_PeerIdentity * receiver,
+                  const GNUNET_MessageHeader * header, TSession * session)
 {
   unsigned short port;
 
@@ -554,7 +557,7 @@
   updatePlaintextTrafficReceiveCounter (port,
                                         ntohs (MAKE_UNALIGNED
                                                (header->size)));
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -585,7 +588,7 @@
     }
 
   GE_ASSERT (coreAPI->ectx, counters == NULL);
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
   stats = capi->requestService ("stats");
   return &api;
 }
@@ -607,9 +610,9 @@
   coreAPI->releaseService (stats);
   stats = NULL;
   for (i = 0; i < max_message_type; i++)
-    FREENONNULL (counters[i]);
-  GROW (counters, max_message_type, 0);
-  MUTEX_DESTROY (lock);
+    GNUNET_free_non_null (counters[i]);
+  GNUNET_array_grow (counters, max_message_type, 0);
+  GNUNET_mutex_destroy (lock);
   lock = NULL;
   coreAPI = NULL;
 }
@@ -632,7 +635,7 @@
     {
       GE_BREAK (capi->ectx, 0);
       myCoreAPI = NULL;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   capi->registerClientHandler (CS_PROTO_traffic_QUERY, &trafficQueryHandler);
   GE_ASSERT (capi->ectx,
@@ -642,7 +645,7 @@
                                                      "traffic",
                                                      gettext_noop
                                                      ("tracks bandwidth 
utilization by gnunetd")));
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -653,7 +656,7 @@
 {
   GE_ASSERT (NULL, myCoreAPI != NULL);
   GE_ASSERT (myCoreAPI->ectx,
-             SYSERR !=
+             GNUNET_SYSERR !=
              myCoreAPI->unregisterClientHandler (CS_PROTO_traffic_QUERY,
                                                  &trafficQueryHandler));
   myCoreAPI->releaseService (myApi);

Modified: GNUnet/src/applications/traffic/traffic.h
===================================================================
--- GNUnet/src/applications/traffic/traffic.h   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/traffic/traffic.h   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -72,7 +72,7 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * The number of different message types we have seen
@@ -102,7 +102,7 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * How many time units back should the statistics returned contain?

Modified: GNUnet/src/applications/transport/Makefile.am
===================================================================
--- GNUnet/src/applications/transport/Makefile.am       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/transport/Makefile.am       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -9,9 +9,7 @@
 libgnunetmodule_transport_la_SOURCES = \
   transport.c 
 libgnunetmodule_transport_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_transport_la_LDFLAGS = \
   -export-dynamic -avoid-version -module
 

Modified: GNUnet/src/applications/transport/check.c
===================================================================
--- GNUnet/src/applications/transport/check.c   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/transport/check.c   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -10,7 +10,7 @@
   /**
    * the tcp socket (used to identify this connection with selector)
    */
-  struct SocketHandle *sock;
+  struct GNUNET_SocketHandle *sock;
 
   /**
    * Our tsession.
@@ -20,16 +20,16 @@
   /**
    * mutex for synchronized access to 'users'
    */
-  struct MUTEX *lock;
+  struct GNUNET_Mutex *lock;
 
   /**
    * To whom are we talking to (set to our identity
    * if we are still waiting for the welcome message)
    */
-  PeerIdentity sender;
+  GNUNET_PeerIdentity sender;
 
   /**
-   * Are we still expecting the welcome? (YES/NO)
+   * Are we still expecting the welcome? (GNUNET_YES/GNUNET_NO)
    */
   int expectingWelcome;
 

Modified: GNUnet/src/applications/transport/transport.c
===================================================================
--- GNUnet/src/applications/transport/transport.c       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/applications/transport/transport.c       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -32,7 +32,7 @@
 #include "gnunet_transport_service.h"
 
 
-#define DEBUG_TRANSPORT NO
+#define DEBUG_TRANSPORT GNUNET_NO
 
 static CoreAPIForTransport ctapi;
 
@@ -51,15 +51,15 @@
 
 static unsigned long long hello_live;
 
-static struct MUTEX *tapis_lock;
+static struct GNUNET_Mutex *tapis_lock;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 static struct GE_Context *ectx;
 
-#define HELLO_RECREATE_FREQ (5 * cronMINUTES)
+#define HELLO_RECREATE_FREQ (5 * GNUNET_CRON_MINUTES)
 
-#define CHECK_IT NO
+#define CHECK_IT GNUNET_NO
 #if CHECK_IT
 #include "check.c"
 #else
@@ -69,7 +69,7 @@
 
 /**
  * Close the session with the remote node.
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
 assertAssociated (TSession * tsession, const char *token)
@@ -79,9 +79,9 @@
   if (tsession == NULL)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < tsession->token_count; i++)
     {
       if (0 == strcmp (tsession->tokens[i], token))
@@ -93,11 +93,11 @@
   if (i != -1)
     {
       GE_BREAK (NULL, 0);
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
-  MUTEX_UNLOCK (lock);
-  return OK;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 /**
@@ -108,47 +108,49 @@
 createSignedhello (void *cls)
 {
   TransportAPI *tapi = cls;
-  MUTEX_LOCK (tapis_lock);
-  FREENONNULL (tapi->hello);
+  GNUNET_mutex_lock (tapis_lock);
+  GNUNET_free_non_null (tapi->hello);
   tapi->hello = tapi->createhello ();
   if (NULL == tapi->hello)
     {
-      MUTEX_UNLOCK (tapis_lock);
+      GNUNET_mutex_unlock (tapis_lock);
       return;
     }
   memcpy (&tapi->hello->publicKey,
-          identity->getPublicPrivateKey (), sizeof (PublicKey));
+          identity->getPublicPrivateKey (), sizeof (GNUNET_RSA_PublicKey));
   memcpy (&tapi->hello->senderIdentity,
-          coreAPI->myIdentity, sizeof (PeerIdentity));
-  tapi->hello->expirationTime = htonl (TIME (NULL) + hello_live);
+          coreAPI->myIdentity, sizeof (GNUNET_PeerIdentity));
+  tapi->hello->expirationTime =
+    htonl (GNUNET_get_time_int32 (NULL) + hello_live);
   tapi->hello->header.type = htons (p2p_PROTO_hello);
-  tapi->hello->header.size = htons (P2P_hello_MESSAGE_size (tapi->hello));
-  if (SYSERR == identity->signData (&(tapi->hello)->senderIdentity,
-                                    P2P_hello_MESSAGE_size (tapi->hello)
-                                    - sizeof (Signature)
-                                    - sizeof (PublicKey)
-                                    - sizeof (MESSAGE_HEADER),
-                                    &tapi->hello->signature))
+  tapi->hello->header.size = htons (GNUNET_sizeof_hello (tapi->hello));
+  if (GNUNET_SYSERR == identity->signData (&(tapi->hello)->senderIdentity,
+                                           GNUNET_sizeof_hello (tapi->
+                                                                hello) -
+                                           sizeof (GNUNET_RSA_Signature) -
+                                           sizeof (GNUNET_RSA_PublicKey) -
+                                           sizeof (GNUNET_MessageHeader),
+                                           &tapi->hello->signature))
     {
-      FREE (tapi->hello);
+      GNUNET_free (tapi->hello);
       tapi->hello = NULL;
       GE_BREAK (ectx, 0);
     }
-  MUTEX_UNLOCK (tapis_lock);
+  GNUNET_mutex_unlock (tapis_lock);
 }
 
 /**
  * Is this transport mechanism available (for sending)?
- * @return YES or NO
+ * @return GNUNET_YES or GNUNET_NO
  */
 static int
 isTransportAvailable (unsigned short ttype)
 {
   if (ttype >= tapis_count)
-    return NO;
+    return GNUNET_NO;
   if (NULL == tapis[ttype])
-    return NO;
-  return YES;
+    return GNUNET_NO;
+  return GNUNET_YES;
 }
 
 /**
@@ -158,25 +160,25 @@
 addTransport (TransportAPI * tapi)
 {
   if (tapi->protocolNumber >= tapis_count)
-    GROW (tapis, tapis_count, tapi->protocolNumber + 1);
+    GNUNET_array_grow (tapis, tapis_count, tapi->protocolNumber + 1);
   if (tapis[tapi->protocolNumber] != NULL)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   tapis[tapi->protocolNumber] = tapi;
   tapi->hello = NULL;
-  cron_add_job (coreAPI->cron,
-                &createSignedhello,
-                HELLO_RECREATE_FREQ, HELLO_RECREATE_FREQ, tapi);
-  return OK;
+  GNUNET_cron_add_job (coreAPI->cron,
+                       &createSignedhello,
+                       HELLO_RECREATE_FREQ, HELLO_RECREATE_FREQ, tapi);
+  return GNUNET_OK;
 }
 
 /**
  * Convert hello to string.
  */
 static int
-helloToAddress (const P2P_hello_MESSAGE * hello,
+helloToAddress (const GNUNET_MessageHello * hello,
                 void **sa, unsigned int *sa_len)
 {
   unsigned short prot;
@@ -189,7 +191,7 @@
               _
               ("Converting peer address to string failed, transport type %d 
not supported\n"),
               ntohs (hello->protocol));
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   return tapis[prot]->helloToAddress (hello, sa, sa_len);
 }
@@ -229,7 +231,7 @@
  * @return session on success, NULL on error
  */
 static TSession *
-transportConnect (const P2P_hello_MESSAGE * hello,
+transportConnect (const GNUNET_MessageHello * hello,
                   const char *token, int may_reuse)
 {
   unsigned short prot;
@@ -246,33 +248,33 @@
       return NULL;
     }
   tsession = NULL;
-  if (OK != tapis[prot]->connect (hello, &tsession, may_reuse))
+  if (GNUNET_OK != tapis[prot]->connect (hello, &tsession, may_reuse))
     return NULL;
   tsession->ttype = prot;
-  MUTEX_LOCK (lock);
-  APPEND (tsession->tokens, tsession->token_count, token);
+  GNUNET_mutex_lock (lock);
+  GNUNET_array_append (tsession->tokens, tsession->token_count, token);
   CHECK (tsession);
-  MUTEX_UNLOCK (lock);
-  GE_BREAK (NULL, OK == assertAssociated (tsession, token));
+  GNUNET_mutex_unlock (lock);
+  GE_BREAK (NULL, GNUNET_OK == assertAssociated (tsession, token));
   return tsession;
 }
 
 static TSession *
-transportConnectFreely (const PeerIdentity * peer, int useTempList,
+transportConnectFreely (const GNUNET_PeerIdentity * peer, int useTempList,
                         const char *token)
 {
   int i;
-  P2P_hello_MESSAGE *hello;
-  int *perm;
+  GNUNET_MessageHello *hello;
+  unsigned int *perm;
   TSession *ret;
   unsigned int hc;
 #if DEBUG_TRANSPORT
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   hc = 0;
   ret = NULL;
-  perm = permute (WEAK, tapis_count);
+  perm = GNUNET_permute (GNUNET_RANDOM_QUALITY_WEAK, tapis_count);
   for (i = 0; i < tapis_count; i++)
     {
       if (tapis[perm[i]] == NULL)
@@ -281,16 +283,16 @@
       if (hello == NULL)
         continue;
       hc++;
-      ret = transportConnect (hello, token, YES);
-      FREE (hello);
+      ret = transportConnect (hello, token, GNUNET_YES);
+      GNUNET_free (hello);
       if (ret != NULL)
         break;
     }
-  FREE (perm);
+  GNUNET_free (perm);
   if (ret == NULL)
     {
 #if DEBUG_TRANSPORT
-      hash2enc (&peer->hashPubKey, &enc);
+      GNUNET_hash_to_enc (&peer->hashPubKey, &enc);
       GE_LOG (ectx,
               GE_WARNING | GE_BULK | GE_ADMIN,
               _
@@ -309,8 +311,8 @@
  * @param tsession the session handle passed along
  *   from the call to receive that was made by the transport
  *   layer
- * @return OK if the session could be associated,
- *         SYSERR if not.
+ * @return GNUNET_OK if the session could be associated,
+ *         GNUNET_SYSERR if not.
  */
 static int
 transportAssociate (TSession * tsession, const char *token)
@@ -319,15 +321,15 @@
 
   if ((tsession == NULL) ||
       (tsession->ttype >= tapis_count) || (tapis[tsession->ttype] == NULL))
-    return SYSERR;
+    return GNUNET_SYSERR;
   ret = tapis[tsession->ttype]->associate (tsession);
-  MUTEX_LOCK (lock);
-  if (ret == OK)
-    APPEND (tsession->tokens, tsession->token_count, token);
+  GNUNET_mutex_lock (lock);
+  if (ret == GNUNET_OK)
+    GNUNET_array_append (tsession->tokens, tsession->token_count, token);
   CHECK (tsession);
-  MUTEX_UNLOCK (lock);
-  if (ret == OK)
-    GE_BREAK (NULL, OK == assertAssociated (tsession, token));
+  GNUNET_mutex_unlock (lock);
+  if (ret == GNUNET_OK)
+    GE_BREAK (NULL, GNUNET_OK == assertAssociated (tsession, token));
   return ret;
 }
 
@@ -338,7 +340,7 @@
 transportGetCost (int ttype)
 {
   if ((ttype >= tapis_count) || (tapis[ttype] == NULL))
-    return SYSERR;              /* -1 = INFTY */
+    return GNUNET_SYSERR;       /* -1 = INFTY */
   return tapis[ttype]->cost;
 }
 
@@ -348,7 +350,7 @@
  * @param msg the message to send
  * @param size the size of the message
  * @param important
- * @return OK on success, SYSERR on persistent error, NO on
+ * @return GNUNET_OK on success, GNUNET_SYSERR on persistent error, GNUNET_NO 
on
  *         temporary error
  */
 static int
@@ -360,26 +362,26 @@
       GE_LOG (ectx,
               GE_DEBUG | GE_DEVELOPER | GE_BULK,
               "Transmission attempted on uni-directional pipe, failing.\n");
-      return SYSERR;            /* can't do that, can happen for 
unidirectional pipes
+      return GNUNET_SYSERR;     /* can't do that, can happen for 
unidirectional pipes
                                    that call core with TSession being NULL. */
     }
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   CHECK (tsession);
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   if ((tsession->ttype >= tapis_count) || (tapis[tsession->ttype] == NULL))
     {
       GE_LOG (ectx,
               GE_ERROR | GE_BULK | GE_USER,
               _("Transmission attempt failed, transport type %d unknown.\n"),
               tsession->ttype);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   return tapis[tsession->ttype]->send (tsession, msg, size, important);
 }
 
 /**
  * Close the session with the remote node.
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
 transportDisconnect (TSession * tsession, const char *token)
@@ -389,22 +391,23 @@
   if (tsession == NULL)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if ((tsession->ttype >= tapis_count) || (tapis[tsession->ttype] == NULL))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   CHECK (tsession);
   for (i = 0; i < tsession->token_count; i++)
     {
       if (0 == strcmp (tsession->tokens[i], token))
         {
           tsession->tokens[i] = tsession->tokens[tsession->token_count - 1];
-          GROW (tsession->tokens,
-                tsession->token_count, tsession->token_count - 1);
+          GNUNET_array_grow (tsession->tokens,
+                             tsession->token_count,
+                             tsession->token_count - 1);
           i = -1;
           break;
         }
@@ -416,32 +419,32 @@
               GE_ERROR | GE_DEVELOPER | GE_USER | GE_IMMEDIATE,
               "Illegal call to `%s', do not have token `%s'\n",
               __FUNCTION__, token);
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   i = tapis[tsession->ttype]->disconnect (tsession);
-  GE_BREAK (NULL, i == OK);     /* should never fail */
+  GE_BREAK (NULL, i == GNUNET_OK);      /* should never fail */
   return i;
 }
 
 /**
  * Verify that a hello is ok. Call a method
  * if the verification was successful.
- * @return OK if the attempt to verify is on the way,
- *        SYSERR if the transport mechanism is not supported
+ * @return GNUNET_OK if the attempt to verify is on the way,
+ *        GNUNET_SYSERR if the transport mechanism is not supported
  */
 static int
-transportVerifyHello (const P2P_hello_MESSAGE * hello)
+transportVerifyHello (const GNUNET_MessageHello * hello)
 {
   unsigned short prot;
 
-  if ((ntohs (hello->header.size) != P2P_hello_MESSAGE_size (hello)) ||
+  if ((ntohs (hello->header.size) != GNUNET_sizeof_hello (hello)) ||
       (ntohs (hello->header.type) != p2p_PROTO_hello))
-    return SYSERR;              /* invalid */
+    return GNUNET_SYSERR;       /* invalid */
   prot = ntohs (hello->protocol);
   if ((prot >= tapis_count) || (tapis[prot] == NULL))
-    return SYSERR;              /* not supported */
+    return GNUNET_SYSERR;       /* not supported */
   return tapis[prot]->verifyHello (hello);
 }
 
@@ -452,7 +455,7 @@
 transportGetMTU (unsigned short ttype)
 {
   if ((ttype >= tapis_count) || (tapis[ttype] == NULL))
-    return SYSERR;
+    return GNUNET_SYSERR;
   return tapis[ttype]->mtu;
 }
 
@@ -460,18 +463,18 @@
  * Create a hello advertisement for the given
  * transport type for this node.
  */
-static P2P_hello_MESSAGE *
+static GNUNET_MessageHello *
 transportCreatehello (unsigned short ttype)
 {
   TransportAPI *tapi;
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
 
-  MUTEX_LOCK (tapis_lock);
+  GNUNET_mutex_lock (tapis_lock);
   if (ttype == ANY_PROTOCOL_NUMBER)
     {
-      int *perm;
+      unsigned int *perm;
 
-      perm = permute (WEAK, tapis_count);
+      perm = GNUNET_permute (GNUNET_RANDOM_QUALITY_WEAK, tapis_count);
       ttype = tapis_count - 1;
       while ((ttype < tapis_count) &&
              ((tapis[perm[ttype]] == NULL) ||
@@ -480,30 +483,30 @@
         ttype--;                /* unsigned, will wrap around! */
       if (ttype >= tapis_count)
         {
-          FREE (perm);
-          MUTEX_UNLOCK (tapis_lock);
+          GNUNET_free (perm);
+          GNUNET_mutex_unlock (tapis_lock);
           return NULL;
         }
       ttype = perm[ttype];
-      FREE (perm);
+      GNUNET_free (perm);
     }
   if ((ttype >= tapis_count) || (tapis[ttype] == NULL))
     {
       GE_LOG (ectx,
               GE_DEBUG | GE_BULK | GE_USER,
               _("No transport of type %d known.\n"), ttype);
-      MUTEX_UNLOCK (tapis_lock);
+      GNUNET_mutex_unlock (tapis_lock);
       return NULL;
     }
   tapi = tapis[ttype];
   if (tapi->hello == NULL)
     {
-      MUTEX_UNLOCK (tapis_lock);
+      GNUNET_mutex_unlock (tapis_lock);
       return NULL;              /* send-only transport */
     }
-  hello = MALLOC (P2P_hello_MESSAGE_size (tapi->hello));
-  memcpy (hello, tapi->hello, P2P_hello_MESSAGE_size (tapi->hello));
-  MUTEX_UNLOCK (tapis_lock);
+  hello = GNUNET_malloc (GNUNET_sizeof_hello (tapi->hello));
+  memcpy (hello, tapi->hello, GNUNET_sizeof_hello (tapi->hello));
+  GNUNET_mutex_unlock (tapis_lock);
   return hello;
 }
 
@@ -525,16 +528,16 @@
 {
   int i;
   int tcount;
-  P2P_hello_MESSAGE **hellos;
+  GNUNET_MessageHello **hellos;
   int used;
 
-  MUTEX_LOCK (tapis_lock);
+  GNUNET_mutex_lock (tapis_lock);
   tcount = 0;
   for (i = 0; i < tapis_count; i++)
     if (tapis[i] != NULL)
       tcount++;
 
-  hellos = MALLOC (tcount * sizeof (P2P_hello_MESSAGE *));
+  hellos = GNUNET_malloc (tcount * sizeof (GNUNET_MessageHello *));
   tcount = 0;
   for (i = 0; i < tapis_count; i++)
     {
@@ -545,30 +548,30 @@
             tcount++;
         }
     }
-  MUTEX_UNLOCK (tapis_lock);
+  GNUNET_mutex_unlock (tapis_lock);
   if (tcount == 0)
     {
       GE_LOG (ectx,
               GE_INFO | GE_USER | GE_REQUEST,
               _("No transport succeeded in creating a hello!\n"));
-      FREE (hellos);
-      return SYSERR;
+      GNUNET_free (hellos);
+      return GNUNET_SYSERR;
     }
   used = 0;
   while (tcount > 0)
     {
-      i = weak_randomi (tcount);        /* select a hello at random */
-      if ((unsigned int) P2P_hello_MESSAGE_size (hellos[i]) <= maxLen - used)
+      i = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, tcount);       /* 
select a hello at random */
+      if ((unsigned int) GNUNET_sizeof_hello (hellos[i]) <= maxLen - used)
         {
-          memcpy (&buff[used], hellos[i], P2P_hello_MESSAGE_size (hellos[i]));
-          used += P2P_hello_MESSAGE_size (hellos[i]);
+          memcpy (&buff[used], hellos[i], GNUNET_sizeof_hello (hellos[i]));
+          used += GNUNET_sizeof_hello (hellos[i]);
         }
-      FREE (hellos[i]);
+      GNUNET_free (hellos[i]);
       hellos[i] = hellos[--tcount];
     }
   for (i = 0; i < tcount; i++)
-    FREE (hellos[i]);
-  FREE (hellos);
+    GNUNET_free (hellos[i]);
+  GNUNET_free (hellos);
   if (used == 0)
     GE_LOG (ectx,
             GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
@@ -580,14 +583,14 @@
 initHello (void *cls)
 {
   TransportAPI *tapi = cls;
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
 
   createSignedhello (tapi);
   hello = transportCreatehello (tapi->protocolNumber);
   if (NULL != hello)
     {
       identity->addHost (hello);
-      FREE (hello);
+      GNUNET_free (hello);
     }
 }
 
@@ -598,7 +601,7 @@
   /* In the (rare) case that we shutdown transports
      before the cron-jobs had a chance to run, stop
      the cron-jobs */
-  cron_del_job (coreAPI->cron, &initHello, 0, tapi);
+  GNUNET_cron_del_job (coreAPI->cron, &initHello, 0, tapi);
 }
 
 static void
@@ -607,16 +610,16 @@
   void (*ptr) ();
 
   doneHelper (tapis[i], NULL);
-  cron_del_job (coreAPI->cron,
-                &createSignedhello, HELLO_RECREATE_FREQ, tapis[i]);
-  ptr = os_plugin_resolve_function (tapis[i]->libHandle,
-                                    "donetransport_", NO);
+  GNUNET_cron_del_job (coreAPI->cron,
+                       &createSignedhello, HELLO_RECREATE_FREQ, tapis[i]);
+  ptr = GNUNET_plugin_resolve_function (tapis[i]->libHandle,
+                                        "donetransport_", GNUNET_NO);
   if (ptr != NULL)
     ptr ();
-  FREE (tapis[i]->transName);
-  FREENONNULL (tapis[i]->hello);
+  GNUNET_free (tapis[i]->transName);
+  GNUNET_free_non_null (tapis[i]->hello);
   tapis[i]->hello = NULL;
-  os_plugin_unload (tapis[i]->libHandle);
+  GNUNET_plugin_unload (tapis[i]->libHandle);
   tapis[i] = NULL;
 }
 
@@ -634,7 +637,7 @@
   for (i = 0; i < tapis_count; i++)
     if (tapis[i] != NULL)
       {
-        if (OK != tapis[i]->startTransportServer ())
+        if (GNUNET_OK != tapis[i]->startTransportServer ())
           unloadTransport (i);
       }
 }
@@ -663,7 +666,7 @@
      blocks the startup process in this case.
      This is why we create the HELLOs in another
      thread. */
-  cron_add_job (coreAPI->cron, &initHello, 0, 0, tapi);
+  GNUNET_cron_add_job (coreAPI->cron, &initHello, 0, 0, tapi);
 }
 
 /**
@@ -674,18 +677,18 @@
  * even bother to construct (and encrypt) this kind
  * of message.
  *
- * @return YES if the transport would try (i.e. queue
+ * @return GNUNET_YES if the transport would try (i.e. queue
  *         the message or call the OS to send),
- *         NO if the transport would just drop the message,
- *         SYSERR if the size/session is invalid
+ *         GNUNET_NO if the transport would just drop the message,
+ *         GNUNET_SYSERR if the size/session is invalid
  */
 static int
 testWouldTry (TSession * tsession, unsigned int size, int important)
 {
   if (tsession == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   if ((tsession->ttype >= tapis_count) || (tapis[tsession->ttype] == NULL))
-    return SYSERR;
+    return GNUNET_SYSERR;
   return tapis[tsession->ttype]->testWouldTry (tsession, size, important);
 }
 
@@ -701,8 +704,8 @@
   char *dso;
   char *next;
   char *pos;
-  struct PluginHandle *lib;
-  EncName myself;
+  struct GNUNET_PluginHandle *lib;
+  GNUNET_EncName myself;
 
   ectx = capi->ectx;
   if (-1 == GC_get_configuration_value_number (capi->cfg,
@@ -714,7 +717,7 @@
     return NULL;
   hello_live *= 60;
 
-  GE_ASSERT (ectx, sizeof (P2P_hello_MESSAGE) == 600);
+  GE_ASSERT (ectx, sizeof (GNUNET_MessageHello) == 600);
   identity = capi->requestService ("identity");
   if (identity == NULL)
     {
@@ -733,10 +736,10 @@
   ctapi.releaseService = coreAPI->releaseService;
   ctapi.assertUnused = coreAPI->assertUnused;
 
-  GROW (tapis, tapis_count, UDP_PROTOCOL_NUMBER + 1);
+  GNUNET_array_grow (tapis, tapis_count, UDP_PROTOCOL_NUMBER + 1);
 
-  tapis_lock = MUTEX_CREATE (YES);
-  lock = MUTEX_CREATE (NO);
+  tapis_lock = GNUNET_mutex_create (GNUNET_YES);
+  lock = GNUNET_mutex_create (GNUNET_NO);
 
   /* now load transports */
   dso = NULL;
@@ -763,7 +766,7 @@
               *next = '\0';     /* add 0-termination for pos */
               next++;
             }
-          lib = os_plugin_load (ectx, "libgnunettransport_", pos);
+          lib = GNUNET_plugin_load (ectx, "libgnunettransport_", pos);
           if (lib == NULL)
             {
               GE_LOG (ectx,
@@ -771,7 +774,9 @@
                       _("Could not load transport plugin `%s'\n"), pos);
               continue;
             }
-          tptr = os_plugin_resolve_function (lib, "inittransport_", YES);
+          tptr =
+            GNUNET_plugin_resolve_function (lib, "inittransport_",
+                                            GNUNET_YES);
           if (tptr == NULL)
             {
               GE_LOG (ectx,
@@ -780,26 +785,28 @@
                       _
                       ("Transport library `%s' did not provide required 
function '%s%s'.\n"),
                       pos, "inittransport_", pos);
-              os_plugin_unload (lib);
+              GNUNET_plugin_unload (lib);
               continue;
             }
           tapi = tptr (&ctapi);
           if (tapi == NULL)
             {
-              os_plugin_unload (lib);
+              GNUNET_plugin_unload (lib);
               continue;
             }
           tapi->libHandle = lib;
-          tapi->transName = STRDUP (pos);
-          if (OK != addTransport (tapi))
+          tapi->transName = GNUNET_strdup (pos);
+          if (GNUNET_OK != addTransport (tapi))
             {
               void (*ptr) ();
 
-              FREE (tapi->transName);
-              ptr = os_plugin_resolve_function (lib, "donetransport_", NO);
+              GNUNET_free (tapi->transName);
+              ptr =
+                GNUNET_plugin_resolve_function (lib, "donetransport_",
+                                                GNUNET_NO);
               if (ptr != NULL)
                 ptr ();
-              os_plugin_unload (lib);
+              GNUNET_plugin_unload (lib);
             }
           else
             {
@@ -810,11 +817,11 @@
         }
       while (next != NULL);
     }
-  FREE (dso);
+  GNUNET_free (dso);
 
   IF_GELOG (ectx,
             GE_INFO | GE_REQUEST | GE_USER,
-            hash2enc (&coreAPI->myIdentity->hashPubKey, &myself));
+            GNUNET_hash_to_enc (&coreAPI->myIdentity->hashPubKey, &myself));
   GE_LOG (ectx,
           GE_INFO | GE_REQUEST | GE_USER, _("I am peer `%s'.\n"), &myself);
   forEachTransport (&initHelper, NULL);
@@ -854,15 +861,15 @@
   for (i = 0; i < tapis_count; i++)
     if (tapis[i] != NULL)
       unloadTransport (i);
-  MUTEX_DESTROY (tapis_lock);
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (tapis_lock);
+  GNUNET_mutex_destroy (lock);
   tapis_lock = NULL;
-  GROW (tapis, tapis_count, 0);
+  GNUNET_array_grow (tapis, tapis_count, 0);
 
   coreAPI->releaseService (identity);
   identity = NULL;
   coreAPI = NULL;
-  return OK;
+  return GNUNET_OK;
 }
 
 

Modified: GNUnet/src/applications/vpn/Makefile.am
===================================================================
--- GNUnet/src/applications/vpn/Makefile.am     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/vpn/Makefile.am     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -14,8 +14,6 @@
 gnunet_vpn_SOURCES = \
   gnunet-vpn.c         
 gnunet_vpn_LDADD = \
- $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
- $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
  $(top_builddir)/src/util/libgnunetutil.la 
 
 libgnunetmodule_vpn_la_SOURCES = \
@@ -23,5 +21,4 @@
 libgnunetmodule_vpn_la_LDFLAGS = \
   -export-dynamic -avoid-version -module
 libgnunetmodule_vpn_la_LIBADD = \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
  $(top_builddir)/src/util/libgnunetutil.la 

Modified: GNUnet/src/applications/vpn/gnunet-vpn.c
===================================================================
--- GNUnet/src/applications/vpn/gnunet-vpn.c    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/applications/vpn/gnunet-vpn.c    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -25,21 +25,19 @@
  */
 
 #include "gnunet_util.h"
-#include "gnunet_util_network_client.h"
-#include "gnunet_util_boot.h"
 #include "gnunet_protocols.h"
 #include "gnunet_directories.h"
 #include "platform.h"
 
 #define TEMPLATE_VERSION "2006072900"
 
-#define buf ((MESSAGE_HEADER*)&buffer)
+#define buf ((GNUNET_MessageHeader*)&buffer)
 
 
-static struct SEMAPHORE *doneSem;
-static struct SEMAPHORE *cmdAck;
-static struct SEMAPHORE *exitCheck;
-static struct MUTEX *lock;
+static struct GNUNET_Semaphore *doneSem;
+static struct GNUNET_Semaphore *cmdAck;
+static struct GNUNET_Semaphore *exitCheck;
+static struct GNUNET_Mutex *lock;
 static int wantExit;
 static int silent;
 
@@ -48,27 +46,27 @@
 /**
  * All gnunet-transport-check command line options
  */
-static struct CommandLineOption gnunetvpnOptions[] = {
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Print statistics about GNUnet 
operations.")),        /* -h */
-  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+static struct GNUNET_CommandLineOption gnunetvpnOptions[] = {
+       GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
+       GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Print statistics about 
GNUnet operations.")),        /* -h */
+  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'s', "silent", NULL,
    gettext_noop ("Suppress display of asynchronous log messages"),
-   0, &gnunet_getopt_configure_set_one, &silent},
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_END,
+   0, &GNUNET_getopt_configure_set_one, &silent},
+   GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 static void *
 receiveThread (void *arg)
 {
-  struct ClientServerConnection *sock = arg;
-  char buffer[MAX_BUFFER_SIZE];
-  MESSAGE_HEADER *bufp = buf;
+  struct GNUNET_ClientServerConnection *sock = arg;
+  char buffer[GNUNET_MAX_BUFFER_SIZE];
+  GNUNET_MessageHeader *bufp = buf;
 
-  /* buffer = MALLOC(MAX_BUFFER_SIZE); */
-  while (OK == connection_read (sock, &bufp))
+  /* buffer = GNUNET_malloc(GNUNET_MAX_BUFFER_SIZE); */
+  while (GNUNET_OK == GNUNET_client_connection_read (sock, &bufp))
     {
       switch (ntohs (buf->type))
         {
@@ -81,40 +79,42 @@
         case CS_PROTO_VPN_REALISE:
         case CS_PROTO_VPN_ADD:
         case CS_PROTO_VPN_TRUST:
-          if (ntohs (buf->size) > sizeof (MESSAGE_HEADER))
+          if (ntohs (buf->size) > sizeof (GNUNET_MessageHeader))
             {
-              fwrite (buffer + sizeof (MESSAGE_HEADER),
+              fwrite (buffer + sizeof (GNUNET_MessageHeader),
                       sizeof (char),
-                      ntohs (buf->size) - sizeof (MESSAGE_HEADER), stdout);
+                      ntohs (buf->size) - sizeof (GNUNET_MessageHeader),
+                      stdout);
             }
 
-          SEMAPHORE_UP (cmdAck);
-          SEMAPHORE_DOWN (exitCheck, YES);
-          MUTEX_LOCK (lock);
-          if (wantExit == YES)
+          GNUNET_semaphore_up (cmdAck);
+          GNUNET_semaphore_down (exitCheck, GNUNET_YES);
+          GNUNET_mutex_lock (lock);
+          if (wantExit == GNUNET_YES)
             {
-              MUTEX_UNLOCK (lock);
-              SEMAPHORE_UP (doneSem);
+              GNUNET_mutex_unlock (lock);
+              GNUNET_semaphore_up (doneSem);
               return NULL;
             }
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           break;;
         case CS_PROTO_VPN_MSG:
-          if (silent == YES)
+          if (silent == GNUNET_YES)
             break;;
         case CS_PROTO_VPN_REPLY:
 
-          if (ntohs (buf->size) > sizeof (MESSAGE_HEADER))
+          if (ntohs (buf->size) > sizeof (GNUNET_MessageHeader))
             {
-              fwrite (buffer + sizeof (MESSAGE_HEADER),
+              fwrite (buffer + sizeof (GNUNET_MessageHeader),
                       sizeof (char),
-                      ntohs (buf->size) - sizeof (MESSAGE_HEADER), stdout);
+                      ntohs (buf->size) - sizeof (GNUNET_MessageHeader),
+                      stdout);
             }
           break;;
         }
     }
-  /* FREE(buffer); */
-  SEMAPHORE_UP (doneSem);
+  /* GNUNET_free(buffer); */
+  GNUNET_semaphore_up (doneSem);
   return NULL;
 }
 
@@ -126,10 +126,10 @@
 int
 main (int argc, char *const *argv)
 {
-  struct ClientServerConnection *sock;
-  struct PTHREAD *messageReceiveThread;
+  struct GNUNET_ClientServerConnection *sock;
+  struct GNUNET_ThreadHandle *messageReceiveThread;
   void *unused;
-  char buffer[sizeof (MESSAGE_HEADER) + 1024];
+  char buffer[sizeof (GNUNET_MessageHeader) + 1024];
   int rancommand = 0;
   struct GC_Configuration *cfg;
   struct GE_Context *ectx;
@@ -143,7 +143,7 @@
       GNUNET_fini (ectx, cfg);
       return -1;
     }
-  sock = client_connection_create (ectx, cfg);
+  sock = GNUNET_client_connection_create (ectx, cfg);
   if (sock == NULL)
     {
       fprintf (stderr, _("Error establishing connection with gnunetd.\n"));
@@ -151,13 +151,14 @@
       return 1;
     }
 
-  doneSem = SEMAPHORE_CREATE (0);
-  cmdAck = SEMAPHORE_CREATE (0);
-  exitCheck = SEMAPHORE_CREATE (0);
-  lock = MUTEX_CREATE (NO);
-  wantExit = NO;
+  doneSem = GNUNET_semaphore_create (0);
+  cmdAck = GNUNET_semaphore_create (0);
+  exitCheck = GNUNET_semaphore_create (0);
+  lock = GNUNET_mutex_create (GNUNET_NO);
+  wantExit = GNUNET_NO;
 
-  messageReceiveThread = PTHREAD_CREATE (&receiveThread, sock, 128 * 1024);
+  messageReceiveThread =
+    GNUNET_thread_create (&receiveThread, sock, 128 * 1024);
   if (messageReceiveThread == NULL)
     GE_DIE_STRERROR (ectx,
                      GE_FATAL | GE_ADMIN | GE_USER | GE_IMMEDIATE,
@@ -170,87 +171,119 @@
       if (rancommand)
         {
           rancommand = 0;
-          SEMAPHORE_UP (exitCheck);
+          GNUNET_semaphore_up (exitCheck);
         }
       if (strncmp (buffer, "debug0", 6) == 0)
         {
-          ((MESSAGE_HEADER *) & buffer)->type = htons (CS_PROTO_VPN_DEBUGOFF);
-          ((MESSAGE_HEADER *) & buffer)->size =
-            htons (sizeof (MESSAGE_HEADER));
-          if (SYSERR == connection_write (sock, (MESSAGE_HEADER *) & buffer))
+          ((GNUNET_MessageHeader *) & buffer)->type =
+            htons (CS_PROTO_VPN_DEBUGOFF);
+          ((GNUNET_MessageHeader *) & buffer)->size =
+            htons (sizeof (GNUNET_MessageHeader));
+          if (GNUNET_SYSERR ==
+              GNUNET_client_connection_write (sock,
+                                              (GNUNET_MessageHeader *) &
+                                              buffer))
             return -1;
           rancommand = 1;
-          SEMAPHORE_DOWN (cmdAck, YES);
+          GNUNET_semaphore_down (cmdAck, GNUNET_YES);
         }
       else if (strncmp (buffer, "debug1", 6) == 0)
         {
-          ((MESSAGE_HEADER *) & buffer)->type = htons (CS_PROTO_VPN_DEBUGON);
-          ((MESSAGE_HEADER *) & buffer)->size =
-            htons (sizeof (MESSAGE_HEADER));
-          if (SYSERR == connection_write (sock, (MESSAGE_HEADER *) & buffer))
+          ((GNUNET_MessageHeader *) & buffer)->type =
+            htons (CS_PROTO_VPN_DEBUGON);
+          ((GNUNET_MessageHeader *) & buffer)->size =
+            htons (sizeof (GNUNET_MessageHeader));
+          if (GNUNET_SYSERR ==
+              GNUNET_client_connection_write (sock,
+                                              (GNUNET_MessageHeader *) &
+                                              buffer))
             return -1;
           rancommand = 1;
-          SEMAPHORE_DOWN (cmdAck, YES);
+          GNUNET_semaphore_down (cmdAck, GNUNET_YES);
         }
       else if (strncmp (buffer, "tunnels", 7) == 0)
         {
-          ((MESSAGE_HEADER *) & buffer)->type = htons (CS_PROTO_VPN_TUNNELS);
-          ((MESSAGE_HEADER *) & buffer)->size =
-            htons (sizeof (MESSAGE_HEADER));
-          if (SYSERR == connection_write (sock, (MESSAGE_HEADER *) & buffer))
+          ((GNUNET_MessageHeader *) & buffer)->type =
+            htons (CS_PROTO_VPN_TUNNELS);
+          ((GNUNET_MessageHeader *) & buffer)->size =
+            htons (sizeof (GNUNET_MessageHeader));
+          if (GNUNET_SYSERR ==
+              GNUNET_client_connection_write (sock,
+                                              (GNUNET_MessageHeader *) &
+                                              buffer))
             return -1;
           rancommand = 1;
-          SEMAPHORE_DOWN (cmdAck, YES);
+          GNUNET_semaphore_down (cmdAck, GNUNET_YES);
         }
       else if (strncmp (buffer, "route", 5) == 0)
         {
-          ((MESSAGE_HEADER *) & buffer)->type = htons (CS_PROTO_VPN_ROUTES);
-          ((MESSAGE_HEADER *) & buffer)->size =
-            htons (sizeof (MESSAGE_HEADER));
-          if (SYSERR == connection_write (sock, (MESSAGE_HEADER *) & buffer))
+          ((GNUNET_MessageHeader *) & buffer)->type =
+            htons (CS_PROTO_VPN_ROUTES);
+          ((GNUNET_MessageHeader *) & buffer)->size =
+            htons (sizeof (GNUNET_MessageHeader));
+          if (GNUNET_SYSERR ==
+              GNUNET_client_connection_write (sock,
+                                              (GNUNET_MessageHeader *) &
+                                              buffer))
             return -1;
           rancommand = 1;
-          SEMAPHORE_DOWN (cmdAck, YES);
+          GNUNET_semaphore_down (cmdAck, GNUNET_YES);
         }
       else if (strncmp (buffer, "realised", 8) == 0)
         {
-          ((MESSAGE_HEADER *) & buffer)->type = htons (CS_PROTO_VPN_REALISED);
-          ((MESSAGE_HEADER *) & buffer)->size =
-            htons (sizeof (MESSAGE_HEADER));
-          if (SYSERR == connection_write (sock, (MESSAGE_HEADER *) & buffer))
+          ((GNUNET_MessageHeader *) & buffer)->type =
+            htons (CS_PROTO_VPN_REALISED);
+          ((GNUNET_MessageHeader *) & buffer)->size =
+            htons (sizeof (GNUNET_MessageHeader));
+          if (GNUNET_SYSERR ==
+              GNUNET_client_connection_write (sock,
+                                              (GNUNET_MessageHeader *) &
+                                              buffer))
             return -1;
           rancommand = 1;
-          SEMAPHORE_DOWN (cmdAck, YES);
+          GNUNET_semaphore_down (cmdAck, GNUNET_YES);
         }
       else if (strncmp (buffer, "reset", 5) == 0)
         {
-          ((MESSAGE_HEADER *) & buffer)->type = htons (CS_PROTO_VPN_RESET);
-          ((MESSAGE_HEADER *) & buffer)->size =
-            htons (sizeof (MESSAGE_HEADER));
-          if (SYSERR == connection_write (sock, (MESSAGE_HEADER *) & buffer))
+          ((GNUNET_MessageHeader *) & buffer)->type =
+            htons (CS_PROTO_VPN_RESET);
+          ((GNUNET_MessageHeader *) & buffer)->size =
+            htons (sizeof (GNUNET_MessageHeader));
+          if (GNUNET_SYSERR ==
+              GNUNET_client_connection_write (sock,
+                                              (GNUNET_MessageHeader *) &
+                                              buffer))
             return -1;
           rancommand = 1;
-          SEMAPHORE_DOWN (cmdAck, YES);
+          GNUNET_semaphore_down (cmdAck, GNUNET_YES);
         }
       else if (strncmp (buffer, "realise", 7) == 0)
         {
-          ((MESSAGE_HEADER *) & buffer)->type = htons (CS_PROTO_VPN_REALISE);
-          ((MESSAGE_HEADER *) & buffer)->size =
-            htons (sizeof (MESSAGE_HEADER));
-          if (SYSERR == connection_write (sock, (MESSAGE_HEADER *) & buffer))
+          ((GNUNET_MessageHeader *) & buffer)->type =
+            htons (CS_PROTO_VPN_REALISE);
+          ((GNUNET_MessageHeader *) & buffer)->size =
+            htons (sizeof (GNUNET_MessageHeader));
+          if (GNUNET_SYSERR ==
+              GNUNET_client_connection_write (sock,
+                                              (GNUNET_MessageHeader *) &
+                                              buffer))
             return -1;
           rancommand = 1;
-          SEMAPHORE_DOWN (cmdAck, YES);
+          GNUNET_semaphore_down (cmdAck, GNUNET_YES);
         }
       else if (strncmp (buffer, "trust", 5) == 0)
         {
-          ((MESSAGE_HEADER *) & buffer)->type = htons (CS_PROTO_VPN_TRUST);
-          ((MESSAGE_HEADER *) & buffer)->size =
-            htons (sizeof (MESSAGE_HEADER));
-          if (SYSERR == connection_write (sock, (MESSAGE_HEADER *) & buffer))
+          ((GNUNET_MessageHeader *) & buffer)->type =
+            htons (CS_PROTO_VPN_TRUST);
+          ((GNUNET_MessageHeader *) & buffer)->size =
+            htons (sizeof (GNUNET_MessageHeader));
+          if (GNUNET_SYSERR ==
+              GNUNET_client_connection_write (sock,
+                                              (GNUNET_MessageHeader *) &
+                                              buffer))
             return -1;
           rancommand = 1;
-          SEMAPHORE_DOWN (cmdAck, YES);
+          GNUNET_semaphore_down (cmdAck, GNUNET_YES);
         }
       else if (strncmp (buffer, "add ", 4) == 0)
         {
@@ -259,14 +292,17 @@
            */
           if (strlen (&buffer[4]) > 1)
             {
-              ((MESSAGE_HEADER *) & buffer)->type = htons (CS_PROTO_VPN_ADD);
-              ((MESSAGE_HEADER *) & buffer)->size =
-                htons (sizeof (MESSAGE_HEADER) + strlen (&buffer[5]));
-              if (SYSERR ==
-                  connection_write (sock, (MESSAGE_HEADER *) & buffer))
+              ((GNUNET_MessageHeader *) & buffer)->type =
+                htons (CS_PROTO_VPN_ADD);
+              ((GNUNET_MessageHeader *) & buffer)->size =
+                htons (sizeof (GNUNET_MessageHeader) + strlen (&buffer[5]));
+              if (GNUNET_SYSERR ==
+                  GNUNET_client_connection_write (sock,
+                                                  (GNUNET_MessageHeader *) &
+                                                  buffer))
                 return -1;
               rancommand = 1;
-              SEMAPHORE_DOWN (cmdAck, YES);
+              GNUNET_semaphore_down (cmdAck, GNUNET_YES);
             }
           else
             {
@@ -282,22 +318,22 @@
   /* wait for shutdown... */
   if (rancommand)
     {
-      MUTEX_LOCK (lock);
-      wantExit = YES;
-      MUTEX_UNLOCK (lock);
-      SEMAPHORE_UP (exitCheck);
+      GNUNET_mutex_lock (lock);
+      wantExit = GNUNET_YES;
+      GNUNET_mutex_unlock (lock);
+      GNUNET_semaphore_up (exitCheck);
     }
 
   /* we can't guarantee that this can be called while the other thread is 
waiting for read */
-  connection_close_forever (sock);
-  SEMAPHORE_DOWN (doneSem, YES);
+  GNUNET_client_connection_close_forever (sock);
+  GNUNET_semaphore_down (doneSem, GNUNET_YES);
 
-  SEMAPHORE_DESTROY (doneSem);
-  SEMAPHORE_DESTROY (cmdAck);
-  SEMAPHORE_DESTROY (exitCheck);
-  MUTEX_DESTROY (lock);
-  PTHREAD_JOIN (messageReceiveThread, &unused);
-  connection_destroy (sock);
+  GNUNET_semaphore_destroy (doneSem);
+  GNUNET_semaphore_destroy (cmdAck);
+  GNUNET_semaphore_destroy (exitCheck);
+  GNUNET_mutex_destroy (lock);
+  GNUNET_thread_join (messageReceiveThread, &unused);
+  GNUNET_client_connection_destroy (sock);
   GNUNET_fini (ectx, cfg);
 
   return 0;

Modified: GNUnet/src/applications/vpn/vpn.c
===================================================================
--- GNUnet/src/applications/vpn/vpn.c   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/applications/vpn/vpn.c   2007-11-23 11:51:54 UTC (rev 5742)
@@ -40,7 +40,7 @@
  * It also allows interoperation with other users of this
  * space such as anonymous internets. We use GNUnet to benefit from
  * its key infrastructure, though other users may well rip fdxx:: bits directly
- * from public keys, using the private key to sign route announcements.
+ * from public keys, using the private key to GNUNET_RSA_sign route 
announcements.
  *
  * CHANGELOG:
  * 20060110 Change ifconfig/route to ioctl's
@@ -91,7 +91,7 @@
  */
 #define maxi(a,b) ((a)>(b)?(a):(b))
 #define mini(a,b) ((a)<(b)?(a):(b))
-#define HEADER_FRAME maxi(sizeof(MESSAGE_HEADER), sizeof(struct tun_pi))
+#define HEADER_FRAME maxi(sizeof(GNUNET_MessageHeader), sizeof(struct tun_pi))
 
 /* we can't actually send messages this long... maybe 2 bytes shorter tho
  * planned includes a way to send yet longer messages
@@ -112,9 +112,9 @@
 
 static int cdebug;
 static int interval = 60;
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
-static struct PTHREAD *tunThreadInfo;
+static struct GNUNET_ThreadHandle *tunThreadInfo;
 
 static struct GE_Context *ectx;
 
@@ -132,7 +132,7 @@
   int active;
   int route_entry;
   int ifindex;
-  PeerIdentity peer;
+  GNUNET_PeerIdentity peer;
 } tunnel_info;
 
 /* from bluetooth agent */
@@ -165,7 +165,7 @@
 typedef struct
 {
   /** owner's public key */
-  PublicKey owner;
+  GNUNET_RSA_PublicKey owner;
   /** hops to owner 1 = have a tunnel to owner, 0 = I am the owner.*/
   int hops;
   /** which tunnel entry in tunnels array */
@@ -181,13 +181,13 @@
 #define GNUNET_VIEW_LIMIT 100
 
 /* same thing as route but without the tunnel info,
- * which is implicit with the sender PeerIdentity anyway.
+ * which is implicit with the sender GNUNET_PeerIdentity anyway.
  *
  * also the fields here are network byte order.
  */
 typedef struct
 {
-  PublicKey owner;
+  GNUNET_RSA_PublicKey owner;
   int hops;
 } transit_route;
 
@@ -206,9 +206,9 @@
   va_list args;
   int r = -1;
   int size = 100;
-  MESSAGE_HEADER *b = NULL, *nb = NULL;
+  GNUNET_MessageHeader *b = NULL, *nb = NULL;
 
-  if ((b = MALLOC (sizeof (MESSAGE_HEADER) + size)) == NULL)
+  if ((b = GNUNET_malloc (sizeof (GNUNET_MessageHeader) + size)) == NULL)
     {
       return;
     }
@@ -227,9 +227,10 @@
         {
           size *= 2;
         }
-      if ((nb = REALLOC (b, sizeof (MESSAGE_HEADER) + size)) == NULL)
+      if ((nb =
+           GNUNET_realloc (b, sizeof (GNUNET_MessageHeader) + size)) == NULL)
         {
-          FREE (b);
+          GNUNET_free (b);
           return;
         }
       else
@@ -238,26 +239,27 @@
         }
     }
   b->type = htons (t);
-  b->size = htons (sizeof (MESSAGE_HEADER) + strlen ((char *) (b + 1)));
+  b->size = htons (sizeof (GNUNET_MessageHeader) + strlen ((char *) (b + 1)));
   if (c != NULL)
     {
-      coreAPI->sendToClient (c, b, YES);
+      coreAPI->sendToClient (c, b, GNUNET_YES);
     }
   else
     {
       for (r = 0; r < clients_entries; r++)
         {
-          coreAPI->sendToClient (*(clients_store + r), b, YES);
+          coreAPI->sendToClient (*(clients_store + r), b, GNUNET_YES);
         }
     }
-  FREE (b);
+  GNUNET_free (b);
 }
 
 #define VLOG if ((cdebug & (GE_DEBUG | GE_DEVELOPER | GE_REQUEST)) > 0) 
cprintf(NULL,CS_PROTO_VPN_MSG,
 
-/** Test if two PublicKey are equal or not */
+/** Test if two GNUNET_RSA_PublicKey are equal or not */
 static int
-isEqualP (const PublicKey * first, const PublicKey * second)
+isEqualP (const GNUNET_RSA_PublicKey * first,
+          const GNUNET_RSA_PublicKey * second)
 {
   int i;
   int ln = maxi (first->sizen, second->sizen);
@@ -267,36 +269,37 @@
   if (memcmp
       ((first->key) + ((first->sizen) - sn),
        (second->key) + ((second->sizen) - sn), sn) != 0)
-    return NO;
+    return GNUNET_NO;
 
   /* difference before n should be 0 */
   for (i = 0; i < (first->sizen) - sn; i++)
     {
       if (*(first->key + i) != 0)
-        return NO;
+        return GNUNET_NO;
     }
   for (i = 0; i < (second->sizen) - sn; i++)
     {
       if (*(second->key + i) != 0)
-        return NO;
+        return GNUNET_NO;
     }
 
   /* compare common mode exponent */
-  if (memcmp ((first->key) + ln, (second->key) + ln, RSA_KEY_LEN - ln) != 0)
-    return NO;
+  if (memcmp ((first->key) + ln, (second->key) + ln, GNUNET_RSA_KEY_LEN - ln)
+      != 0)
+    return GNUNET_NO;
 
   for (i = first->sizen; i < ln; i++)
     {
       if (*(first->key + i) != 0)
-        return NO;
+        return GNUNET_NO;
     }
   for (i = second->sizen; i < ln; i++)
     {
       if (*(second->key + i) != 0)
-        return NO;
+        return GNUNET_NO;
     }
 
-  return YES;
+  return GNUNET_YES;
 }
 
 /**
@@ -311,7 +314,7 @@
   reqcapacity = sizeof (route_info);
   if (reqcapacity > route_capacity)
     {
-      reqstore = REALLOC (route_store, reqcapacity);
+      reqstore = GNUNET_realloc (route_store, reqcapacity);
       if (reqstore == NULL)
         return;                 /* not enough ram, cannot init! */
       route_store = reqstore;
@@ -334,7 +337,7 @@
   reqcapacity = sizeof (route_info);
   if (reqcapacity > realised_capacity)
     {
-      reqstore = REALLOC (realised_store, reqcapacity);
+      reqstore = GNUNET_realloc (realised_store, reqcapacity);
       if (reqstore == NULL)
         return;                 /* not enough ram, cannot init! */
       realised_store = reqstore;
@@ -346,9 +349,9 @@
   realised_store->owner = *(identity->getPublicPrivateKey ());  /* us! */
 }
 
-/* adds a route to prototype route table, unless it has same PublicKey and 
tunnel as another entry */
+/* adds a route to prototype route table, unless it has same 
GNUNET_RSA_PublicKey and tunnel as another entry */
 static void
-add_route (PublicKey * them, int hops, int tunnel)
+add_route (GNUNET_RSA_PublicKey * them, int hops, int tunnel)
 {
   int i;
   route_info *rstore;
@@ -385,7 +388,7 @@
   rcapacity = route_entries * sizeof (route_info);
   if (rcapacity > route_capacity)
     {
-      rstore = REALLOC (route_store, rcapacity);
+      rstore = GNUNET_realloc (route_store, rcapacity);
       if (rstore == NULL)
         {
           route_entries--;
@@ -464,34 +467,35 @@
     {
       GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
               _("RFC4193 Frame length %d is too big for GNUnet!\n"), len);
-      return NO;
+      return GNUNET_NO;
     }
   if (len < sizeof (struct tun_pi))
     {
       GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
               _("RFC4193 Frame length %d too small\n"), len);
-      return NO;
+      return GNUNET_NO;
     }
   if ((ntohs (tp->proto) == ETH_P_IP)
       && (((struct iphdr *) fp)->version == 4))
     {
-      return YES;
+      return GNUNET_YES;
     }
   else if ((ntohs (tp->proto) == ETH_P_IPV6)
            && (((struct iphdr *) fp)->version == 6))
     {
       ipinfo (info, fp);
       VLOG "-> GNUnet(%d) : %s\n", len - sizeof (struct tun_pi), info);
-      return YES;
+      return GNUNET_YES;
     }
   GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
           _("RFC4193 Ethertype %x and IP version %x do not match!\n"),
           ntohs (tp->proto), ((struct iphdr *) fp)->version);
-  return NO;
+  return GNUNET_NO;
 }
 
-/** Test if two PeerIdentity are equal or not */
-static int isEqual (const PeerIdentity * first, const PeerIdentity * second)
+/** Test if two GNUNET_PeerIdentity are equal or not */
+static int isEqual (const GNUNET_PeerIdentity * first,
+                    const GNUNET_PeerIdentity * second)
 {
   int i;
   for (i = 0; i < 512 / 8 / sizeof (unsigned int); i++)
@@ -506,9 +510,9 @@
 
 /**
  * Convert a PeerIdentify into a "random" RFC4193 prefix
- * actually we make the first 40 bits of the hash into the prefix!
+ * actually we make the first 40 bits of the GNUNET_hash into the prefix!
  */
-static void id2ip (struct ClientHandle *cx, const PeerIdentity * them)
+static void id2ip (struct ClientHandle *cx, const GNUNET_PeerIdentity * them)
 {
   unsigned char a, b, c, d, e;
   a = (them->hashPubKey.bits[0] >> 8) & 0xff;
@@ -519,8 +523,8 @@
   cprintf (cx, CS_PROTO_VPN_REPLY, "fd%02x:%02x%02x:%02x%02x", a, b, c, d, e);
 }
 
-/* convert PeerIdentity into network octet order IPv6 address */
-static void id2net (struct in6_addr *buf, const PeerIdentity * them)
+/* convert GNUNET_PeerIdentity into network octet order IPv6 address */
+static void id2net (struct in6_addr *buf, const GNUNET_PeerIdentity * them)
 {
   unsigned char a, b, c, d, e;
   a = (them->hashPubKey.bits[0] >> 8) & 0xff;
@@ -544,7 +548,7 @@
   buf->s6_addr16[7] = 0;
 }
 
-static void setup_tunnel (int n, const PeerIdentity * them)
+static void setup_tunnel (int n, const GNUNET_PeerIdentity * them)
 {
   struct ifreq ifr;
   struct in6_ifreq ifr6;
@@ -619,10 +623,10 @@
 
 
   ioctl (fd, TUNSETNOCSUM, 1);
-  memcpy (&((store1 + n)->peer), them, sizeof (PeerIdentity));
+  memcpy (&((store1 + n)->peer), them, sizeof (GNUNET_PeerIdentity));
   (store1 + n)->id = id;
   (store1 + n)->fd = fd;
-  (store1 + n)->active = YES;
+  (store1 + n)->active = GNUNET_YES;
   (store1 + n)->route_entry = 0;
 
   /* tun_alloc can change the tunnel name */
@@ -631,12 +635,12 @@
   /* here we should give the tunnel an IPv6 address and fake up a route to the 
other end
    * the format looks like this, and the net/host split is fixed at /48 as in 
rfc4193
    * local /64
-   *    net: my PeerIdentity
+   *    net: my GNUNET_PeerIdentity
    *    subnet: interface number+2
    *    interface: NULL
    *
    * remote /48
-   *    net: their PeerIdentity
+   *    net: their GNUNET_PeerIdentity
    *    host: NULL (it's not needed for routes)
    */
 
@@ -738,9 +742,10 @@
 
 /**
  * See if we already got a TUN/TAP open for the given GNUnet peer. if not, 
make one, stick
- * PeerIdentity and the filehandle and name of the TUN/TAP in an array so we 
remember we did it.
+ * GNUNET_PeerIdentity and the filehandle and name of the TUN/TAP in an array 
so we remember we did it.
  */
-static void checkensure_peer (const PeerIdentity * them, void *callerinfo)
+static void checkensure_peer (const GNUNET_PeerIdentity * them,
+                              void *callerinfo)
 {
   int i;
   tunnel_info *rstore1;
@@ -754,7 +759,7 @@
     {
       if (isEqual (them, &((store1 + i)->peer)))
         {
-          (store1 + i)->active = YES;
+          (store1 + i)->active = GNUNET_YES;
           return;
         }
     }
@@ -766,7 +771,7 @@
   rcapacity1 = entries1 * sizeof (tunnel_info);
   if (rcapacity1 > capacity1)
     {
-      rstore1 = REALLOC (store1, rcapacity1);
+      rstore1 = GNUNET_realloc (store1, rcapacity1);
       if (rstore1 == NULL)
         {
           GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
@@ -808,7 +813,7 @@
   char frame[IP_FRAME + HEADER_FRAME];
   struct ip6_hdr *fp;
   struct tun_pi *tp;
-  MESSAGE_HEADER *gp;
+  GNUNET_MessageHeader *gp;
   struct timeval timeout;
 
   /* need the cast otherwise it increments by HEADER_FRAME * sizeof(frame) 
rather than HEADER_FRAME */
@@ -816,13 +821,13 @@
 
   /* this trick decrements the pointer by the sizes of the respective structs 
*/
   tp = ((struct tun_pi *) fp) - 1;
-  gp = ((MESSAGE_HEADER *) fp) - 1;
+  gp = ((GNUNET_MessageHeader *) fp) - 1;
   running = 1;
   GE_LOG (ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
           _("RFC4193 Thread running (frame %d tunnel %d f2f %d) ...\n"), fp,
           tp, gp);
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   while (running)
     {
 
@@ -845,7 +850,7 @@
           FD_SET (((store1 + i)->fd), &readSet);
           max = maxi (max, (store1 + i)->fd);
         }
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       timeout.tv_sec = interval;
       timeout.tv_usec = 0;
 
@@ -864,7 +869,7 @@
                              GE_WARNING | GE_BULK | GE_USER,
                              "vpn could not read from exit control pipe\n");
         }
-      MUTEX_LOCK (lock);
+      GNUNET_mutex_lock (lock);
       for (i = 0; i < entries1; i++)
         {
           if (FD_ISSET (((store1 + i)->fd), &readSet))
@@ -879,7 +884,7 @@
                 {
                   gp->type = htons (P2P_PROTO_aip_IP);
                   gp->size =
-                    htons (sizeof (MESSAGE_HEADER) + ret -
+                    htons (sizeof (GNUNET_MessageHeader) + ret -
                            sizeof (struct tun_pi));
                   coreAPI->unicast (&((store1 + i)->peer), gp,
                                     EXTREME_PRIORITY, 1);
@@ -907,7 +912,7 @@
        if (timeout.tv_sec < (interval / 2)) {
                for (i = 0; i < entries1; i++) {
                        if (((store1+i)->active) > 0) {
-                               if 
(identity->isBlacklisted(&((store1+i)->peer)), YES) {
+                               if 
(identity->isBlacklisted(&((store1+i)->peer)), GNUNET_YES) {
                                        GE_LOG(ectx, GE_INFO | GE_REQUEST | 
GE_USER, _("RFC4193 --- whitelist of peer %x\n"),
                                                
(store1+i)->peer.hashPubKey.bits[0]);
                                        
identity->whitelistHost(&((store1+i)->peer));
@@ -919,25 +924,25 @@
     }
   GE_LOG (ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
           _("RFC4193 Thread exiting\n"));
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return NULL;
 }
 
 /**
- * Pass IP packet to tap. Which tap depends on what the PeerIdentity is.
+ * Pass IP packet to tap. Which tap depends on what the GNUNET_PeerIdentity is.
  * If we've not seen the peer before, create a new TAP and tell our thread 
about it?
  * else scan the array of TAPS and copy the message into it.
  *
- * Mainly this routine exchanges the MESSAGE_HEADER on incoming ipv6 packets
+ * Mainly this routine exchanges the GNUNET_MessageHeader on incoming ipv6 
packets
  * for a TUN/TAP header for writing it to TUNTAP.
  */
-static int handlep2pMSG (const PeerIdentity * sender,
-                         const MESSAGE_HEADER * gp)
+static int handlep2pMSG (const GNUNET_PeerIdentity * sender,
+                         const GNUNET_MessageHeader * gp)
 {
   int i = 0, fd;
   char loginfo[100];
 
-  MESSAGE_HEADER *rgp = NULL;
+  GNUNET_MessageHeader *rgp = NULL;
   char frame[IP_FRAME + sizeof (struct tun_pi)];
   const struct ip6_hdr *fp = (struct ip6_hdr *) (gp + 1);
   struct ip6_hdr *new_fp =
@@ -966,137 +971,140 @@
             {
               GE_LOG (ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
                       _("VPN IP src not anonymous. drop..\n"));
-              return OK;
+              return GNUNET_OK;
             }
           if (ntohs (fp->ip6_dst.s6_addr16[0]) < 0xFD00)
             {
               GE_LOG (ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
                       _("VPN IP not anonymous, drop.\n"));
-              return OK;
+              return GNUNET_OK;
             }
           break;
         case 4:
           tp->proto = htons (ETH_P_IP);
           GE_LOG (ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
                   _("VPN Received, not anonymous, drop.\n"));
-          return OK;
+          return GNUNET_OK;
         default:
           GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
                   _("VPN Received unknown IP version %d...\n"),
                   ((struct iphdr *) fp)->version);
-          return OK;
+          return GNUNET_OK;
         }
 
       ipinfo (loginfo, fp);
 
       /* do packet memcpy outside of mutex for speed */
-      memcpy (new_fp, fp, ntohs (gp->size) - sizeof (MESSAGE_HEADER));
+      memcpy (new_fp, fp, ntohs (gp->size) - sizeof (GNUNET_MessageHeader));
 
-      MUTEX_LOCK (lock);
+      GNUNET_mutex_lock (lock);
       VLOG _("<- GNUnet(%d) : %s\n"),
-        ntohs (gp->size) - sizeof (MESSAGE_HEADER), loginfo);
+        ntohs (gp->size) - sizeof (GNUNET_MessageHeader), loginfo);
       for (i = 0; i < entries1; i++)
         {
           if (isEqual (sender, &((store1 + i)->peer)))
             {
               fd = ((store1 + i)->fd);
 
-              (store1 + i)->active = YES;
+              (store1 + i)->active = GNUNET_YES;
 
               /* We are only allowed one call to write() per packet.
                * We need to write packet and packetinfo together in one go.
                */
               write (fd, tp,
                      ntohs (gp->size) + sizeof (struct tun_pi) -
-                     sizeof (MESSAGE_HEADER));
+                     sizeof (GNUNET_MessageHeader));
               coreAPI->preferTrafficFrom (&((store1 + i)->peer), 1000);
-              MUTEX_UNLOCK (lock);
-              return OK;
+              GNUNET_mutex_unlock (lock);
+              return GNUNET_OK;
             }
         }
       /* do not normally get here... but checkensure so any future packets 
could be routed... */
       checkensure_peer (sender, NULL);
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       GE_LOG (ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
               _
               ("Could not write the tunnelled IP to the OS... Did to setup a 
tunnel?\n"));
-      return OK;
+      return GNUNET_OK;
     case p2p_PROTO_PONG:
-      MUTEX_LOCK (lock);
+      GNUNET_mutex_lock (lock);
       checkensure_peer (sender, NULL);
-      MUTEX_UNLOCK (lock);
-      return OK;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_OK;
     case P2P_PROTO_hangup:
-      MUTEX_LOCK (lock);
+      GNUNET_mutex_lock (lock);
       for (i = 0; i < entries1; i++)
         {
           if ((((store1 + i)->fd) > 0) &&
               isEqual (sender, &((store1 + i)->peer)))
             {
-              (store1 + i)->active = NO;
+              (store1 + i)->active = GNUNET_NO;
             }
         }
-      MUTEX_UNLOCK (lock);
-      return OK;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_OK;
     case P2P_PROTO_aip_GETROUTE:
         /** peer wants an entry from our routing table */
       VLOG _("Receive route request\n"));
-      if (ntohs (gp->size) == (sizeof (MESSAGE_HEADER) + sizeof (int)))
+      if (ntohs (gp->size) == (sizeof (GNUNET_MessageHeader) + sizeof (int)))
         {
           i = ntohl (*((int *) fp));
-          MUTEX_LOCK (lock);
+          GNUNET_mutex_lock (lock);
           if (i < realised_entries)
             {
               VLOG _("Prepare route announcement level %d\n"), i);
-              rgp = MALLOC (sizeof (MESSAGE_HEADER) + sizeof (transit_route));
+              rgp =
+                GNUNET_malloc (sizeof (GNUNET_MessageHeader) +
+                               sizeof (transit_route));
               if (rgp == NULL)
                 {
-                  MUTEX_UNLOCK (lock);
-                  return OK;
+                  GNUNET_mutex_unlock (lock);
+                  return GNUNET_OK;
                 }
               rgp->size =
-                htons (sizeof (MESSAGE_HEADER) + sizeof (transit_route));
+                htons (sizeof (GNUNET_MessageHeader) +
+                       sizeof (transit_route));
               rgp->type = htons (P2P_PROTO_aip_ROUTE);
               ((transit_route *) (rgp + 1))->owner =
                 (realised_store + i)->owner;
               ((transit_route *) (rgp + 1))->hops =
                 htonl ((realised_store + i)->hops);
-              MUTEX_UNLOCK (lock);
+              GNUNET_mutex_unlock (lock);
               VLOG _("Send route announcement %d with route announce\n"), i);
               /* it must be delivered if possible, but it can wait longer than 
IP */
               coreAPI->unicast (sender, rgp, EXTREME_PRIORITY, 15);
-              FREE (rgp);
-              return OK;
+              GNUNET_free (rgp);
+              return GNUNET_OK;
             }
           VLOG _("Send outside table info %d\n"), i);
-          rgp = MALLOC (sizeof (MESSAGE_HEADER) + sizeof (int));
+          rgp = GNUNET_malloc (sizeof (GNUNET_MessageHeader) + sizeof (int));
           if (rgp == NULL)
             {
-              MUTEX_UNLOCK (lock);
-              return OK;
+              GNUNET_mutex_unlock (lock);
+              return GNUNET_OK;
             }
-          rgp->size = htons (sizeof (MESSAGE_HEADER) + sizeof (int));
+          rgp->size = htons (sizeof (GNUNET_MessageHeader) + sizeof (int));
           rgp->type = htons (P2P_PROTO_aip_ROUTES);
           *((int *) (rgp + 1)) = htonl (realised_entries);
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           coreAPI->unicast (sender, rgp, EXTREME_PRIORITY, 15);
-          FREE (rgp);
-          return OK;
+          GNUNET_free (rgp);
+          return GNUNET_OK;
         }
-      return OK;
+      return GNUNET_OK;
     case P2P_PROTO_aip_ROUTE:
       VLOG _("Receive route announce.\n"));
         /** peer sent us a route, insert it into routing table, then req next 
entry */
       if (ntohs (gp->size) ==
-          (sizeof (MESSAGE_HEADER) + sizeof (transit_route)))
+          (sizeof (GNUNET_MessageHeader) + sizeof (transit_route)))
         {
-          MUTEX_LOCK (lock);
+          GNUNET_mutex_lock (lock);
           VLOG _("Going to try insert route into local table.\n"));
           for (i = 0; i < entries1; i++)
             {
               if (isEqual (sender, &((store1 + i)->peer)))
                 {
-                  (store1 + i)->active = YES;
+                  (store1 + i)->active = GNUNET_YES;
                   VLOG _("Inserting with hops %d\n"),
                     ntohl (((transit_route *) (gp + 1))->hops));
                   add_route (&(((transit_route *) (gp + 1))->owner),
@@ -1105,38 +1113,40 @@
                   if ((store1 + i)->route_entry < GNUNET_VIEW_LIMIT)
                     {
                       (store1 + i)->route_entry++;
-                      rgp = MALLOC (sizeof (MESSAGE_HEADER) + sizeof (int));
+                      rgp =
+                        GNUNET_malloc (sizeof (GNUNET_MessageHeader) +
+                                       sizeof (int));
                       if (rgp == NULL)
                         {
-                          MUTEX_UNLOCK (lock);
-                          return OK;
+                          GNUNET_mutex_unlock (lock);
+                          return GNUNET_OK;
                         }
                       rgp->type = htons (P2P_PROTO_aip_GETROUTE);
                       rgp->size =
-                        htons (sizeof (MESSAGE_HEADER) + sizeof (int));
+                        htons (sizeof (GNUNET_MessageHeader) + sizeof (int));
                       *((int *) (rgp + 1)) =
                         htonl ((store1 + i)->route_entry);
                       VLOG _("Request level %d from peer %d\n"),
                         (store1 + i)->route_entry, i);
                       coreAPI->unicast (&((store1 + i)->peer), rgp,
                                         EXTREME_PRIORITY, 60);
-                      FREE (rgp);
+                      GNUNET_free (rgp);
                     }
                   break;
                 }
             }
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
         }
-      return OK;
+      return GNUNET_OK;
     case P2P_PROTO_aip_ROUTES:
-      if (ntohs (gp->size) == (sizeof (MESSAGE_HEADER) + sizeof (int)))
+      if (ntohs (gp->size) == (sizeof (GNUNET_MessageHeader) + sizeof (int)))
         {
           /* if this is the last route message, we do route realisation
            * that is, insert the routes into the operating system.
            */
           VLOG _("Receive table limit on peer reached %d\n"),
             ntohl (*((int *) fp)));
-/*             MUTEX_LOCK(lock);
+/*             GNUNET_mutex_lock(lock);
                for (i = 0; i < entries1; i++) {
                        if (isEqual(sender, &((store1+i)->peer))) {
                                VLOG _("Storing table limit %d for peer %d\n"), 
ntohl( *((int*)fp)), i );
@@ -1144,11 +1154,11 @@
                                break;
                        }
                }
-               MUTEX_UNLOCK(lock);
+               GNUNET_mutex_unlock(lock);
 */ }
-      return OK;
+      return GNUNET_OK;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /* here we copy the prototype route table we are collecting from peers to the 
actual
@@ -1157,12 +1167,12 @@
 static void realise (struct ClientHandle *c)
 {
   int i, j, found;
-  PeerIdentity id;
+  GNUNET_PeerIdentity id;
   int reqcapacity;
   route_info *reqstore;
   struct in6_rtmsg rt;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   /* make sure realised table can take the new routes - if it wont, abort now! 
*/
   GE_LOG (ectx, GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
           _("realise alloc ram\n"));
@@ -1171,12 +1181,12 @@
       reqcapacity = sizeof (route_info) * route_entries;
       if (reqcapacity > realised_capacity)
         {
-          reqstore = REALLOC (realised_store, reqcapacity);
+          reqstore = GNUNET_realloc (realised_store, reqcapacity);
           if (reqstore == NULL)
             {
               cprintf (c, CS_PROTO_VPN_REPLY,
                        "I cannot up the ram for realised routes.\n");
-              MUTEX_UNLOCK (lock);
+              GNUNET_mutex_unlock (lock);
               return;
             }
           realised_store = reqstore;
@@ -1293,7 +1303,7 @@
   realised_entries = route_entries;
   memcpy (realised_store, route_store, sizeof (route_info) * route_entries);
 
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 static void add_client (struct ClientHandle *c)
@@ -1313,7 +1323,7 @@
   rcapacity = clients_entries * sizeof (struct ClientHandle *);
   if (rcapacity > clients_capacity)
     {
-      rstore = REALLOC (clients_store, rcapacity);
+      rstore = GNUNET_realloc (clients_store, rcapacity);
       if (rstore == NULL)
         {
           clients_entries--;
@@ -1345,45 +1355,46 @@
 }
 
 /** The console client is used to admin/debug vpn */
-static int csHandle (struct ClientHandle *c, const MESSAGE_HEADER * message)
+static int csHandle (struct ClientHandle *c,
+                     const GNUNET_MessageHeader * message)
 {
-  MESSAGE_HEADER *rgp = NULL;
+  GNUNET_MessageHeader *rgp = NULL;
   int i;
-  PeerIdentity id;
-  int parameter = ntohs (message->size) - sizeof (MESSAGE_HEADER);
+  GNUNET_PeerIdentity id;
+  int parameter = ntohs (message->size) - sizeof (GNUNET_MessageHeader);
   char *ccmd = (char *) (message + 1);
   char *parm;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   add_client (c);
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   /* issued command from client */
   if (ntohs (message->type) == CS_PROTO_VPN_MSG)
     {
       if (ntohs (message->size) == 0)
-        return OK;
+        return GNUNET_OK;
     }
   /*    while ((l < ll) && (*(ccmd+cl) > 32)) cl++; */
 
   if (ntohs (message->type) == CS_PROTO_VPN_DEBUGOFF)
     {
-      MUTEX_LOCK (lock);
+      GNUNET_mutex_lock (lock);
       cdebug = 0;
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       cprintf (c, CS_PROTO_VPN_DEBUGOFF, "LOG NOTHING\n");
-      return OK;
+      return GNUNET_OK;
     }
   if (ntohs (message->type) == CS_PROTO_VPN_DEBUGON)
     {
-      MUTEX_LOCK (lock);
+      GNUNET_mutex_lock (lock);
       cdebug = GE_DEBUG | GE_DEVELOPER | GE_REQUEST;
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       cprintf (c, CS_PROTO_VPN_DEBUGON, "LOG DEBUG\n");
-      return OK;
+      return GNUNET_OK;
     }
   if (ntohs (message->type) == CS_PROTO_VPN_TUNNELS)
     {
-      MUTEX_LOCK (lock);
+      GNUNET_mutex_lock (lock);
       id2ip (c, coreAPI->myIdentity);
       cprintf (c, CS_PROTO_VPN_REPLY, "::/48 This Node\n");
       for (i = 0; i < entries1; i++)
@@ -1395,11 +1406,11 @@
                    (store1 + i)->route_entry);
         }
       cprintf (c, CS_PROTO_VPN_TUNNELS, "%d Tunnels\n", entries1);
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
     }
   if (ntohs (message->type) == CS_PROTO_VPN_ROUTES)
     {
-      MUTEX_LOCK (lock);
+      GNUNET_mutex_lock (lock);
       for (i = 0; i < route_entries; i++)
         {
           identity->getPeerIdentity (&(route_store + i)->owner, &id);
@@ -1416,11 +1427,11 @@
             }
         }
       cprintf (c, CS_PROTO_VPN_ROUTES, "%d Routes\n", route_entries);
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
     }
   if (ntohs (message->type) == CS_PROTO_VPN_REALISED)
     {
-      MUTEX_LOCK (lock);
+      GNUNET_mutex_lock (lock);
       for (i = 0; i < realised_entries; i++)
         {
           identity->getPeerIdentity (&(realised_store + i)->owner, &id);
@@ -1437,7 +1448,7 @@
             }
         }
       cprintf (c, CS_PROTO_VPN_REALISED, "%d Realised\n", realised_entries);
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
     }
   /* add routes in route but not realised to OS
    * delete routes in realised but not route from OS
@@ -1450,38 +1461,38 @@
     }
   if (ntohs (message->type) == CS_PROTO_VPN_RESET)
     {
-      MUTEX_LOCK (lock);
+      GNUNET_mutex_lock (lock);
       init_router ();
       for (i = 0; i < entries1; i++)
         {
           (store1 + i)->route_entry = 0;
           /* lets send it to everyone - expect response only from VPN enabled 
nodes tho :-) */
-/*             if ((store1+i)->active == YES) { */
-          rgp = MALLOC (sizeof (MESSAGE_HEADER) + sizeof (int));
+/*             if ((store1+i)->active == GNUNET_YES) { */
+          rgp = GNUNET_malloc (sizeof (GNUNET_MessageHeader) + sizeof (int));
           if (rgp == NULL)
             {
               break;
             }
           rgp->type = htons (P2P_PROTO_aip_GETROUTE);
-          rgp->size = htons (sizeof (MESSAGE_HEADER) + sizeof (int));
+          rgp->size = htons (sizeof (GNUNET_MessageHeader) + sizeof (int));
           *((int *) (rgp + 1)) = htonl ((store1 + i)->route_entry);
           cprintf (c, CS_PROTO_VPN_REPLY, "Request level %d from peer %d ",
                    (store1 + i)->route_entry, i);
           id2ip (c, &((store1 + i)->peer));
           cprintf (c, CS_PROTO_VPN_REPLY, "\n");
           coreAPI->unicast (&((store1 + i)->peer), rgp, EXTREME_PRIORITY, 60);
-          FREE (rgp);
+          GNUNET_free (rgp);
 /*             }       */
         }
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       cprintf (c, CS_PROTO_VPN_RESET, "Rebuilding routing tables done\n");
     }
   if (ntohs (message->type) == CS_PROTO_VPN_TRUST)
     {
-      MUTEX_LOCK (lock);
+      GNUNET_mutex_lock (lock);
       for (i = 0; i < entries1; i++)
         {
-          if ((store1 + i)->active == YES)
+          if ((store1 + i)->active == GNUNET_YES)
             {
               cprintf (c, CS_PROTO_VPN_REPLY, "Uprating peer ");
               id2ip (c, &(store1 + i)->peer);
@@ -1491,25 +1502,25 @@
         }
       cprintf (c, CS_PROTO_VPN_TRUST,
                "Gave credit to active nodes of %d nodes...\n", entries1);
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
     }
   if (ntohs (message->type) == CS_PROTO_VPN_ADD)
     {
       if (parameter > 0)
         {
-          if ((parm = MALLOC (parameter + 1)) != NULL)
+          if ((parm = GNUNET_malloc (parameter + 1)) != NULL)
             {
               strncpy (parm, ccmd, parameter);
               *(parm + parameter) = 0;
               cprintf (c, CS_PROTO_VPN_REPLY, "Connect ");
-              if (OK == enc2hash (parm, &(id.hashPubKey)))
+              if (GNUNET_OK == GNUNET_enc_to_hash (parm, &(id.hashPubKey)))
                 {
                   id2ip (c, &id);
 
                   /* this does not seem to work, strangeness with threads and 
capabilities?
-                   * MUTEX_LOCK(lock);
+                   * GNUNET_mutex_lock(lock);
                    * checkensure_peer(&id, NULL);
-                   * MUTEX_UNLOCK(lock);
+                   * GNUNET_mutex_unlock(lock);
                    */
 
                   /* get it off the local blacklist */
@@ -1517,15 +1528,15 @@
 
                   switch (session->tryConnect (&id))
                     {
-                    case YES:
+                    case GNUNET_YES:
                       cprintf (c, CS_PROTO_VPN_REPLY,
                                " already connected.\n");
                       break;
-                    case NO:
+                    case GNUNET_NO:
                       cprintf (c, CS_PROTO_VPN_REPLY,
                                " schedule connection.\n");
                       break;
-                    case SYSERR:
+                    case GNUNET_SYSERR:
                       cprintf (c, CS_PROTO_VPN_REPLY, " core refused.\n");
                       break;
                     default:
@@ -1534,14 +1545,14 @@
                     }
 
                   /* req route level 0
-                     rgp = MALLOC(sizeof(MESSAGE_HEADER) + sizeof(int));
+                     rgp = GNUNET_malloc(sizeof(GNUNET_MessageHeader) + 
sizeof(int));
                      if (rgp != NULL) {
                      rgp->type = htons(P2P_PROTO_aip_GETROUTE);
-                     rgp->size = htons(sizeof(MESSAGE_HEADER) + sizeof(int));
+                     rgp->size = htons(sizeof(GNUNET_MessageHeader) + 
sizeof(int));
                      *((int*)(rgp+1)) = 0;
                      coreAPI->unicast(&id,rgp,EXTREME_PRIORITY,4);
                      cprintf(c, " Sent");
-                     FREE(rgp);
+                     GNUNET_free(rgp);
                      } */
 
                   cprintf (c, CS_PROTO_VPN_ADD, "\n");
@@ -1553,7 +1564,7 @@
                            parm);
 
                 }
-              FREE (parm);
+              GNUNET_free (parm);
             }
           else
             {
@@ -1565,14 +1576,14 @@
           cprintf (c, CS_PROTO_VPN_ADD, "Require key for parameter\n");
         }
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 static void clientExitHandler (struct ClientHandle *c)
 {
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   remove_client (c);
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 
@@ -1585,7 +1596,7 @@
   if (ioctlsocket (handle, FIONBIO, &mode == SOCKET_ERROR))
     {
       SetErrnoFromWinsockError (WSAGetLastError ());
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   else
     {
@@ -1604,10 +1615,10 @@
       GE_LOG_STRERROR (ectx,
                        GE_WARNING | GE_USER | GE_ADMIN | GE_IMMEDIATE,
                        "fcntl");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 #endif
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -1623,7 +1634,7 @@
   char *str = "OK\r\n";
 
   ectx = capi->ectx;
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
 
   coreAPI = capi;
 
@@ -1657,44 +1668,58 @@
   /* core calls us to receive messages */
   /* get a PONG = peer is online */
   /* get a HANGUP = peer is offline */
-  if (SYSERR == capi->registerHandler (P2P_PROTO_aip_IP, &handlep2pMSG))
-    return SYSERR;
-  if (SYSERR == capi->registerHandler (P2P_PROTO_aip_GETROUTE, &handlep2pMSG))
-    return SYSERR;
-  if (SYSERR == capi->registerHandler (P2P_PROTO_aip_ROUTE, &handlep2pMSG))
-    return SYSERR;
-  if (SYSERR == capi->registerHandler (P2P_PROTO_aip_ROUTES, &handlep2pMSG))
-    return SYSERR;
-  if (SYSERR == capi->registerHandler (p2p_PROTO_PONG, &handlep2pMSG))
-    return SYSERR;
-  if (SYSERR == capi->registerHandler (P2P_PROTO_hangup, &handlep2pMSG))
-    return SYSERR;
-  if (SYSERR == capi->registerClientExitHandler (&clientExitHandler))
-    return SYSERR;
-  if (SYSERR == capi->registerClientHandler (CS_PROTO_VPN_MSG, &csHandle))
-    return SYSERR;
-  if (SYSERR ==
+  if (GNUNET_SYSERR ==
+      capi->registerHandler (P2P_PROTO_aip_IP, &handlep2pMSG))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerHandler (P2P_PROTO_aip_GETROUTE, &handlep2pMSG))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerHandler (P2P_PROTO_aip_ROUTE, &handlep2pMSG))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerHandler (P2P_PROTO_aip_ROUTES, &handlep2pMSG))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR == capi->registerHandler (p2p_PROTO_PONG, &handlep2pMSG))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerHandler (P2P_PROTO_hangup, &handlep2pMSG))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR == capi->registerClientExitHandler (&clientExitHandler))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerClientHandler (CS_PROTO_VPN_MSG, &csHandle))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
       capi->registerClientHandler (CS_PROTO_VPN_DEBUGOFF, &csHandle))
-    return SYSERR;
-  if (SYSERR == capi->registerClientHandler (CS_PROTO_VPN_DEBUGON, &csHandle))
-    return SYSERR;
-  if (SYSERR == capi->registerClientHandler (CS_PROTO_VPN_TUNNELS, &csHandle))
-    return SYSERR;
-  if (SYSERR == capi->registerClientHandler (CS_PROTO_VPN_ROUTES, &csHandle))
-    return SYSERR;
-  if (SYSERR ==
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerClientHandler (CS_PROTO_VPN_DEBUGON, &csHandle))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerClientHandler (CS_PROTO_VPN_TUNNELS, &csHandle))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerClientHandler (CS_PROTO_VPN_ROUTES, &csHandle))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
       capi->registerClientHandler (CS_PROTO_VPN_REALISED, &csHandle))
-    return SYSERR;
-  if (SYSERR == capi->registerClientHandler (CS_PROTO_VPN_RESET, &csHandle))
-    return SYSERR;
-  if (SYSERR == capi->registerClientHandler (CS_PROTO_VPN_REALISE, &csHandle))
-    return SYSERR;
-  if (SYSERR == capi->registerClientHandler (CS_PROTO_VPN_ADD, &csHandle))
-    return SYSERR;
-  if (SYSERR == capi->registerClientHandler (CS_PROTO_VPN_TRUST, &csHandle))
-    return SYSERR;
-  if (SYSERR == capi->registerClientHandler (CS_PROTO_VPN_REPLY, &csHandle))
-    return SYSERR;
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerClientHandler (CS_PROTO_VPN_RESET, &csHandle))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerClientHandler (CS_PROTO_VPN_REALISE, &csHandle))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerClientHandler (CS_PROTO_VPN_ADD, &csHandle))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerClientHandler (CS_PROTO_VPN_TRUST, &csHandle))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR ==
+      capi->registerClientHandler (CS_PROTO_VPN_REPLY, &csHandle))
+    return GNUNET_SYSERR;
 
   identity = coreAPI->requestService ("identity");
   session = coreAPI->requestService ("session");
@@ -1715,7 +1740,8 @@
    * They may go in the thread that usually monitors the GUI port.
    */
   tunThreadInfo =
-    PTHREAD_CREATE ((PThreadMain) & tunThread, NULL, 128 * 1024);
+    GNUNET_thread_create ((GNUNET_ThreadMainFunction) & tunThread, NULL,
+                          128 * 1024);
 
   /* use capi->unicast to send messages to connected peers */
   GE_ASSERT (capi->ectx,
@@ -1726,7 +1752,7 @@
                                                      _
                                                      ("enables IPv6 over 
GNUnet (incomplete)")));
 
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -1770,7 +1796,7 @@
                        "RFC4193 can not tell thread to exit");
 
   /* wait for it to exit */
-  PTHREAD_JOIN (tunThreadInfo, &returnval);
+  GNUNET_thread_join (tunThreadInfo, &returnval);
   GE_LOG (ectx, GE_INFO | GE_REQUEST | GE_USER,
           _("RFC4193 The tun thread has ended\n"));
 
@@ -1799,11 +1825,11 @@
     {
       entries1 = 0;
       capacity1 = 0;
-      FREE (store1);
+      GNUNET_free (store1);
     }
   close (admin_fd);
 
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   coreAPI = NULL;
 }
 

Modified: GNUnet/src/include/Makefile.am
===================================================================
--- GNUnet/src/include/Makefile.am      2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/include/Makefile.am      2007-11-23 11:51:54 UTC (rev 5742)
@@ -53,7 +53,6 @@
   gnunet_util_boot.h \
   gnunet_util_common.h \
   gnunet_util_config.h \
-  gnunet_util_config_impl.h \
   gnunet_util_containers.h \
   gnunet_util_core.h \
   gnunet_util_cron.h \

Modified: GNUnet/src/include/core.h
===================================================================
--- GNUnet/src/include/core.h   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/include/core.h   2007-11-23 11:51:54 UTC (rev 5742)
@@ -35,7 +35,8 @@
  */
 int initCore (struct GE_Context *ectx,
               struct GC_Configuration *cfg,
-              struct CronManager *cron, struct LoadMonitor *monitor);
+              struct GNUNET_CronManager *cron,
+              struct GNUNET_LoadMonitor *monitor);
 
 /**
  * Shutdown the CORE modules (also shuts down all
@@ -48,12 +49,12 @@
 int releaseService (void *service);
 
 /**
- * @return OK on success, SYSERR if some modules failed to unload
+ * @return GNUNET_OK on success, GNUNET_SYSERR if some modules failed to unload
  */
 int unloadApplicationModules (void);
 
 /**
- * @return OK on success, SYSERR if some modules failed to load
+ * @return GNUNET_OK on success, GNUNET_SYSERR if some modules failed to load
  */
 int loadApplicationModules (void);
 

Modified: GNUnet/src/include/dht.h
===================================================================
--- GNUnet/src/include/dht.h    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/include/dht.h    2007-11-23 11:51:54 UTC (rev 5742)
@@ -52,11 +52,11 @@
 typedef struct
 {
 
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   unsigned int type;            /* nbo */
 
-  HashCode512 key;
+  GNUNET_HashCode key;
 
   unsigned long long expire;    /* nbo */
 
@@ -70,11 +70,11 @@
 typedef struct
 {
 
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   unsigned int type;            /* nbo */
 
-  HashCode512 key;
+  GNUNET_HashCode key;
 
   unsigned long long timeout;   /* nbo */
 

Modified: GNUnet/src/include/ecrs_core.h
===================================================================
--- GNUnet/src/include/ecrs_core.h      2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/include/ecrs_core.h      2007-11-23 11:51:54 UTC (rev 5742)
@@ -34,12 +34,12 @@
 #include "gnunet_datastore_service.h"
 
 /**
- * @brief content hash key
+ * @brief content GNUNET_hash key
  */
 typedef struct
 {
-  HashCode512 key;
-  HashCode512 query;
+  GNUNET_HashCode key;
+  GNUNET_HashCode query;
 } CHK;
 
 /**
@@ -102,14 +102,14 @@
   unsigned int type;
 
   /**
-   * Signature using RSA-key generated from search keyword.
+   * GNUNET_RSA_Signature using RSA-key generated from search keyword.
    */
-  Signature signature;
+  GNUNET_RSA_Signature signature;
 
   /**
    * Key generated (!) from the H(keyword) as the seed!
    */
-  PublicKey keyspace;
+  GNUNET_RSA_PublicKey keyspace;
 
   /* 0-terminated URI here */
 
@@ -128,26 +128,26 @@
   /**
    * RSA signature (from pseudonym controlling the namespace)
    */
-  Signature signature;
+  GNUNET_RSA_Signature signature;
 
   /**
    * Public key of the pseudonym; S = H(subspace);
    */
-  PublicKey subspace;
+  GNUNET_RSA_PublicKey subspace;
 
   /* from here on signed */
 
   /**
    * R = H(N-I)^S, used for routing!
    */
-  HashCode512 identifier;
+  GNUNET_HashCode identifier;
   /* from here on encrypted */
 
   /**
    * Time at which this SBlock was created;
    * in network byte order
    */
-  TIME_T creationTime;
+  GNUNET_Int32Time creationTime;
 
   /**
    * Interval (in seconds) how often the publisher intends to produce
@@ -156,19 +156,19 @@
    * for entries without a fixed update frequency; in network byte
    * order
    */
-  TIME_T updateInterval;
+  GNUNET_Int32Time updateInterval;
 
   /**
    * N, the identifier that will be used for the
    * next revision of this SBlock.
    */
-  HashCode512 nextIdentifier;
+  GNUNET_HashCode nextIdentifier;
 
   /**
    * I, the increment between identifiers (used to enable
    * skipping of blocks by appying multiple increments.
    */
-  HashCode512 identifierIncrement;
+  GNUNET_HashCode identifierIncrement;
 
   /* 0-terminated URI follows here! */
 
@@ -183,27 +183,27 @@
    */
   unsigned int type;
 
-  Signature signature;          /* 256 b */
+  GNUNET_RSA_Signature signature;       /* 256 b */
 
-  PublicKey subspace;           /* S = H(subspace); 264 b */
+  GNUNET_RSA_PublicKey subspace;        /* S = H(subspace); 264 b */
 
   /**
    * Must be all zeros
    */
-  HashCode512 identifier;
+  GNUNET_HashCode identifier;
 
   /* The REST (from here on) is encrypted! */
 
   /**
    * Identifier of the namespace
    */
-  HashCode512 namespace;
+  GNUNET_HashCode namespace;
 
   /**
    * Key of an (optional) root entry into the namespace
    * (use all-zeros for not given).
    */
-  HashCode512 rootEntry;
+  GNUNET_HashCode rootEntry;
 
   /* variable-size Meta-Data follows here! */
 } NBlock;
@@ -236,19 +236,19 @@
  *        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);
 
 /**
  * Get the query that will be used to query for
  * a certain block of data.
  */
 void fileBlockGetQuery (const DBlock * data,
-                        unsigned int len, HashCode512 * query);
+                        unsigned int len, GNUNET_HashCode * query);
 
 
 /**
@@ -256,7 +256,7 @@
  * a certain block of data.
  */
 void fileBlockGetKey (const DBlock * data,
-                      unsigned int len, HashCode512 * key);
+                      unsigned int len, GNUNET_HashCode * key);
 
 /**
  * What is the type of the given block of data?
@@ -270,14 +270,14 @@
  *
  * @param type the type of the encoding
  * @param data the content (encoded)
- * @param verify should the data be verified?  Use NO if
+ * @param verify should the data be verified?  Use GNUNET_NO if
  *         data integrity has been checked before (maybe much faster!)
  * @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);
 
 /**
  * Verify that the given Datum is a valid response
@@ -289,14 +289,14 @@
  * @param knownDatumQuery result of getQueryFor
  * @param keyCount the number of keys in the query
  * @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 * knownDatumQuery,
-                       unsigned int keyCount, const HashCode512 * keys);
+                       const GNUNET_HashCode * knownDatumQuery,
+                       unsigned int keyCount, const GNUNET_HashCode * keys);
 
 #endif

Modified: GNUnet/src/include/fs.h
===================================================================
--- GNUnet/src/include/fs.h     2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/include/fs.h     2007-11-23 11:51:54 UTC (rev 5742)
@@ -36,7 +36,7 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * Priority of the search.
@@ -46,7 +46,7 @@
   /**
    * At what time does the search expire?
    */
-  cron_t expiration;
+  GNUNET_CronTime expiration;
 
   /**
    * Type of the content that we're looking for.
@@ -66,12 +66,12 @@
    * response.  Set to all-zeros if target is not
    * known.
    */
-  PeerIdentity target;
+  GNUNET_PeerIdentity target;
 
   /**
    * What are the queries?
    */
-  HashCode512 query[1];
+  GNUNET_HashCode query[1];
 
 } CS_fs_request_search_MESSAGE;
 
@@ -82,11 +82,11 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   unsigned int anonymityLevel;
 
-  cron_t expirationTime;
+  GNUNET_CronTime expirationTime;
 
 } CS_fs_reply_content_MESSAGE;
 
@@ -98,7 +98,7 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * Priority for the on-demand encoded entry.
@@ -108,7 +108,7 @@
   /**
    * At what time does the entry expire?
    */
-  cron_t expiration;
+  GNUNET_CronTime expiration;
 
   /**
    * What are the anonymity requirements for this content?
@@ -126,15 +126,15 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   unsigned int reserved;
 
   /**
-   * What is the hash of the file that contains
+   * What is the GNUNET_hash of the file that contains
    * this block?
    */
-  HashCode512 fileId;
+  GNUNET_HashCode fileId;
 
 } CS_fs_request_init_index_MESSAGE;
 
@@ -145,7 +145,7 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * Priority for the on-demand encoded entry.
@@ -155,7 +155,7 @@
   /**
    * At what time does the entry expire?
    */
-  cron_t expiration;
+  GNUNET_CronTime expiration;
 
   /**
    * At what offset in the plaintext file is
@@ -164,11 +164,11 @@
   unsigned long long fileOffset;
 
   /**
-   * What is the hash of the file that contains
+   * What is the GNUNET_hash of the file that contains
    * this block?  Used by gnunetd for the name
    * of the file in the on-demand datastore.
    */
-  HashCode512 fileId;
+  GNUNET_HashCode fileId;
 
   /**
    * What are the anonymity requirements for this content?
@@ -185,7 +185,7 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
 } CS_fs_request_delete_MESSAGE;
 
@@ -195,7 +195,7 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * Size of each block of the file.
@@ -203,10 +203,10 @@
   unsigned int blocksize;
 
   /**
-   * What is the hash of the file that should be
+   * What is the GNUNET_hash of the file that should be
    * unindexed?
    */
-  HashCode512 fileId;
+  GNUNET_HashCode fileId;
 
 } CS_fs_request_unindex_MESSAGE;
 
@@ -215,15 +215,15 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   unsigned int reserved;
 
   /**
-   * What is the hash of the file that should be
+   * What is the GNUNET_hash of the file that should be
    * unindexed?
    */
-  HashCode512 fileId;
+  GNUNET_HashCode fileId;
 
 } RequestTestindex;
 

Modified: GNUnet/src/include/gettext.h
===================================================================
--- GNUnet/src/include/gettext.h        2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/include/gettext.h        2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,7 +32,7 @@
    later inclusions of <locale.h> a NOP.  We don't include <libintl.h>
    as well because people using "gettext.h" will not include <libintl.h>,
    and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
-   is OK.  */
+   is GNUNET_OK.  */
 #if defined(__sun)
 # include <locale.h>
 #endif
@@ -51,7 +51,7 @@
     ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
 # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
     ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
-/* slight modification here to avoid warnings: generate NO code,
+/* slight modification here to avoid warnings: generate GNUNET_NO code,
    not even the cast... */
 # define textdomain(Domainname)
 # define bindtextdomain(Domainname, Dirname)

Modified: GNUnet/src/include/gnunet_blockstore.h
===================================================================
--- GNUnet/src/include/gnunet_blockstore.h      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_blockstore.h      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -56,9 +56,9 @@
  * @param key the current key
  * @param value the current value
  * @param cls argument passed for context (closure)
- * @return OK to continue with iteration, SYSERR to abort
+ * @return GNUNET_OK to continue with iteration, GNUNET_SYSERR to abort
  */
-typedef int (*DataProcessor) (const HashCode512 * key,
+typedef int (*DataProcessor) (const GNUNET_HashCode * key,
                               const DataContainer * value, void *cls);
 
 /**
@@ -88,7 +88,7 @@
   /**
    * Do a quick test if we MAY have the content.
    */
-  int (*fast_get) (const HashCode512 * key);
+  int (*fast_get) (const GNUNET_HashCode * key);
 
   /**
    * Lookup an item in the datastore.
@@ -99,13 +99,13 @@
    * @param keys to look up
    * @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
    */
   int (*get) (void *closure,
               unsigned int type,
               unsigned int prio,
               unsigned int keyCount,
-              const HashCode512 * keys,
+              const GNUNET_HashCode * keys,
               DataProcessor resultCallback, void *resCallbackClosure);
 
   /**
@@ -114,12 +114,12 @@
    * @param key the key of the item, NULL if not known
    *        (client should try to figure it out)
    * @param value the value to store
-   * @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
    */
   int (*put) (void *closure,
-              const HashCode512 * key,
+              const GNUNET_HashCode * key,
               const DataContainer * value, unsigned int prio);
 
   /**
@@ -127,17 +127,17 @@
    *
    * @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)
    */
   int (*del) (void *closure,
-              const HashCode512 * key, const DataContainer * value);
+              const GNUNET_HashCode * key, const DataContainer * value);
 
   /**
    * Iterate over all keys in the local datastore
    *
    * @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
    */
   int (*iterate) (void *closure, DataProcessor processor, void *cls);
 

Modified: GNUnet/src/include/gnunet_bootstrap_service.h
===================================================================
--- GNUnet/src/include/gnunet_bootstrap_service.h       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/include/gnunet_bootstrap_service.h       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -41,11 +41,11 @@
  * Definition of a callback function that processes
  * hello messages generated by the bootstrap API.
  */
-typedef void (*bootstrap_hello_callback) (const P2P_hello_MESSAGE * helo,
+typedef void (*bootstrap_hello_callback) (const GNUNET_MessageHello * helo,
                                           void *arg);
 
 /**
- * @return YES to continue, NO to abort
+ * @return GNUNET_YES to continue, GNUNET_NO to abort
  */
 typedef int (*bootstrap_terminate_callback) (void *arg);
 

Modified: GNUnet/src/include/gnunet_chat_lib.h
===================================================================
--- GNUnet/src/include/gnunet_chat_lib.h        2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_chat_lib.h        2007-11-23 11:51:54 UTC (rev 
5742)
@@ -75,7 +75,7 @@
   GNUNET_CHAT_MSG_OFF_THE_RECORD = 8,
 
   /**
-   * Require signed acknowledgement before 
+   * Require signed acknowledgement before
    * completing delivery (and of course, only
    * acknowledge if delivery is guaranteed).
    */
@@ -86,18 +86,18 @@
 /**
  * Callback function to iterate over rooms.
  *
- * @return OK to continue, SYSERR to abort iteration
+ * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
  */
-typedef int (*GNUNET_CHAT_Room_Iterator) (const char *room,
+typedef int (*GNUNET_CHAT_RoomIterator) (const char *room,
                                           const char *topic, void *cls);
 
 /**
  * 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);
 
 
 /**
@@ -117,33 +117,35 @@
  *        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
  */
-typedef int (*GNUNET_CHAT_Message_Callback) (void *cls,
+typedef int (*GNUNET_CHAT_MessageCallback) (void *cls,
                                              struct GNUNET_CHAT_Room * room,
                                              const char *senderNick,
                                              const char *message,
-                                             cron_t timestamp,
+                                             GNUNET_CronTime timestamp,
                                              GNUNET_CHAT_MSG_OPTIONS options);
 
 /**
- * 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
+                                                GNUNET_CHAT_MessageCallback
                                                 callback, void *cls);
 
 /**
@@ -160,54 +162,56 @@
  * @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
  */
-typedef int (*GNUNET_CHAT_Message_Confirmation) (void *cls,
+typedef int (*GNUNET_CHAT_MessageConfirmation) (void *cls,
                                                  struct GNUNET_CHAT_Room *
                                                  room,
                                                  const char *receiverNick,
-                                                 const PublicKey *
+                                                 const GNUNET_RSA_PublicKey *
                                                  receiverKey,
                                                  const char *message,
-                                                 cron_t timestamp,
+                                                 GNUNET_CronTime timestamp,
                                                  GNUNET_CHAT_MSG_OPTIONS
                                                  options, int response,
-                                                 const Signature * receipt);
+                                                 const GNUNET_RSA_Signature *
+                                                 receipt);
 
 
 /**
  * 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);
 
 
 /**
  * Callback function to iterate over room members.
  */
-typedef int (*GNUNET_CHAT_Member_Iterator) (const char *nickname,
-                                            const PublicKey * owner,
-                                            const char *memberInfo,
-                                            cron_t lastConfirmed, void *cls);
+typedef int (*GNUNET_CHAT_MemberIterator) (const char *nickname,
+                                            const GNUNET_RSA_PublicKey *
+                                            owner, const char *memberInfo,
+                                            GNUNET_CronTime lastConfirmed,
+                                            void *cls);
 
 /**
  * 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);
 
 
 

Modified: GNUnet/src/include/gnunet_collection_lib.h
===================================================================
--- GNUnet/src/include/gnunet_collection_lib.h  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_collection_lib.h  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -54,13 +54,13 @@
  */
 int CO_startCollection (unsigned int anonymityLevel,
                         unsigned int priority,
-                        TIME_T updateInterval,
+                        GNUNET_Int32Time updateInterval,
                         const char *name, const struct ECRS_MetaData *meta);
 
 /**
  * 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 (void);
 
@@ -72,7 +72,7 @@
 char *CO_getCollection (void);
 
 /**
- * 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.

Modified: GNUnet/src/include/gnunet_core.h
===================================================================
--- GNUnet/src/include/gnunet_core.h    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/include/gnunet_core.h    2007-11-23 11:51:54 UTC (rev 5742)
@@ -81,7 +81,7 @@
 
   const char **tokens;
 
-  PeerIdentity peer;
+  GNUNET_PeerIdentity peer;
 
   unsigned int token_count;
 
@@ -98,7 +98,7 @@
  * Type of a handler for messages from clients.
  */
 typedef int (*CSHandler) (struct ClientHandle * client,
-                          const MESSAGE_HEADER * message);
+                          const GNUNET_MessageHeader * message);
 
 /**
  * Method called whenever a given client disconnects.
@@ -108,23 +108,25 @@
 /**
  * Type of a handler for some message type.
  */
-typedef int (*MessagePartHandler) (const PeerIdentity * sender,
-                                   const MESSAGE_HEADER * message);
+typedef int (*MessagePartHandler) (const GNUNET_PeerIdentity * sender,
+                                   const GNUNET_MessageHeader * message);
 
 /**
  * Type of a handler for plaintext messages.  Since we cannot
  * be certain about the sender's identity, it is NOT passed to
  * the callback.
  */
-typedef int (*PlaintextMessagePartHandler) (const PeerIdentity * sender,
-                                            const MESSAGE_HEADER * message,
-                                            TSession * session);
+typedef int (*PlaintextMessagePartHandler) (const GNUNET_PeerIdentity *
+                                            sender,
+                                            const GNUNET_MessageHeader *
+                                            message, TSession * session);
 
 /**
  * Type of a handler for some message type.
  * @param identity the id of the node
  */
-typedef void (*PerNodeCallback) (const PeerIdentity * identity, void *data);
+typedef void (*PerNodeCallback) (const GNUNET_PeerIdentity * identity,
+                                 void *data);
 
 /**
  * Type of a send callback to fill up buffers.
@@ -136,8 +138,8 @@
  * @return the number of bytes written to
  *   that buffer (must be a positive number).
  */
-typedef unsigned int (*BufferFillCallback) (const PeerIdentity * receiver,
-                                            void *position,
+typedef unsigned int (*BufferFillCallback) (const GNUNET_PeerIdentity *
+                                            receiver, void *position,
                                             unsigned int padding);
 
 /**
@@ -150,7 +152,7 @@
  * @param len the expected number of bytes to write to buf,
  *   note that this can be 0 to indicate that the core wants
  *   to discard the message!
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 typedef int (*BuildMessageCallback) (void *buf,
                                      void *closure, unsigned short len);
@@ -158,14 +160,14 @@
 /**
  * Send a message to the client identified by the handle.  Note that
  * the core will typically buffer these messages as much as possible
- * and only return SYSERR if it runs out of buffers.  Returning OK
+ * and only return GNUNET_SYSERR if it runs out of buffers.  Returning 
GNUNET_OK
  * on the other hand does NOT confirm delivery since the actual
  * transfer happens asynchronously.
  *
- * @param force YES if this message MUST be queued
+ * @param force GNUNET_YES if this message MUST be queued
  */
 typedef int (*SendToClientCallback) (struct ClientHandle * handle,
-                                     const MESSAGE_HEADER * message,
+                                     const GNUNET_MessageHeader * message,
                                      int force);
 
 /**
@@ -183,7 +185,7 @@
   /**
    * The identity of the local node.
    */
-  PeerIdentity *myIdentity;
+  GNUNET_PeerIdentity *myIdentity;
 
   /**
    * System error context
@@ -198,12 +200,12 @@
   /**
    * System load monitor
    */
-  struct LoadMonitor *load_monitor;
+  struct GNUNET_LoadMonitor *load_monitor;
 
   /**
    * System cron Manager.
    */
-  struct CronManager *cron;
+  struct GNUNET_CronManager *cron;
 
 
   /* ****************** services and applications **************** */
@@ -216,7 +218,7 @@
    * are loaded or unloaded inside the module initialization or
    * shutdown code.
    *
-   * @return OK on success, SYSERR on error
+   * @return GNUNET_OK on success, GNUNET_SYSERR on error
    */
   int (*loadApplicationModule) (const char *name);
 
@@ -228,7 +230,7 @@
    * are loaded or unloaded inside the module initialization or
    * shutdown code.
    *
-   * @return OK on success, SYSERR on error
+   * @return GNUNET_OK on success, GNUNET_SYSERR on error
    */
   int (*unloadApplicationModule) (const char *name);
 
@@ -250,7 +252,7 @@
    * modules are loaded or unloaded inside the module initialization
    * or shutdown code.
    *
-   * @return OK if service was successfully released, SYSERR on error
+   * @return GNUNET_OK if service was successfully released, GNUNET_SYSERR on 
error
    */
   int (*releaseService) (void *service);
 
@@ -266,7 +268,7 @@
    *
    * @param session the transport session
    * @param msg the message to transmit, should contain MESSAGE_HEADERs
-   * @return OK on success, SYSERR on failure
+   * @return GNUNET_OK on success, GNUNET_SYSERR on failure
    */
   int (*sendPlaintext) (TSession * session,
                         const char *msg, unsigned int size);
@@ -280,8 +282,8 @@
    * @param importance how important is the message?
    * @param maxdelay how long can the message be delayed?
    */
-  void (*unicast) (const PeerIdentity * receiver,
-                   const MESSAGE_HEADER * msg,
+  void (*unicast) (const GNUNET_PeerIdentity * receiver,
+                   const GNUNET_MessageHeader * msg,
                    unsigned int importance, unsigned int maxdelay);
 
   /**
@@ -294,7 +296,7 @@
    * @param importance how important is the message?
    * @param maxdelay how long can the message wait?
    */
-  void (*unicastCallback) (const PeerIdentity * receiver,
+  void (*unicastCallback) (const GNUNET_PeerIdentity * receiver,
                            BuildMessageCallback callback,
                            void *closure,
                            unsigned short len,
@@ -328,14 +330,14 @@
    *   the message, padding is the number of bytes left in that buffer.
    *   The callback method must return the number of bytes written to
    *   that buffer (must be a positive number).
-   * @return OK if the handler was registered, SYSERR on error
+   * @return GNUNET_OK if the handler was registered, GNUNET_SYSERR on error
    */
   int (*registerSendCallback) (const unsigned int minimumPadding,
                                BufferFillCallback callback);
 
   /**
    * Unregister a handler that was registered with registerSendCallback.
-   * @return OK if the handler was removed, SYSERR on error
+   * @return GNUNET_OK if the handler was removed, GNUNET_SYSERR on error
    */
   int (*unregisterSendCallback) (const unsigned int minimumPadding,
                                  BufferFillCallback callback);
@@ -346,7 +348,7 @@
    *
    * @param callback the method to call for each
    *        P2P message part that is transmitted
-   * @return OK on success, SYSERR if there is a problem
+   * @return GNUNET_OK on success, GNUNET_SYSERR if there is a problem
    */
   int (*registerSendNotify) (MessagePartHandler callback);
 
@@ -356,7 +358,7 @@
    *
    * @param callback the method to call for each
    *        P2P message part that is transmitted
-   * @return OK on success, SYSERR if there is a problem
+   * @return GNUNET_OK on success, GNUNET_SYSERR if there is a problem
    */
   int (*unregisterSendNotify) (MessagePartHandler callback);
 
@@ -369,7 +371,7 @@
    * @param type the message type
    * @param callback the method to call if a message of
    *        that type is received
-   * @return OK on success, SYSERR if there is already a
+   * @return GNUNET_OK on success, GNUNET_SYSERR if there is already a
    *         handler for that type
    */
   int (*registerHandler) (unsigned short type, MessagePartHandler callback);
@@ -380,7 +382,7 @@
    * @param type the message type
    * @param callback the method to call if a message of
    *        that type is received
-   * @return OK on success, SYSERR if there is a different
+   * @return GNUNET_OK on success, GNUNET_SYSERR if there is a different
    *         handler for that type
    */
   int (*unregisterHandler) (unsigned short type, MessagePartHandler callback);
@@ -392,9 +394,9 @@
    *                    1 for ciphertext P2P,
    *                    2 for either plaintext or ciphertext P2P,
    *                    3 for client-server
-   *        NO for ciphertext handlers, SYSERR for either
+   *        GNUNET_NO for ciphertext handlers, GNUNET_SYSERR for either
    * @return number of handlers registered, 0 for none,
-   *        SYSERR for invalid value of handlerType
+   *        GNUNET_SYSERR for invalid value of handlerType
    */
   int (*isHandlerRegistered) (unsigned short type,
                               unsigned short handlerType);
@@ -405,7 +407,7 @@
    * @param type the message type
    * @param callback the method to call if a message of
    *        that type is received
-   * @return OK on success, SYSERR if there is already a
+   * @return GNUNET_OK on success, GNUNET_SYSERR if there is already a
    *         handler for that type
    */
   int (*registerPlaintextHandler) (unsigned short type,
@@ -418,7 +420,7 @@
    * @param type the message type
    * @param callback the method to call if a message of
    *        that type is received
-   * @return OK on success, SYSERR if there is a different
+   * @return GNUNET_OK on success, GNUNET_SYSERR if there is a different
    *         handler for that type
    */
   int (*unregisterPlaintextHandler) (unsigned short type,
@@ -435,7 +437,8 @@
    * use it after this call.  If the core does not want/need
    * the session, it will also be disconnected.
    */
-  void (*offerTSessionFor) (const PeerIdentity * peer, TSession * session);
+  void (*offerTSessionFor) (const GNUNET_PeerIdentity * peer,
+                            TSession * session);
 
   /**
    * Assign a session key for traffic from or to a given peer.
@@ -444,12 +447,12 @@
    *
    * @param key the sessionkey,
    * @param peer the other peer,
-   * @param forSending NO if it is the key for receiving,
-   *                   YES if it is the key for sending
+   * @param forSending GNUNET_NO if it is the key for receiving,
+   *                   GNUNET_YES if it is the key for sending
    */
-  void (*assignSessionKey) (const SESSIONKEY * key,
-                            const PeerIdentity * peer,
-                            TIME_T age, int forSending);
+  void (*assignSessionKey) (const GNUNET_AES_SessionKey * key,
+                            const GNUNET_PeerIdentity * peer,
+                            GNUNET_Int32Time age, int forSending);
 
   /**
    * Obtain the session key used for traffic from or to a given peer.
@@ -457,14 +460,14 @@
    * @param key the sessionkey (set)
    * @param age the age of the key (set)
    * @param peer the other peer,
-   * @param forSending NO if it is the key for receiving,
-   *                   YES if it is the key for sending
-   * @return SYSERR if no sessionkey is known to the core,
-   *         OK if the sessionkey was set.
+   * @param forSending GNUNET_NO if it is the key for receiving,
+   *                   GNUNET_YES if it is the key for sending
+   * @return GNUNET_SYSERR if no sessionkey is known to the core,
+   *         GNUNET_OK if the sessionkey was set.
    */
-  int (*getCurrentSessionKey) (const PeerIdentity * peer,
-                               SESSIONKEY * key,
-                               TIME_T * age, int forSending);
+  int (*getCurrentSessionKey) (const GNUNET_PeerIdentity * peer,
+                               GNUNET_AES_SessionKey * key,
+                               GNUNET_Int32Time * age, int forSending);
 
   /**
    * We have confirmed that the other peer is communicating with us,
@@ -473,7 +476,7 @@
    * this could happen if in between the core has discarded
    * the session information).
    */
-  void (*confirmSessionUp) (const PeerIdentity * peer);
+  void (*confirmSessionUp) (const GNUNET_PeerIdentity * peer);
 
   /**
    * Increase the preference for traffic from some other peer.
@@ -481,7 +484,8 @@
    * @param node the identity of the other peer
    * @param preference how much should the traffic preference be increased?
    */
-  void (*preferTrafficFrom) (const PeerIdentity * node, double preference);
+  void (*preferTrafficFrom) (const GNUNET_PeerIdentity * node,
+                             double preference);
 
   /**
    * Query how much bandwidth is availabe FROM the given node to
@@ -489,10 +493,10 @@
    *
    * @param bpm set to the bandwidth
    * @param last_seen set to last time peer was confirmed up
-   * @return OK on success, SYSERR if if we are NOT connected
+   * @return GNUNET_OK on success, GNUNET_SYSERR if if we are NOT connected
    */
-  int (*queryPeerStatus) (const PeerIdentity * node,
-                          unsigned int *bpm, cron_t * last_seen);
+  int (*queryPeerStatus) (const GNUNET_PeerIdentity * node,
+                          unsigned int *bpm, GNUNET_CronTime * last_seen);
 
   /**
    * Disconnect a particular peer. Sends a HANGUP message to the other
@@ -500,14 +504,14 @@
    *
    * @param peer  the peer to disconnect
    */
-  void (*disconnectFromPeer) (const PeerIdentity * peer);
+  void (*disconnectFromPeer) (const GNUNET_PeerIdentity * peer);
 
   /* **************** Client-server interaction **************** */
 
   /**
    * Send a message to the client identified by the handle.  Note that
    * the core will typically buffer these messages as much as possible
-   * and only return SYSERR if it runs out of buffers.  Returning OK
+   * and only return GNUNET_SYSERR if it runs out of buffers.  Returning 
GNUNET_OK
    * on the other hand does NOT confirm delivery since the actual
    * transfer happens asynchronously.
    */
@@ -516,7 +520,7 @@
   /**
    * Send a message to the client identified by the handle.  Note that
    * the core will typically buffer these messages as much as possible
-   * and only return SYSERR if it runs out of buffers.  Returning OK
+   * and only return GNUNET_SYSERR if it runs out of buffers.  Returning 
GNUNET_OK
    * on the other hand does NOT confirm delivery since the actual
    * transfer happens asynchronously.
    */
@@ -528,7 +532,7 @@
    * @param type the message type
    * @param callback the method to call if a message of
    *        that type is received
-   * @return OK on success, SYSERR if there is already a
+   * @return GNUNET_OK on success, GNUNET_SYSERR if there is already a
    *         handler for that type
    */
   int (*registerClientHandler) (unsigned short type, CSHandler callback);
@@ -539,7 +543,7 @@
    * @param type the message type
    * @param callback the method to call if a message of
    *        that type is received
-   * @return OK on success, SYSERR if there is a different
+   * @return GNUNET_OK on success, GNUNET_SYSERR if there is a different
    *         handler for that type
    */
   int (*unregisterClientHandler) (unsigned short type, CSHandler callback);
@@ -548,7 +552,7 @@
    * Register a handler to call if any client exits.
    * @param callback a method to call with the socket
    *   of every client that disconnected.
-   * @return OK on success, SYSERR on error
+   * @return GNUNET_OK on success, GNUNET_SYSERR on error
    */
   int (*registerClientExitHandler) (ClientExitHandler callback);
 
@@ -556,7 +560,7 @@
    * Unregister a handler to call if any client exits.
    * @param callback a method to call with the socket
    *   of every client that disconnected.
-   * @return OK on success, SYSERR on error
+   * @return GNUNET_OK on success, GNUNET_SYSERR on error
    */
   int (*unregisterClientExitHandler) (ClientExitHandler callback);
 
@@ -574,12 +578,12 @@
    * Handle a message (that was decrypted if needed).  Processes the
    * message by calling the registered handler for each message part.
    *
-   * @param wasEncrypted YES if it was encrypted,
-   *                     NO if plaintext.
+   * @param wasEncrypted GNUNET_YES if it was encrypted,
+   *                     GNUNET_NO if plaintext.
    * @param session for plaintext messages, the
    *  assumed transport session.  Maybe NULL.
    */
-  void (*injectMessage) (const PeerIdentity * sender,
+  void (*injectMessage) (const GNUNET_PeerIdentity * sender,
                          const char *msg,
                          unsigned int size,
                          int wasEncrypted, TSession * session);
@@ -588,13 +592,13 @@
    * Compute the index (small, positive, pseudo-unique identification
    * number) of a hostId.
    */
-  unsigned int (*computeIndex) (const PeerIdentity * hostId);
+  unsigned int (*computeIndex) (const GNUNET_PeerIdentity * hostId);
 
   /**
    * The the lock of the connection module. A module that registers
    * callbacks may need this.
    */
-  struct MUTEX *(*getConnectionModuleLock) (void);
+  struct GNUNET_Mutex *(*getConnectionModuleLock) (void);
 
   /**
    * Get the current number of slots in the connection table (as computed
@@ -613,16 +617,17 @@
    * Get the time of the last encrypted message that was received
    * from the given peer.
    * @param time updated with the time
-   * @return SYSERR if we are not connected to the peer at the moment
+   * @return GNUNET_SYSERR if we are not connected to the peer at the moment
    */
-  int (*getLastActivityOf) (const PeerIdentity * peer, cron_t * time);
+  int (*getLastActivityOf) (const GNUNET_PeerIdentity * peer,
+                            GNUNET_CronTime * time);
 
   /* here for binary compatibility (for now) */
 
   /**
    * Send a message to the client identified by the handle.  Note that
    * the core will typically buffer these messages as much as possible
-   * and only return SYSERR if it runs out of buffers.  Returning OK
+   * and only return GNUNET_SYSERR if it runs out of buffers.  Returning 
GNUNET_OK
    * on the other hand does NOT confirm delivery since the actual
    * transfer happens asynchronously.
    */
@@ -710,7 +715,7 @@
    * modules are loaded or unloaded inside the module initialization
    * or shutdown code.
    *
-   * @return OK if service was successfully released, SYSERR on error
+   * @return GNUNET_OK if service was successfully released, GNUNET_SYSERR on 
error
    */
   int (*releaseService) (void *service);
 

Modified: GNUnet/src/include/gnunet_datastore_service.h
===================================================================
--- GNUnet/src/include/gnunet_datastore_service.h       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/include/gnunet_datastore_service.h       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -76,10 +76,10 @@
   unsigned int anonymityLevel;
 
   /**
-   * Expiration time for this item, in NBO (use htonll to read!).  Use
+   * Expiration time for this item, in NBO (use GNUNET_htonll to read!).  Use
    * "-1" for items that never expire.
    */
-  cron_t expirationTime;
+  GNUNET_CronTime expirationTime;
 
 } Datastore_Value;
 
@@ -91,10 +91,10 @@
  * @param uid unique identifier for the datum;
  *        maybe 0 if no unique identifier is available
  *
- * @return SYSERR to abort the iteration, OK to continue,
- *         NO to delete the item and continue (if supported)
+ * @return GNUNET_SYSERR to abort the iteration, GNUNET_OK to continue,
+ *         GNUNET_NO to delete the item and continue (if supported)
  */
-typedef int (*Datum_Iterator) (const HashCode512 * key,
+typedef int (*Datum_Iterator) (const GNUNET_HashCode * key,
                                const Datastore_Value * value, void *closure,
                                unsigned long long uid);
 
@@ -129,24 +129,25 @@
    * 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)
    */
-  int (*put) (const HashCode512 * key, const Datastore_Value * value);
+  int (*put) (const GNUNET_HashCode * key, const Datastore_Value * value);
 
   /**
    * Store an item in the datastore.  If the item is already present,
    * 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)
    */
-  int (*putUpdate) (const HashCode512 * key, const Datastore_Value * value);
+  int (*putUpdate) (const GNUNET_HashCode * key,
+                    const Datastore_Value * value);
 
   /**
    * Iterate over the results for a particular key
@@ -156,32 +157,32 @@
    * @param type entries of which type are relevant?
    *     Use 0 for any type.
    * @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,
    *   0 if no matches were found.  May NOT return
-   *   SYSERR unless the iterator aborted!
+   *   GNUNET_SYSERR unless the iterator aborted!
    */
-  int (*get) (const HashCode512 * key,
+  int (*get) (const GNUNET_HashCode * key,
               unsigned int type, Datum_Iterator iter, void *closure);
 
   /**
    * Do a quick test if we MAY have the content.
    */
-  int (*fast_get) (const HashCode512 * key);
+  int (*fast_get) (const GNUNET_HashCode * key);
 
   /**
    * Get a random value from the datastore.
    *
    * @param key set to the key of the match
    * @param value set to an approximate match
-   * @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);
 
   /**
    * Explicitly remove some content from the database.
    */
-  int (*del) (const HashCode512 * query, const Datastore_Value * value);
+  int (*del) (const GNUNET_HashCode * query, const Datastore_Value * value);
 
 } Datastore_ServiceAPI;
 

Modified: GNUnet/src/include/gnunet_dht_lib.h
===================================================================
--- GNUnet/src/include/gnunet_dht_lib.h 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/include/gnunet_dht_lib.h 2007-11-23 11:51:54 UTC (rev 5742)
@@ -47,14 +47,14 @@
  *        automatically time-out
  * @param resultCallback function to call for results,
  *        the operation also aborts if the callback returns
- *        SYSERR
- * @return number of results on success, SYSERR on error (i.e. timeout)
+ *        GNUNET_SYSERR
+ * @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,
+                 const GNUNET_HashCode * key,
+                 GNUNET_CronTime timeout,
                  DataProcessor resultCallback, void *resCallbackClosure);
 
 /**
@@ -63,13 +63,13 @@
  * @param key the key to store
  * @param expire when should the content expire
  * @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,
+                 const GNUNET_HashCode * key,
                  unsigned int type,
-                 cron_t expire, const DataContainer * value);
+                 GNUNET_CronTime expire, const DataContainer * value);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

Modified: GNUnet/src/include/gnunet_dht_service.h
===================================================================
--- GNUnet/src/include/gnunet_dht_service.h     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_dht_service.h     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -69,8 +69,8 @@
    * @return handle to stop the async get
    */
   struct DHT_GET_RECORD *(*get_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,
@@ -88,9 +88,9 @@
    *
    * @param key the key to store under
    */
-  void (*put) (const HashCode512 * key,
+  void (*put) (const GNUNET_HashCode * key,
                unsigned int type,
-               unsigned int size, cron_t expire, const char *data);
+               unsigned int size, GNUNET_CronTime expire, const char *data);
 
 } DHT_ServiceAPI;
 

Modified: GNUnet/src/include/gnunet_dstore_service.h
===================================================================
--- GNUnet/src/include/gnunet_dstore_service.h  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_dstore_service.h  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -20,7 +20,7 @@
 
 /**
  * @file include/gnunet_dstore_service.h
- * @brief dstore is a simple persistent hash table
+ * @brief dstore is a simple persistent GNUNET_hash table
  *        of bounded size with content expiration
  *        In contrast to the sqstore there is
  *        no prioritization, deletion or iteration.
@@ -42,7 +42,7 @@
 #endif
 #endif
 
-typedef void (*ResultHandler) (const HashCode512 * key,
+typedef void (*ResultHandler) (const GNUNET_HashCode * key,
                                unsigned int type,
                                unsigned int size,
                                const char *data, void *cls);
@@ -56,11 +56,12 @@
   /**
    * Store an item in the datastore.
    *
-   * @return OK on success, SYSERR on error
+   * @return GNUNET_OK on success, GNUNET_SYSERR on error
    */
-  int (*put) (const HashCode512 * key,
+  int (*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);
 
   /**
    * Iterate over the results for a particular key
@@ -69,10 +70,10 @@
    * @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
    */
-  int (*get) (const HashCode512 * key,
+  int (*get) (const GNUNET_HashCode * key,
               unsigned int type, ResultHandler handler, void *closure);
 
 } Dstore_ServiceAPI;

Modified: GNUnet/src/include/gnunet_ecrs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_ecrs_lib.h        2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_ecrs_lib.h        2007-11-23 11:51:54 UTC (rev 
5742)
@@ -43,7 +43,7 @@
  * Just the version number of the AFS/ESED/ESED2/ECRS implementation.
  * History:
  *
- * 1.x.x: initial version with triple hash and merkle tree
+ * 1.x.x: initial version with triple GNUNET_hash and merkle tree
  * 2.x.x: root node with mime-type, filename and version number
  * 2.1.x: combined CHK/3HASH encoding with 25:1 super-nodes
  * 2.2.x: with directories
@@ -88,14 +88,14 @@
 
 /**
  * Iterator over meta data.
- * @return OK to continue to iterate, SYSERR to abort
+ * @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort
  */
 typedef int (*ECRS_MetaDataIterator) (EXTRACTOR_KeywordType type,
                                       const char *data, void *closure);
 
 /**
  * Iterator over keywords
- * @return OK to continue to iterate, SYSERR to abort
+ * @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort
  */
 typedef int (*ECRS_KeywordIterator) (const char *data, void *closure);
 
@@ -123,14 +123,14 @@
 
 /**
  * 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 (struct ECRS_MetaData *md,
                         EXTRACTOR_KeywordType type, const char *data);
 
 /**
  * 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 (struct ECRS_MetaData *md,
                           EXTRACTOR_KeywordType type, const char *data);
@@ -178,7 +178,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 ECRS_extractMetaData (struct GE_Context *ectx,
@@ -187,10 +187,10 @@
                           EXTRACTOR_ExtractorList * extractors);
 
 /* = 0 */
-#define ECRS_SERIALIZE_FULL NO
+#define ECRS_SERIALIZE_FULL GNUNET_NO
 
 /* = 1 */
-#define ECRS_SERIALIZE_PART YES
+#define ECRS_SERIALIZE_PART GNUNET_YES
 
 /* disallow compression (if speed is important) */
 #define ECRS_SERIALIZE_NO_COMPRESS 2
@@ -202,9 +202,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 ECRS_serializeMetaData (struct GE_Context *ectx,
@@ -232,8 +232,8 @@
  * Does the meta-data claim that this is a directory?
  * Checks if the mime-type is that of a GNUnet directory.
  *
- * @return YES if it is, NO if it is not, SYSERR if
- *  we have no mime-type information (treat as 'NO')
+ * @return GNUNET_YES if it is, GNUNET_NO if it is not, GNUNET_SYSERR if
+ *  we have no mime-type information (treat as 'GNUNET_NO')
  */
 int ECRS_isDirectory (const struct ECRS_MetaData *md);
 
@@ -287,9 +287,10 @@
 
 /**
  * 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);
+int ECRS_getPeerFromUri (const struct ECRS_URI *uri,
+                         GNUNET_PeerIdentity * peer);
 
 /**
  * Obtain the URI of the content itself.
@@ -304,7 +305,8 @@
  */
 typedef int (*ECRS_SignFunction) (void *cls,
                                   unsigned short size,
-                                  const void *data, Signature * result);
+                                  const void *data,
+                                  GNUNET_RSA_Signature * result);
 
 /**
  * Construct a location URI.
@@ -317,8 +319,8 @@
  * @return the location URI
  */
 struct ECRS_URI *ECRS_uriFromLocation (const struct ECRS_URI *baseUri,
-                                       const PublicKey * peer,
-                                       TIME_T expirationTime,
+                                       const GNUNET_RSA_PublicKey * peer,
+                                       GNUNET_Int32Time expirationTime,
                                        ECRS_SignFunction signer,
                                        void *signer_cls);
 
@@ -381,21 +383,22 @@
  * 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 * nsid);
+char *ECRS_getNamespaceName (const GNUNET_HashCode * nsid);
 
 /**
  * Get the ID of a namespace from the given
  * namespace URI.
  */
-int ECRS_getNamespaceId (const struct ECRS_URI *uri, HashCode512 * nsid);
+int ECRS_getNamespaceId (const struct ECRS_URI *uri, GNUNET_HashCode * nsid);
 
 /**
  * Get the content ID of an SKS URI.
  */
-int ECRS_getSKSContentHash (const struct ECRS_URI *uri, HashCode512 * nsid);
+int ECRS_getSKSContentHash (const struct ECRS_URI *uri,
+                            GNUNET_HashCode * nsid);
 
 /**
  * Is this a keyword URI?
@@ -438,17 +441,15 @@
 /**
  * @param scls must be of type "struct ECRS_URI **"
  */
-int gnunet_getopt_configure_set_keywords (CommandLineProcessorContext * ctx,
-                                          void *scls,
-                                          const char *option,
+int gnunet_getopt_configure_set_keywords (GNUNET_CommandLineProcessorContext *
+                                          ctx, void *scls, const char *option,
                                           const char *value);
 
 /**
  * @param scls must be of type "struct ECRS_MetaData **"
  */
-int gnunet_getopt_configure_set_metadata (CommandLineProcessorContext * ctx,
-                                          void *scls,
-                                          const char *option,
+int gnunet_getopt_configure_set_metadata (GNUNET_CommandLineProcessorContext *
+                                          ctx, void *scls, const char *option,
                                           const char *value);
 
 
@@ -465,7 +466,7 @@
  */
 typedef void (*ECRS_UploadProgressCallback)
   (unsigned long long totalBytes,
-   unsigned long long completedBytes, cron_t eta, void *closure);
+   unsigned long long completedBytes, GNUNET_CronTime eta, void *closure);
 
 /**
  * Should the operation be aborted?  Callback used by many functions
@@ -477,8 +478,8 @@
  * be aborted by any signal, after which the functions will call
  * this callback to check if they should continue).
  *
- * @return OK to continue, SYSERR to abort with deleting
- *  temporary files, NO to abort without deleting temporary files
+ * @return GNUNET_OK to continue, GNUNET_SYSERR to abort with deleting
+ *  temporary files, GNUNET_NO to abort without deleting temporary files
  */
 typedef int (*ECRS_TestTerminate) (void *closure);
 
@@ -488,28 +489,28 @@
  * @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 ECRS_uploadFile (struct GE_Context *ectx, struct GC_Configuration *cfg, 
const char *filename, int doIndex, unsigned int anonymityLevel, unsigned int 
priority, cron_t expirationTime,       /* absolute time */
+int ECRS_uploadFile (struct GE_Context *ectx, struct GC_Configuration *cfg, 
const char *filename, int doIndex, unsigned int anonymityLevel, unsigned int 
priority, GNUNET_CronTime expirationTime,      /* absolute time */
                      ECRS_UploadProgressCallback upcb, void *upcbClosure, 
ECRS_TestTerminate tt, void *ttClosure, struct ECRS_URI **uri);       /* 
upload.c */
 
 /**
  * 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);
 
 /**
- * @return OK to continue iteration, SYSERR to abort
+ * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
  */
 typedef int (*ECRS_FileIterator) (const char *filename, void *cls);
 
@@ -523,7 +524,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,
                               struct GC_Configuration *cfg,
@@ -532,7 +533,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, struct GC_Configuration *cfg, 
const char *filename, ECRS_UploadProgressCallback upcb, void *upcbClosure, 
ECRS_TestTerminate tt, void *ttClosure);        /* unindex.c */
 
@@ -557,24 +558,24 @@
  *
  * @return URI on success, NULL on error (namespace already exists)
  */
-struct ECRS_URI *ECRS_createNamespace (struct GE_Context *ectx, struct 
GC_Configuration *cfg, const char *name, const struct ECRS_MetaData *meta, 
unsigned int anonymityLevel, unsigned int priority, cron_t expiration, const 
struct ECRS_URI *advertisementURI, const HashCode512 * rootEntry);       /* 
namespace.c */
+struct ECRS_URI *ECRS_createNamespace (struct GE_Context *ectx, struct 
GC_Configuration *cfg, const char *name, const struct ECRS_MetaData *meta, 
unsigned int anonymityLevel, unsigned int priority, GNUNET_CronTime expiration, 
const struct ECRS_URI *advertisementURI, const GNUNET_HashCode * rootEntry);  
/* namespace.c */
 
 /**
  * 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);
 
 /**
  * Delete a local namespace.  Only prevents future insertions
  * into the namespace, does not delete any content from
  * the network!
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int ECRS_deleteNamespace (struct GE_Context *ectx, struct GC_Configuration 
*cfg, const char *namespaceName);    /* namespace.c */
 
@@ -583,7 +584,7 @@
  * Contains the name of the local namespace and the global
  * ID.
  */
-typedef int (*ECRS_NamespaceInfoCallback) (const HashCode512 * id,
+typedef int (*ECRS_NamespaceInfoCallback) (const GNUNET_HashCode * id,
                                            const char *name, void *closure);
 
 /**
@@ -592,7 +593,7 @@
  * we only iterate over the local 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, struct GC_Configuration 
*cfg, ECRS_NamespaceInfoCallback cb, void *cls);      /* namespace.c */
 
@@ -606,7 +607,7 @@
  *        entry?
  * @return URI on success, NULL on error
  */
-struct ECRS_URI *ECRS_addToNamespace (struct GE_Context *ectx, struct 
GC_Configuration *cfg, const char *name, unsigned int anonymityLevel, unsigned 
int priority, cron_t expirationTime, TIME_T creationTime, TIME_T 
updateInterval, const HashCode512 * thisId, const HashCode512 * nextId, const 
struct ECRS_URI *dst, const struct ECRS_MetaData *md);      /* namespace.c */
+struct ECRS_URI *ECRS_addToNamespace (struct GE_Context *ectx, struct 
GC_Configuration *cfg, const char *name, unsigned int anonymityLevel, unsigned 
int priority, GNUNET_CronTime expirationTime, GNUNET_Int32Time creationTime, 
GNUNET_Int32Time updateInterval, const GNUNET_HashCode * thisId, const 
GNUNET_HashCode * nextId, const struct ECRS_URI *dst, const struct 
ECRS_MetaData *md); /* namespace.c */
 
 /**
  * Add an entry into the K-space (keyword space).
@@ -617,22 +618,22 @@
  * @param md what meta-data should be associated with the
  *        entry?
  */
-int ECRS_addToKeyspace (struct GE_Context *ectx, struct GC_Configuration *cfg, 
const struct ECRS_URI *uri, unsigned int anonymityLevel, unsigned int priority, 
cron_t expirationTime, const struct ECRS_URI *dst, const struct ECRS_MetaData 
*md);      /* keyspace.c */
+int ECRS_addToKeyspace (struct GE_Context *ectx, struct GC_Configuration *cfg, 
const struct ECRS_URI *uri, unsigned int anonymityLevel, unsigned int priority, 
GNUNET_CronTime expirationTime, const struct ECRS_URI *dst, const struct 
ECRS_MetaData *md);     /* keyspace.c */
 
 /**
  * The search has found another result.  Callback to notify
  * whoever is controlling the search.
  *
  * @param uri the URI of the datum
- * @param key under which the result was found (hash of keyword),
+ * @param key under which the result was found (GNUNET_hash of keyword),
  *        NULL if no key is known
  * @param isRoot is this a namespace root advertisement?
  * @param md a description for the URI
- * @return OK, SYSERR to abort
+ * @return GNUNET_OK, GNUNET_SYSERR to abort
  */
 typedef int (*ECRS_SearchProgressCallback)
   (const ECRS_FileInfo * fi,
-   const HashCode512 * key, int isRoot, void *closure);
+   const GNUNET_HashCode * key, int isRoot, void *closure);
 
 /**
  * Search for content.
@@ -641,7 +642,7 @@
  * @param uri specifies the search parameters
  * @param uri set to the URI of the uploaded file
  */
-int ECRS_search (struct GE_Context *ectx, struct GC_Configuration *cfg, const 
struct ECRS_URI *uri, unsigned int anonymityLevel, cron_t timeout, 
ECRS_SearchProgressCallback spcb, void *spcbClosure, ECRS_TestTerminate tt, 
void *ttClosure);  /* search.c */
+int ECRS_search (struct GE_Context *ectx, struct GC_Configuration *cfg, const 
struct ECRS_URI *uri, unsigned int anonymityLevel, GNUNET_CronTime timeout, 
ECRS_SearchProgressCallback spcb, void *spcbClosure, ECRS_TestTerminate tt, 
void *ttClosure); /* search.c */
 
 /**
  * Notification of ECRS to a client about the progress of an insertion
@@ -652,7 +653,7 @@
  * @param completedBytes number of bytes that have been obtained
  * @param eta absolute estimated time for the completion of the operation
  * @param lastBlockOffset offset of the last block that was downloaded,
- *        -1 as long as NO leaf of the file-tree has been obtained.  Note
+ *        -1 as long as GNUNET_NO leaf of the file-tree has been obtained.  
Note
  *        that inner nodes are _not_ counted here
  * @param lastBlock plaintext of the last block that was downloaded
  * @param lastBlockSize size of the last block that was downloaded
@@ -660,12 +661,12 @@
 typedef void (*ECRS_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 *closure);
 
 /**
- * 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
@@ -673,7 +674,7 @@
 int ECRS_downloadFile (struct GE_Context *ectx, struct GC_Configuration *cfg, 
const struct ECRS_URI *uri, const char *filename, unsigned int anonymityLevel, 
ECRS_DownloadProgressCallback dpcb, void *dpcbClosure, ECRS_TestTerminate tt, 
void *ttClosure);    /* download.c */
 
 /**
- * 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
@@ -687,7 +688,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)
  */
@@ -704,7 +705,7 @@
  * @param len number of bytes in data
  * @param md set to the MD for the directory if the first
  *   block is part of data
- * @return number of entries on success, SYSERR if the
+ * @return number of entries on success, GNUNET_SYSERR if the
  *         directory is malformed
  */
 int ECRS_listDirectory (struct GE_Context *ectx, const char *data, unsigned 
long long len, struct ECRS_MetaData **md, ECRS_SearchProgressCallback spcb, 
void *spcbClosure);     /* directory.c */
@@ -720,7 +721,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, char **data, unsigned long 
long *len, unsigned int count, const ECRS_FileInfo * fis, struct ECRS_MetaData 
*meta);    /* directory.c */
 

Modified: GNUnet/src/include/gnunet_fragmentation_service.h
===================================================================
--- GNUnet/src/include/gnunet_fragmentation_service.h   2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/include/gnunet_fragmentation_service.h   2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -53,7 +53,7 @@
    * @param bmc callback to construct the message
    * @param bmcClosure argument to bmc
    */
-  void (*fragment) (const PeerIdentity * peer,
+  void (*fragment) (const GNUNET_PeerIdentity * peer,
                     unsigned int mtu,
                     unsigned int prio,
                     unsigned int targetTime,

Modified: GNUnet/src/include/gnunet_fs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_fs_lib.h  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/include/gnunet_fs_lib.h  2007-11-23 11:51:54 UTC (rev 5742)
@@ -48,7 +48,7 @@
 
 struct FS_SEARCH_CONTEXT *FS_SEARCH_makeContext (struct GE_Context *ectx,
                                                  struct GC_Configuration *cfg,
-                                                 struct MUTEX *lock);
+                                                 struct GNUNET_Mutex *lock);
 
 void FS_SEARCH_destroyContext (struct FS_SEARCH_CONTEXT *ctx);
 
@@ -67,13 +67,13 @@
  * @param prio priority to use for the search
  */
 struct FS_SEARCH_HANDLE *FS_start_search (struct FS_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,
+                                          GNUNET_CronTime timeout,
                                           Datum_Iterator callback,
                                           void *closure);
 
@@ -87,7 +87,7 @@
  * What is the current average priority of entries
  * in the routing table like?  Returns -1 on error.
  */
-int FS_getAveragePriority (struct ClientServerConnection *sock);
+int FS_getAveragePriority (struct GNUNET_ClientServerConnection *sock);
 
 /**
  * Insert a block.  Note that while the API is VERY similar to
@@ -95,31 +95,31 @@
  * plaintext, whereas the block passed to FS_insert must be encrypted!
  *
  * @param block the block (properly encoded and all)
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  * @see ecrs_core.h::fileBlockEncode
  */
-int FS_insert (struct ClientServerConnection *sock,
+int FS_insert (struct GNUNET_ClientServerConnection *sock,
                const Datastore_Value * block);
 
 
 /**
  * Initialize to index a file.  Tries to do the symlinking.
  */
-int FS_initIndex (struct ClientServerConnection *sock,
-                  const HashCode512 * fileHc, const char *fn);
+int FS_initIndex (struct GNUNET_ClientServerConnection *sock,
+                  const GNUNET_HashCode * fileHc, const char *fn);
 
 /**
  * Index a block.  Note that while the API is VERY similar to
  * FS_insert in terms of signature, the block for FS_index must be in
  * plaintext, whereas the block passed to FS_insert must be encrypted!
  *
- * @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,
+int FS_index (struct GNUNET_ClientServerConnection *sock,
+              const GNUNET_HashCode * fileHc,
               const Datastore_Value * block, unsigned long long offset);
 
 /**
@@ -128,28 +128,28 @@
  *
  * @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,
+int FS_delete (struct GNUNET_ClientServerConnection *sock,
                const Datastore_Value * block);
 
 /**
  * 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);
+int FS_unindex (struct GNUNET_ClientServerConnection *sock,
+                unsigned int blocksize, const GNUNET_HashCode * hc);
 
 /**
- * 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);
+int FS_testIndexed (struct GNUNET_ClientServerConnection *sock,
+                    const GNUNET_HashCode * hc);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

Modified: GNUnet/src/include/gnunet_fsui_lib.h
===================================================================
--- GNUnet/src/include/gnunet_fsui_lib.h        2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_fsui_lib.h        2007-11-23 11:51:54 UTC (rev 
5742)
@@ -417,7 +417,7 @@
       /**
        * Estimated completion time.
        */
-      cron_t eta;
+      GNUNET_CronTime eta;
 
       /**
        * Information about the download.
@@ -547,7 +547,7 @@
       /**
        * Estimated completion time.
        */
-      cron_t eta;
+      GNUNET_CronTime eta;
 
       /**
        * Information about the download.
@@ -581,7 +581,7 @@
       /**
        * Estimated completion time (for the current file)
        */
-      cron_t eta;
+      GNUNET_CronTime eta;
 
       /**
        * Information about the upload.
@@ -683,7 +683,7 @@
       /**
        * Estimated completion time (for the current file)
        */
-      cron_t eta;
+      GNUNET_CronTime eta;
 
       /**
        * Information about the upload.
@@ -712,7 +712,7 @@
 
       unsigned long long completed;
 
-      cron_t eta;
+      GNUNET_CronTime eta;
 
       const char *filename;
 
@@ -763,7 +763,7 @@
 
       unsigned long long completed;
 
-      cron_t eta;
+      GNUNET_CronTime eta;
 
       const char *filename;
 
@@ -821,11 +821,11 @@
  * previously.<p>
  *
  * The basic idea is that graphical user interfaces use their UI name
- * (i.e.  gnunet-gtk) for 'name' and set doResume to YES.  They should
+ * (i.e.  gnunet-gtk) for 'name' and set doResume to GNUNET_YES.  They should
  * have a command-line switch --resume=NAME to allow the user to
  * change 'name' to something else (such that the user can resume
  * state from another GUI).  Shell UIs on the other hand should set
- * doResume to NO and may hard-wire a 'name' (which has no semantic
+ * doResume to GNUNET_NO and may hard-wire a 'name' (which has no semantic
  * meaning, however, the name of the UI would still be a good choice).
  * <p>
  *
@@ -837,10 +837,10 @@
  *          and that also use resume cannot run multiple instances
  *          in parallel (for the same user account); the name
  *          must be a valid filename (not a path)
- * @param doResume YES if old activities should be resumed (also
+ * @param doResume GNUNET_YES if old activities should be resumed (also
  *          implies that on shutdown, all pending activities are
  *          suspended instead of canceled);
- *          NO if activities should never be resumed
+ *          GNUNET_NO if activities should never be resumed
  * @param cb function to call for events, must not be NULL
  * @param closure extra argument to cb
  * @return NULL on error
@@ -861,19 +861,19 @@
  *
  * @return NULL on error
  */
-struct FSUI_SearchList *FSUI_startSearch (struct FSUI_Context *ctx, unsigned 
int anonymityLevel, unsigned int maxResults, cron_t timeout, const struct 
ECRS_URI *uri);  /* search.c */
+struct FSUI_SearchList *FSUI_startSearch (struct FSUI_Context *ctx, unsigned 
int anonymityLevel, unsigned int maxResults, GNUNET_CronTime timeout, const 
struct ECRS_URI *uri); /* search.c */
 
 /**
  * Abort a search.
  *
- * @return SYSERR if such a search is not known
+ * @return GNUNET_SYSERR if such a search is not known
  */
 int FSUI_abortSearch (struct FSUI_Context *ctx, struct FSUI_SearchList *sl);   
 /* search.c */
 
 /**
  * Stop a search.
  *
- * @return SYSERR if such a search is not known
+ * @return GNUNET_SYSERR if such a search is not known
  */
 int FSUI_stopSearch (struct FSUI_Context *ctx, struct FSUI_SearchList *sl);    
 /* search.c */
 
@@ -888,7 +888,7 @@
  * Abort a download.  If the dl is for a recursive
  * download, all sub-downloads will also be aborted.
  *
- * @return SYSERR on error
+ * @return GNUNET_SYSERR on error
  */
 int FSUI_abortDownload (struct FSUI_Context *ctx, struct FSUI_DownloadList 
*dl);        /* download.c */
 
@@ -896,21 +896,21 @@
  * Stop a download.  If the dl is for a recursive
  * download, all sub-downloads will also be stopped.
  *
- * @return SYSERR on error
+ * @return GNUNET_SYSERR on error
  */
 int FSUI_stopDownload (struct FSUI_Context *ctx, struct FSUI_DownloadList 
*dl); /* download.c */
 
 /**
  * Method that can be used to select files that
  * should be put into a directory when doing an
- * upload.  For example, "disk_directory_scan"
+ * upload.  For example, "GNUNET_disk_directory_scan"
  * is a legal implementation that would simply
  * select all files of the directory for the
  * upload.
  */
 typedef int (*DirectoryScanCallback) (void *data,
                                       const char *filename,
-                                      DirectoryEntryCallback dec,
+                                      GNUNET_DirectoryEntryCallback dec,
                                       void *decClosure);
 
 /**
@@ -936,7 +936,7 @@
                                           int doIndex,
                                           int doExtract,
                                           int individualKeywords,
-                                          cron_t expiration,
+                                          GNUNET_CronTime expiration,
                                           const struct ECRS_MetaData
                                           *topLevelMetaData,
                                           const struct ECRS_URI *globalURI,
@@ -947,7 +947,7 @@
  * Abort an upload.  If the context is for a recursive
  * upload, all sub-uploads will also be aborted.
  *
- * @return SYSERR on error
+ * @return GNUNET_SYSERR on error
  */
 int FSUI_abortUpload (struct FSUI_Context *ctx, struct FSUI_UploadList *ul);
 
@@ -955,7 +955,7 @@
  * 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);
 
@@ -973,7 +973,7 @@
 /**
  * Abort an unindex operation.
  *
- * @return SYSERR on error
+ * @return GNUNET_SYSERR on error
  */
 int FSUI_abortUnindex (struct FSUI_Context *ctx, struct FSUI_UnindexList *ul);
 
@@ -981,7 +981,7 @@
 /**
  * Stop an unindex operation.
  *
- * @return SYSERR on error
+ * @return GNUNET_SYSERR on error
  */
 int FSUI_stopUnindex (struct FSUI_Context *ctx, struct FSUI_UnindexList *ul);
 

Modified: GNUnet/src/include/gnunet_gap_service.h
===================================================================
--- GNUnet/src/include/gnunet_gap_service.h     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_gap_service.h     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -52,20 +52,20 @@
  * Function that helps the routing code to find out if
  * a given reply is the one and only reply for a given
  * request.
- * @param verify check that content is valid? (YES/NO)
+ * @param verify check that content is valid? (GNUNET_YES/GNUNET_NO)
  */
 typedef int (*UniqueReplyIdentifier) (const DataContainer * content,
                                       unsigned int query_type,
                                       int verify,
-                                      const HashCode512 * primaryKey);
+                                      const GNUNET_HashCode * primaryKey);
 
 /**
  * Given some content, compute the unique
- * hash of the content that can then be used
+ * GNUNET_hash of the content that can then be used
  * to sort out duplicates.
  */
 typedef int (*ReplyHashFunction) (const DataContainer * data,
-                                  HashCode512 * hc);
+                                  GNUNET_HashCode * hc);
 
 /**
  * Functions of the GAP Service API.
@@ -77,7 +77,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
    */
   int (*init) (Blockstore * datastore,
                UniqueReplyIdentifier uri, ReplyHashFunction rhf);
@@ -93,15 +93,15 @@
    * @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
+   * @return GNUNET_OK if we will start to query, GNUNET_SYSERR if all of our
    *  buffers are full or other error
    */
-  int (*get_start) (const PeerIdentity * target,
+  int (*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);
 
   /**
    * Stop sending out queries for a given key.  GAP will automatically
@@ -109,7 +109,7 @@
    * to stop it earlier.
    */
   int (*get_stop) (unsigned int type,
-                   unsigned int keyCount, const HashCode512 * keys);
+                   unsigned int keyCount, const GNUNET_HashCode * keys);
 
   /**
    * Try to migrate the given content.
@@ -121,7 +121,7 @@
    *   that buffer (must be a positive number).
    */
   unsigned int (*tryMigrate) (const DataContainer * data,
-                              const HashCode512 * primaryKey,
+                              const GNUNET_HashCode * primaryKey,
                               char *position, unsigned int padding);
 
   /**

Modified: GNUnet/src/include/gnunet_getoption_lib.h
===================================================================
--- GNUnet/src/include/gnunet_getoption_lib.h   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_getoption_lib.h   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -41,7 +41,7 @@
  * Obtain option value from a peer.
  * @return NULL on error
  */
-char *getConfigurationOptionValue (struct ClientServerConnection *sock,
+char *GNUNET_get_daemon_configuration_value (struct 
GNUNET_ClientServerConnection *sock,
                                    const char *section, const char *option);
 
 #if 0                           /* keep Emacsens' auto-indent happy */

Modified: GNUnet/src/include/gnunet_identity_lib.h
===================================================================
--- GNUnet/src/include/gnunet_identity_lib.h    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_identity_lib.h    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -45,36 +45,37 @@
  * just like HELLOs received from other peers.
  *
  * @param sock socket to talk to gnunetd over
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int gnunet_identity_peer_add (struct ClientServerConnection *sock,
-                              const P2P_hello_MESSAGE * hello);
+int GNUNET_IDENTITY_peer_add (struct GNUNET_ClientServerConnection *sock,
+                              const GNUNET_MessageHello * hello);
 
 /**
- * Function to request the peer to sign something
+ * Function to request the peer to GNUNET_RSA_sign something
  * with the private key of the peer.
  */
-int gnunet_identity_sign_function (struct ClientServerConnection *sock,
+int GNUNET_IDENTITY_sign_function (struct GNUNET_ClientServerConnection *sock,
                                    unsigned short size,
-                                   const void *data, Signature * result);
+                                   const void *data,
+                                   GNUNET_RSA_Signature * result);
 
 /**
  * Function to request one of the peer's identities
  * (that is, external addresses).
  *
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
-int gnunet_identity_get_self (struct ClientServerConnection *sock,
-                              P2P_hello_MESSAGE ** hello);
+int GNUNET_IDENTITY_get_self (struct GNUNET_ClientServerConnection *sock,
+                              GNUNET_MessageHello ** hello);
 
 
 /**
  * Request the peer to connect to another peer
- * @return SYSERR on error, YES if connection is now there
- *         NO if connection is not yet present
+ * @return GNUNET_SYSERR on error, GNUNET_YES if connection is now there
+ *         GNUNET_NO if connection is not yet present
  */
-int gnunet_identity_request_connect (struct ClientServerConnection *sock,
-                                     const PeerIdentity * peer);
+int GNUNET_IDENTITY_request_connect (struct GNUNET_ClientServerConnection
+                                     *sock, const GNUNET_PeerIdentity * peer);
 
 
 /**
@@ -91,24 +92,25 @@
  *        number of bytes per minute that we currently allow
  *        this peer to sent to us
  * @param identity the id of the node
- * @return OK to continue to iterate, SYSERR to abort
+ * @return GNUNET_OK to continue to iterate, GNUNET_SYSERR to abort
  */
-typedef int (*GNUnetIdentityPeerInfoCallback) (void *data,
-                                               const PeerIdentity * identity,
-                                               const void *address,
+typedef int (*GNUNET_IDENTITY_PeerInfoCallback) (void *data,
+                                               const GNUNET_PeerIdentity *
+                                               identity, const void *address,
                                                unsigned int addr_len,
-                                               cron_t last_message,
+                                               GNUNET_CronTime last_message,
                                                unsigned int trust,
                                                unsigned int bpmFromPeer);
 
 /**
  * Request information about all known peers
  *
- * @return SYSERR if iteration was aborted,
+ * @return GNUNET_SYSERR if iteration was aborted,
  *         otherwise number of peers known
  */
-int gnunet_identity_request_peer_infos (struct ClientServerConnection *sock,
-                                        GNUnetIdentityPeerInfoCallback
+int GNUNET_IDENTITY_request_peer_infos (struct GNUNET_ClientServerConnection
+                                        *sock,
+                                        GNUNET_IDENTITY_PeerInfoCallback
                                         callback, void *cls);
 
 

Modified: GNUnet/src/include/gnunet_identity_service.h
===================================================================
--- GNUnet/src/include/gnunet_identity_service.h        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/include/gnunet_identity_service.h        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -53,12 +53,12 @@
  *
  * @param identity the identity of the host
  * @param protocol the available protocol
- * @param confirmed is the address confirmed (YES),
- *        if NO the host is in the temporary list
+ * @param confirmed is the address confirmed (GNUNET_YES),
+ *        if GNUNET_NO the host is in the temporary list
  * @param data callback closure
- * @return OK to continue iteration
+ * @return GNUNET_OK to continue iteration
  */
-typedef int (*HostIterator) (const PeerIdentity * identity,
+typedef int (*HostIterator) (const GNUNET_PeerIdentity * identity,
                              unsigned short protocol,
                              int confirmed, void *data);
 
@@ -73,7 +73,7 @@
    *
    * @return reference to the public key. Do not free it!
    */
-  const PublicKey *(*getPublicPrivateKey) (void);
+  const GNUNET_RSA_PublicKey *(*getPublicPrivateKey) (void);
 
   /**
    * Obtain identity from publicPrivateKey.
@@ -81,17 +81,19 @@
    * @param pubKey the public key of the host
    * @param result address where to write the identity of the node
    */
-  void (*getPeerIdentity) (const PublicKey * pubKey, PeerIdentity * result);
+  void (*getPeerIdentity) (const GNUNET_RSA_PublicKey * pubKey,
+                           GNUNET_PeerIdentity * result);
 
 
   /**
    * Sign arbitrary data. ALWAYS use only on data we entirely generated.
-   * @param data what to sign
+   * @param data what to GNUNET_RSA_sign
    * @param size how big is the data
    * @param result where to store the result
-   * @returns SYSERR on failure, OK on success
+   * @returns GNUNET_SYSERR on failure, GNUNET_OK on success
    */
-  int (*signData) (const void *data, unsigned short size, Signature * result);
+  int (*signData) (const void *data, unsigned short size,
+                   GNUNET_RSA_Signature * result);
 
   /**
    * Decrypt a given block with the hostkey.
@@ -101,25 +103,25 @@
    *        the decrypted block is bigger, an error is returned
    * @returns the size of the decrypted block, -1 on error
    */
-  int (*decryptData) (const RSAEncryptedData * block,
+  int (*decryptData) (const GNUNET_RSA_EncryptedData * block,
                       void *result, unsigned int max);
 
   /**
    * Delete a host from the list
    */
-  void (*delHostFromKnown) (const PeerIdentity * identity,
+  void (*delHostFromKnown) (const GNUNET_PeerIdentity * identity,
                             unsigned short protocol);
 
   /**
    * Add a host to the temporary list.
    */
-  void (*addHostTemporarily) (const P2P_hello_MESSAGE * tmp);
+  void (*addHostTemporarily) (const GNUNET_MessageHello * tmp);
 
   /**
    * Add a host to the persistent list.
    * @param msg the verified (!) hello message
    */
-  void (*addHost) (const P2P_hello_MESSAGE * msg);
+  void (*addHost) (const GNUNET_MessageHello * msg);
 
   /**
    * Call a method for each known host.
@@ -129,7 +131,7 @@
    * @param data an argument to pass to the method
    * @return the number of known hosts matching
    */
-  int (*forEachHost) (cron_t now, HostIterator callback, void *data);
+  int (*forEachHost) (GNUNET_CronTime now, HostIterator callback, void *data);
 
   /**
    * Obtain the public key and address of a known host. If no specific
@@ -141,9 +143,9 @@
    *        ANY_PROTOCOL_NUMBER  if we do not care which protocol
    * @return NULL on failure, the hello on success
    */
-  P2P_hello_MESSAGE *(*identity2Hello) (const PeerIdentity * hostId,
-                                        unsigned short protocol,
-                                        int tryTemporaryList);
+  GNUNET_MessageHello *(*identity2Hello) (const GNUNET_PeerIdentity * hostId,
+                                          unsigned short protocol,
+                                          int tryTemporaryList);
 
   /**
    *
@@ -152,11 +154,11 @@
    * @param message the signed message
    * @param size the size of the message
    * @param sig the signature
-   * @return OK on success, SYSERR on error (verification failed)
+   * @return GNUNET_OK on success, GNUNET_SYSERR on error (verification failed)
    */
-  int (*verifyPeerSignature) (const PeerIdentity * signer,
+  int (*verifyPeerSignature) (const GNUNET_PeerIdentity * signer,
                               const void *message,
-                              int size, const Signature * sig);
+                              int size, const GNUNET_RSA_Signature * sig);
 
   /**
    * Blacklist a host. This method is called if a host
@@ -167,12 +169,12 @@
    * @param strict should we reject incoming connections?
    *               (and also not possibly attempt to connect
    *                to this peer from our side)?
-   *               If set to YES, the desperation value
+   *               If set to GNUNET_YES, the desperation value
    *               is also definite, otherwise an algorithm
    *               for back-off and limiting is applied.
-   * @return OK on success SYSERR on error
+   * @return GNUNET_OK on success GNUNET_SYSERR on error
    */
-  int (*blacklistHost) (const PeerIdentity * identity,
+  int (*blacklistHost) (const GNUNET_PeerIdentity * identity,
                         unsigned int desperation, int strict);
 
   /**
@@ -182,20 +184,20 @@
    * misbehaved badly and we also reject inbound connections.
    *
    * @param identity node to check
-   * @param strict YES if we should only care about
+   * @param strict GNUNET_YES if we should only care about
    *        strict blacklisting
-   * @return YES if true, else NO
+   * @return GNUNET_YES if true, else GNUNET_NO
    */
-  int (*isBlacklisted) (const PeerIdentity * identity, int strict);
+  int (*isBlacklisted) (const GNUNET_PeerIdentity * identity, int strict);
 
   /**
    * Whitelist a host. This method is called if a host
    * successfully established a connection. It typically
    * resets the exponential backoff to the smallest value.
    *
-   * @return OK on success SYSERR on error
+   * @return GNUNET_OK on success GNUNET_SYSERR on error
    */
-  int (*whitelistHost) (const PeerIdentity * identity);
+  int (*whitelistHost) (const GNUNET_PeerIdentity * identity);
 
   /**
    * Change the host trust by a value.
@@ -204,12 +206,12 @@
    * @param value is the int value by which the host credit is to be increased
    * @returns the new credit
    */
-  int (*changeHostTrust) (const PeerIdentity * hostId, int value);
+  int (*changeHostTrust) (const GNUNET_PeerIdentity * hostId, int value);
 
   /**
    * Obtain the trust record of the host.
    */
-  unsigned int (*getHostTrust) (const PeerIdentity * hostId);
+  unsigned int (*getHostTrust) (const GNUNET_PeerIdentity * hostId);
 
 } Identity_ServiceAPI;
 

Modified: GNUnet/src/include/gnunet_kvstore_service.h
===================================================================
--- GNUnet/src/include/gnunet_kvstore_service.h 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_kvstore_service.h 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -52,7 +52,7 @@
  * @param closure optional parameter
  * @param val the value retrieved
  * @param vallen the length von val
- * @return OK on success
+ * @return GNUNET_OK on success
  */
 typedef int (*KVCallback) (void *closure, void *val, int vallen);
 
@@ -93,7 +93,7 @@
    * @param val value of the pair
    * @param vallen length of the value (int because of SQLite!)
    * @param optional creation time
-   * @return OK on success, SYSERR otherwise
+   * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
    */
   int (*put) (KVHandle * kv,
               void *key,
@@ -104,7 +104,7 @@
    * @param key key to delete (may be NULL)
    * @param keylen length of the key
    * @param age age of the items to delete (may be 0)
-   * @return OK on success, SYSERR otherwise
+   * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
    */
   int (*del) (KVHandle * kv, void *key, int keylen, unsigned long long age);
 
@@ -117,7 +117,7 @@
   /**
    * @brief Drop a Key/Value-Table
    * @param the handle to the table
-   * @return OK on success, SYSERR otherwise
+   * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
    */
   int (*dropTable) (KVHandle * kv);
 

Modified: GNUnet/src/include/gnunet_namespace_lib.h
===================================================================
--- GNUnet/src/include/gnunet_namespace_lib.h   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_namespace_lib.h   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -41,11 +41,11 @@
  * Iterator over all namespaces.
  *
  * @param rating the local rating of the namespace
- * @return OK to continue iteration, SYSERR to abort
+ * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
  */
 typedef int (*NS_NamespaceIterator) (void *cls,
                                      const char *namespaceName,
-                                     const HashCode512 * namespaceId,
+                                     const GNUNET_HashCode * namespaceId,
                                      const struct ECRS_MetaData * md,
                                      int rating);
 
@@ -58,14 +58,14 @@
  * @param publicationFrequency how often are updates scheduled?
  * @param nextPublicationTime the scheduled time for the
  *  next update (0 for sporadic updates)
- * @return OK to continue iteration, SYSERR to abort
+ * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
  */
 typedef int (*NS_UpdateIterator) (void *cls,
                                   const ECRS_FileInfo * uri,
-                                  const HashCode512 * lastId,
-                                  const HashCode512 * nextId,
-                                  TIME_T publicationFrequency,
-                                  TIME_T nextPublicationTime);
+                                  const GNUNET_HashCode * lastId,
+                                  const GNUNET_HashCode * nextId,
+                                  GNUNET_Int32Time publicationFrequency,
+                                  GNUNET_Int32Time nextPublicationTime);
 
 /**
  * Create a new namespace (and publish an advertismement).
@@ -75,13 +75,13 @@
  * @param meta meta-data about the namespace (maybe NULL)
  * @return URI on success, NULL on error (namespace already exists)
  */
-struct ECRS_URI *NS_createNamespace (struct GE_Context *ectx, struct 
GC_Configuration *cfg, unsigned int anonymityLevel, unsigned int 
insertPriority, cron_t insertExpiration, const char *namespaceName, const 
struct ECRS_MetaData *meta, const struct ECRS_URI *advertisementURI, const 
HashCode512 * rootEntry);    /* namespace_info.c */
+struct ECRS_URI *NS_createNamespace (struct GE_Context *ectx, struct 
GC_Configuration *cfg, unsigned int anonymityLevel, unsigned int 
insertPriority, GNUNET_CronTime insertExpiration, const char *namespaceName, 
const struct ECRS_MetaData *meta, const struct ECRS_URI *advertisementURI, 
const GNUNET_HashCode * rootEntry);       /* namespace_info.c */
 
 /**
  * Delete a local namespace.  Only prevents future insertions into the
  * namespace, does not delete any content from the network!
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int NS_deleteNamespace (struct GE_Context *ectx, struct GC_Configuration *cfg, 
const char *namespaceName);      /* namespace.c */
 
@@ -111,11 +111,11 @@
 
 /**
  * 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);
 
 void NS_setNamespaceRoot (struct GE_Context *ectx,
                           struct GC_Configuration *cfg,
@@ -181,20 +181,21 @@
  *        entry?
  * @return the resulting URI, NULL on error
  */
-struct ECRS_URI *NS_addToNamespace (struct GE_Context *ectx, struct 
GC_Configuration *cfg, unsigned int anonymityLevel, unsigned int 
insertPriority, cron_t insertExpiration, const char *name, TIME_T 
updateInterval, const HashCode512 * lastId, const HashCode512 * thisId, const 
HashCode512 * nextId, const struct ECRS_URI *dst, const struct ECRS_MetaData 
*md); /* namespace_info.c */
+struct ECRS_URI *NS_addToNamespace (struct GE_Context *ectx, struct 
GC_Configuration *cfg, unsigned int anonymityLevel, unsigned int 
insertPriority, GNUNET_CronTime insertExpiration, const char *name, 
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);  /* namespace_info.c */
 
 /**
  * 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 NS
- * @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);
 
 /**
  * List all updateable content in a given namespace.

Modified: GNUnet/src/include/gnunet_peerinfo_lib.h
===================================================================
--- GNUnet/src/include/gnunet_peerinfo_lib.h    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_peerinfo_lib.h    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -45,10 +45,10 @@
  * @param id identity of the peer
  * @param trust trust we have in the peer
  *
- * @return OK to continue, SYSERR to abort iteration
+ * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
  */
 typedef int (*PEERINFO_PeerProcessor) (const char *name,
-                                       const PeerIdentity * id,
+                                       const GNUNET_PeerIdentity * id,
                                        unsigned int trust, void *cls);
 
 /**
@@ -57,10 +57,10 @@
  * @param sock the socket to use
  * @param processor function to call on each value
  * @param connected_only only list currently connected peers
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int PEERINFO_getInfo (struct GE_Context *ectx,
-                      struct ClientServerConnection *sock,
+                      struct GNUNET_ClientServerConnection *sock,
                       int connected_only,
                       PEERINFO_PeerProcessor processor, void *cls);
 

Modified: GNUnet/src/include/gnunet_pingpong_service.h
===================================================================
--- GNUnet/src/include/gnunet_pingpong_service.h        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/include/gnunet_pingpong_service.h        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -48,14 +48,15 @@
    * an encrypted ping routed using the core.
    *
    * @param receiver the peer that should be PINGed
-   * @param usePlaintext send the PING in plaintext (YES/NO)
+   * @param usePlaintext send the PING in plaintext (GNUNET_YES/GNUNET_NO)
    * @param method the method to call if a PONG comes back
    * @param data an argument to pass to the method, if not
-   *   NULL and the ping does not come back, ping will FREE data!
-   * @returns OK on success, SYSERR on error
+   *   NULL and the ping does not come back, ping will GNUNET_free data!
+   * @returns GNUNET_OK on success, GNUNET_SYSERR on error
    */
-  int (*ping) (const PeerIdentity * receiver,
-               CronJob method, void *data, int usePlaintext, int challenge);
+  int (*ping) (const GNUNET_PeerIdentity * receiver,
+               GNUNET_CronJob method, void *data, int usePlaintext,
+               int challenge);
 
   /**
    * Ping a host an call a method if a reply comes back.
@@ -66,12 +67,13 @@
    * @param receiver the peer that should be PINGed
    * @param method the method to call if a PONG comes back
    * @param data an argument to pass to the method, if not
-   *   NULL and the ping does not come back, ping will FREE data!
+   *   NULL and the ping does not come back, ping will GNUNET_free data!
    * @returns NULL on error, otherwise the PING message
    */
-  MESSAGE_HEADER *(*pingUser) (const PeerIdentity * receiver,
-                               CronJob method,
-                               void *data, int plaintext, int challenge);
+  GNUNET_MessageHeader *(*pingUser) (const GNUNET_PeerIdentity * receiver,
+                                     GNUNET_CronJob method,
+                                     void *data, int plaintext,
+                                     int challenge);
 
   unsigned int ping_size;
 

Modified: GNUnet/src/include/gnunet_protocols.h
===================================================================
--- GNUnet/src/include/gnunet_protocols.h       2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_protocols.h       2007-11-23 11:51:54 UTC (rev 
5742)
@@ -218,7 +218,7 @@
 #define CS_PROTO_identity_HELLO 28
 
 /**
- * Client asks the Daemon to sign a message.
+ * Client asks the Daemon to GNUNET_RSA_sign a message.
  */
 #define CS_PROTO_identity_request_SIGN 29
 
@@ -365,7 +365,7 @@
 
 /**
  * termination of connection (other host is nice
- * and tells us, there is NO requirement to do so!)
+ * and tells us, there is GNUNET_NO requirement to do so!)
  */
 #define P2P_PROTO_hangup 4
 

Modified: GNUnet/src/include/gnunet_rpc_service.h
===================================================================
--- GNUnet/src/include/gnunet_rpc_service.h     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_rpc_service.h     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -74,12 +74,12 @@
 /**
  * Type of RPC arguments.
  */
-#define RPC_Param struct Vector
+#define RPC_Param struct GNUNET_Vector
 
 /**
  * Prototype for synchronous RPC functions.
  */
-typedef void (*RPC_Function) (const PeerIdentity * caller,
+typedef void (*RPC_Function) (const GNUNET_PeerIdentity * caller,
                               RPC_Param * arguments, RPC_Param * results);
 
 /**
@@ -88,7 +88,7 @@
 struct CallInstance;
 
 /**
- * Signature of the callback function for the ASYNC_RPC to
+ * GNUNET_RSA_Signature of the callback function for the ASYNC_RPC to
  * be called upon completion of the ASYNC function.
  */
 typedef void (*Async_RPC_Complete_Callback) (RPC_Param * results,
@@ -98,7 +98,7 @@
 /**
  * Prototype for asynchronous RPC functions.
  */
-typedef void (*ASYNC_RPC_Function) (const PeerIdentity * caller,
+typedef void (*ASYNC_RPC_Function) (const GNUNET_PeerIdentity * caller,
                                     RPC_Param * arguments,
                                     Async_RPC_Complete_Callback callback,
                                     struct CallInstance * context);
@@ -107,7 +107,7 @@
 /**
  * Function to call once an asynchronous RPC completes.
  */
-typedef void (*RPC_Complete) (const PeerIdentity * responder,
+typedef void (*RPC_Complete) (const GNUNET_PeerIdentity * responder,
                               RPC_Param * results, void *closure);
 
 struct RPC_Record;
@@ -121,11 +121,11 @@
   /**
    * Perform a synchronous RPC.
    */
-  int (*RPC_execute) (const PeerIdentity * receiver,
+  int (*RPC_execute) (const GNUNET_PeerIdentity * receiver,
                       const char *name,
                       RPC_Param * request_param,
                       RPC_Param * return_param,
-                      unsigned int importance, cron_t timeout);
+                      unsigned int importance, GNUNET_CronTime timeout);
 
   /**
    * Register a synchronous RPC function.
@@ -158,11 +158,11 @@
    * @return value required to stop the RPC (and the RPC must
    *  be explicitly stopped to free resources!)
    */
-  struct RPC_Record *(*RPC_start) (const PeerIdentity * receiver,
+  struct RPC_Record *(*RPC_start) (const GNUNET_PeerIdentity * receiver,
                                    const char *name,
                                    RPC_Param * request_param,
                                    unsigned int importance,
-                                   cron_t timeout,
+                                   GNUNET_CronTime timeout,
                                    RPC_Complete callback, void *closure);
 
   /**
@@ -199,14 +199,14 @@
 unsigned int RPC_paramIndex (RPC_Param * param, const char *name);
 
 /**
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int RPC_paramValueByName (RPC_Param * param,
                           const char *name,
                           unsigned int *dataLength, void **data);
 
 /**
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int RPC_paramValueByPosition (RPC_Param * param,
                               unsigned int i,
@@ -227,7 +227,7 @@
  *
  * @param param Target RPC parameter structure
  * @param value set to the value of the named parameter
- * @return SYSERR on error
+ * @return GNUNET_SYSERR on error
  */
 DataContainer *RPC_paramDataContainerByName (RPC_Param * param,
                                              const char *name);

Modified: GNUnet/src/include/gnunet_session_service.h
===================================================================
--- GNUnet/src/include/gnunet_session_service.h 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_session_service.h 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -49,11 +49,11 @@
   /**
    * Try to connect to the given peer.
    *
-   * @return SYSERR if that is impossible,
-   *         YES if a connection is established upon return,
-   *         NO if we're going to try to establish one asynchronously
+   * @return GNUNET_SYSERR if that is impossible,
+   *         GNUNET_YES if a connection is established upon return,
+   *         GNUNET_NO if we're going to try to establish one asynchronously
    */
-  int (*tryConnect) (const PeerIdentity * peer);
+  int (*tryConnect) (const GNUNET_PeerIdentity * peer);
 
 } Session_ServiceAPI;
 

Modified: GNUnet/src/include/gnunet_sqstore_service.h
===================================================================
--- GNUnet/src/include/gnunet_sqstore_service.h 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_sqstore_service.h 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -62,9 +62,9 @@
   /**
    * Store an item in the datastore.
    *
-   * @return OK on success, SYSERR on error, NO on temporary error
+   * @return GNUNET_OK on success, GNUNET_SYSERR on error, GNUNET_NO on 
temporary error
    */
-  int (*put) (const HashCode512 * key, const Datastore_Value * value);
+  int (*put) (const GNUNET_HashCode * key, const Datastore_Value * value);
 
   /**
    * Iterate over the results for a particular key
@@ -74,10 +74,10 @@
    * @param type entries of which type are relevant?
    *     Use 0 for any type.
    * @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
    */
-  int (*get) (const HashCode512 * key,
+  int (*get) (const GNUNET_HashCode * key,
               unsigned int type, Datum_Iterator iter, void *closure);
 
   /**
@@ -99,10 +99,10 @@
    * @param expire new expiration time should be the
    *     MAX of any existing expiration time and
    *     this value
-   * @return OK if a match was found and the update
-   *     was successful, SYSERR on error
+   * @return GNUNET_OK if a match was found and the update
+   *     was successful, GNUNET_SYSERR on error
    */
-  int (*update) (unsigned long long uid, int delta, cron_t expire);
+  int (*update) (unsigned long long uid, int delta, GNUNET_CronTime expire);
 
   /**
    * Iterate over the items in the datastore in ascending
@@ -111,7 +111,7 @@
    * @param type entries of which type should be considered?
    *        Use 0 for any type.
    * @param iter never NULL
-   * @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
    */
   int (*iterateLowPriority) (unsigned int type,
@@ -123,7 +123,7 @@
    * @param type entries of which type should be considered?
    *        Use 0 for any type.
    * @param iter never NULL
-   * @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
    */
   int (*iterateNonAnonymous) (unsigned int type,
@@ -136,7 +136,7 @@
    * @param type entries of which type should be considered?
    *        Use 0 for any type.
    * @param iter never NULL
-   * @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
    */
   int (*iterateExpirationTime) (unsigned int type,
@@ -148,7 +148,7 @@
    * order.
    *
    * @param iter never NULL
-   * @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
    */
   int (*iterateMigrationOrder) (Datum_Iterator iter, void *closure);
@@ -160,7 +160,7 @@
    * is on doing it fast).
    *
    * @param iter never NULL
-   * @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
    */
   int (*iterateAllNow) (Datum_Iterator iter, void *closure);

Modified: GNUnet/src/include/gnunet_state_service.h
===================================================================
--- GNUnet/src/include/gnunet_state_service.h   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_state_service.h   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -58,7 +58,7 @@
    * @param fn the key for the entry
    * @param len the number of bytes in block
    * @param block the data to store
-   * @return SYSERR on error, OK if ok.
+   * @return GNUNET_SYSERR on error, GNUNET_OK if ok.
    */
   int (*append) (struct GE_Context * ectx,
                  const char *name, int len, const void *block);
@@ -69,7 +69,7 @@
    * @param fn the key for the entry
    * @param len the number of bytes in block
    * @param block the data to store
-   * @return SYSERR on error, OK if ok.
+   * @return GNUNET_SYSERR on error, GNUNET_OK if ok.
    */
   int (*write) (struct GE_Context * ectx,
                 const char *name, int len, const void *block);

Modified: GNUnet/src/include/gnunet_stats_lib.h
===================================================================
--- GNUnet/src/include/gnunet_stats_lib.h       2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_stats_lib.h       2007-11-23 11:51:54 UTC (rev 
5742)
@@ -53,7 +53,7 @@
 /**
  * @param name the name of the datum
  * @param value the value
- * @return OK to continue, SYSERR to abort iteration
+ * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
  */
 typedef int (*STATS_StatProcessor) (const char *name,
                                     unsigned long long value, void *cls);
@@ -62,16 +62,16 @@
  * Request statistics from TCP socket.
  * @param sock the socket to use
  * @param processor function to call on each value
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int STATS_getStatistics (struct GE_Context *ectx,
-                         struct ClientServerConnection *sock,
+                         struct GNUNET_ClientServerConnection *sock,
                          STATS_StatProcessor processor, void *cls);
 
 /**
  * @param type the type ID of the message
- * @param isP2P YES for P2P, NO for CS types
- * @return OK to continue, SYSERR to abort iteration
+ * @param isP2P GNUNET_YES for P2P, GNUNET_NO for CS types
+ * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
  */
 typedef int (*STATS_ProtocolProcessor) (unsigned short type,
                                         int isP2P, void *cls);
@@ -80,10 +80,10 @@
  * Request available protocols from TCP socket.
  * @param sock the socket to use
  * @param processor function to call on each value
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int STATS_getAvailableProtocols (struct GE_Context *ectx,
-                                 struct ClientServerConnection *sock,
+                                 struct GNUNET_ClientServerConnection *sock,
                                  STATS_ProtocolProcessor processor,
                                  void *cls);
 

Modified: GNUnet/src/include/gnunet_testing_lib.h
===================================================================
--- GNUnet/src/include/gnunet_testing_lib.h     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_testing_lib.h     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -52,15 +52,16 @@
  * @param applications application services that should be loaded
  * @param pid of the process (set)
  * @param peer identity of the peer (set)
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int gnunet_testing_start_daemon (unsigned short app_port,
+int GNUNET_TESTING_start_daemon (unsigned short app_port,
                                  unsigned short tra_offset,
                                  const char *gnunetd_home,
                                  const char *transports,
                                  const char *applications,
                                  pid_t * pid,
-                                 PeerIdentity * peer, char **configFile);
+                                 GNUNET_PeerIdentity * peer,
+                                 char **configFile);
 
 /**
  * Establish a connection between two GNUnet daemons
@@ -68,9 +69,9 @@
  *
  * @param port1 client port of the first daemon
  * @param port2 client port of the second daemon
- * @return OK on success, SYSERR on failure
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
-int gnunet_testing_connect_daemons (unsigned short port1,
+int GNUNET_TESTING_connect_daemons (unsigned short port1,
                                     unsigned short port2);
 
 
@@ -78,18 +79,18 @@
  * Shutdown the GNUnet daemon waiting on the given port
  * and running under the given pid.
  *
- * @return OK on success, SYSERR on failure
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
-int gnunet_testing_stop_daemon (unsigned short port, pid_t pid);
+int GNUNET_TESTING_stop_daemon (unsigned short port, pid_t pid);
 
 
 /**
  * Linked list of information about daemon processes.
  */
-struct DaemonContext
+struct GNUNET_TESTING_DaemonContext
 {
-  struct DaemonContext *next;
-  PeerIdentity peer;
+  struct GNUNET_TESTING_DaemonContext *next;
+  GNUNET_PeerIdentity peer;
   pid_t pid;
   unsigned short port;
   char *configFile;
@@ -104,7 +105,7 @@
  *
  * @return handle used to stop the daemons, NULL on error
  */
-struct DaemonContext *gnunet_testing_start_daemons (const char *transports,
+struct GNUNET_TESTING_DaemonContext *GNUNET_TESTING_start_daemons (const char 
*transports,
                                                     const char *applications,
                                                     const char
                                                     *gnunetd_home_prefix,
@@ -115,9 +116,9 @@
 
 /**
  * Stop all of the daemons started with the start function.
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int gnunet_testing_stop_daemons (struct DaemonContext *peers);
+int GNUNET_TESTING_stop_daemons (struct GNUNET_TESTING_DaemonContext *peers);
 
 
 #if 0                           /* keep Emacsens' auto-indent happy */

Modified: GNUnet/src/include/gnunet_topology_service.h
===================================================================
--- GNUnet/src/include/gnunet_topology_service.h        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/include/gnunet_topology_service.h        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -63,7 +63,7 @@
 
   /**
    * Get an estimate of the network size.
-   * @return the estimated number of nodes, SYSERR on error
+   * @return the estimated number of nodes, GNUNET_SYSERR on error
    */
   int (*estimateNetworkSize) (void);
 
@@ -76,9 +76,9 @@
 
   /**
    * Will the topology allow a connection from the specified peer?
-   * @return OK if a connection maybe established, SYSERR if not.
+   * @return GNUNET_OK if a connection maybe established, GNUNET_SYSERR if not.
    */
-  int (*allowConnectionFrom) (const PeerIdentity * peer);
+  int (*allowConnectionFrom) (const GNUNET_PeerIdentity * peer);
 
 
 } Topology_ServiceAPI;

Modified: GNUnet/src/include/gnunet_traffic_lib.h
===================================================================
--- GNUnet/src/include/gnunet_traffic_lib.h     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_traffic_lib.h     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -52,9 +52,9 @@
  * @param time set to the time distribution
  *        bit-vector giving times of interactions,
  *        highest bit is current time-unit, bit 1 is 32 time-units ago (set)
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int gnunet_traffic_poll (struct ClientServerConnection *sock,
+int GNUNET_traffic_poll (struct GNUNET_ClientServerConnection *sock,
                          unsigned int timeframe,
                          unsigned short type,
                          unsigned short direction,

Modified: GNUnet/src/include/gnunet_traffic_service.h
===================================================================
--- GNUnet/src/include/gnunet_traffic_service.h 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_traffic_service.h 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -56,11 +56,11 @@
 #define TC_DIVERSITY_MASK 0xFFF
 
 /**
- * What is the unit of time (in cron_t) for the traffic module? This
+ * What is the unit of time (in GNUNET_CronTime) for the traffic module? This
  * constant essentially specifies the resolution of the distribution
  * function that is applied for sampling traffic. Default is 1s.
  */
-#define TRAFFIC_TIME_UNIT cronSECONDS
+#define TRAFFIC_TIME_UNIT GNUNET_CRON_SECONDS
 
 /**
  * @brief API to the traffic service.
@@ -85,7 +85,7 @@
    * @param time set to the time distribution
    *        bit-vector giving times of interactions,
    *        highest bit is current time-unit, bit 1 is 32 time-units ago (set)
-   * @return OK on success, SYSERR on error
+   * @return GNUNET_OK on success, GNUNET_SYSERR on error
    */
   int (*get) (unsigned int timeframe,
               unsigned short type,

Modified: GNUnet/src/include/gnunet_transport.h
===================================================================
--- GNUnet/src/include/gnunet_transport.h       2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_transport.h       2007-11-23 11:51:54 UTC (rev 
5742)
@@ -66,10 +66,10 @@
   /**
    * The identity of the sender node
    */
-  PeerIdentity sender;
+  GNUNET_PeerIdentity sender;
 
   /**
-   * The message itself. The GNUnet core will call 'FREE' once
+   * The message itself. The GNUnet core will call 'GNUNET_free' once
    * processing of msg is complete.
    */
   char *msg;
@@ -108,7 +108,7 @@
   /**
    * The identity of the local node.
    */
-  PeerIdentity *myIdentity;
+  GNUNET_PeerIdentity *myIdentity;
 
   /**
    * System error context
@@ -123,12 +123,12 @@
   /**
    * System load monitor
    */
-  struct LoadMonitor *load_monitor;
+  struct GNUNET_LoadMonitor *load_monitor;
 
   /**
    * System cron Manager.
    */
-  struct CronManager *cron;
+  struct GNUNET_CronManager *cron;
 
   /**
    * Data was received (potentially encrypted), make the core process
@@ -154,7 +154,7 @@
    * modules are loaded or unloaded inside the module initialization
    * or shutdown code.
    *
-   * @return OK if service was successfully released, SYSERR on error
+   * @return GNUNET_OK if service was successfully released, GNUNET_SYSERR on 
error
    */
   int (*releaseService) (void *service);
 
@@ -191,7 +191,7 @@
    * the transport should never do ANYTHING
    * with it.
    */
-  struct PluginHandle *libHandle;
+  struct GNUNET_PluginHandle *libHandle;
 
   /**
    * The name of the transport, set by the
@@ -206,7 +206,7 @@
    * idea.  The field is updated by a cron job
    * periodically.
    */
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
 
   /**
    * The number of the protocol that is supported by this transport
@@ -235,22 +235,22 @@
    * will only play ping pong after this verification passed.
    * @param hello the hello message to verify
    *        (the signature/crc have been verified before)
-   * @return OK if the helo is well-formed
+   * @return GNUNET_OK if the helo is well-formed
    */
-  int (*verifyHello) (const P2P_hello_MESSAGE * hello);
+  int (*verifyHello) (const GNUNET_MessageHello * hello);
 
   /**
    * Create a hello-Message for the current node. The hello is
    * created without signature, timestamp, senderIdentity
-   * or publicKey. The GNUnet core will sign the message
+   * or publicKey. The GNUnet core will GNUNET_RSA_sign the message
    * and add these other fields. The callee is only
    * responsible for filling in the protocol number,
    * senderAddressSize and the senderAddress itself.
    *
-   * @return OK on success, SYSERR on error (e.g. send-only
-   *  transports return SYSERR here)
+   * @return GNUNET_OK on success, GNUNET_SYSERR on error (e.g. send-only
+   *  transports return GNUNET_SYSERR here)
    */
-  P2P_hello_MESSAGE *(*createhello) (void);
+  GNUNET_MessageHello *(*createhello) (void);
 
   /**
    * Establish a connection to a remote node.
@@ -258,9 +258,9 @@
    * @param hello the hello-Message for the target node
    * @param tsession the session handle that is to be set
    * @param may_reuse can an existing connection be re-used?
-   * @return OK on success, SYSERR if the operation failed
+   * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
    */
-  int (*connect) (const P2P_hello_MESSAGE * hello, TSession ** tsession,
+  int (*connect) (const GNUNET_MessageHello * hello, TSession ** tsession,
                   int may_reuse);
 
   /**
@@ -269,10 +269,10 @@
    *        or the hello_message from connect)
    * @param msg the message
    * @param size the size of the message, <= mtu
-   * @param important YES if message is important (i.e. grow
+   * @param important GNUNET_YES if message is important (i.e. grow
    *        buffers to queue if needed)
-   * @return SYSERR on error, NO on temporary error (retry),
-   *         YES/OK on success; after any persistent error,
+   * @return GNUNET_SYSERR on error, GNUNET_NO on temporary error (retry),
+   *         GNUNET_YES/GNUNET_OK on success; after any persistent error,
    *         the caller must call "disconnect" and not continue
    *         using the session afterwards (useful if the other
    *         side closed the connection).
@@ -288,7 +288,7 @@
    * later, in this case, call disconnect afterwards. This can be used
    * to test if the connection must be closed by the core or if the core
    * can assume that it is going to be self-managed (if associate
-   * returns OK and session was NULL, the transport layer is responsible
+   * returns GNUNET_OK and session was NULL, the transport layer is responsible
    * for eventually freeing resources associated with the tesession). If
    * session is not NULL, the core takes responsbility for eventually
    * calling disconnect.
@@ -296,8 +296,8 @@
    * @param tsession the session handle passed along
    *   from the call to receive that was made by the transport
    *   layer
-   * @return OK if the session could be associated,
-   *         SYSERR if not.
+   * @return GNUNET_OK if the session could be associated,
+   *         GNUNET_SYSERR if not.
    */
   int (*associate) (TSession * tsession);
 
@@ -312,13 +312,13 @@
    * being called from the other side.
    *
    * @param tsession the session that is to be closed
-   * @return OK on success, SYSERR if the operation failed
+   * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
    */
   int (*disconnect) (TSession * tsession);
 
   /**
    * Start the server process to receive inbound traffic.
-   * @return OK on success, SYSERR if the operation failed
+   * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
    */
   int (*startTransportServer) (void);
 
@@ -330,9 +330,9 @@
 
   /**
    * Convert hello to network address.
-   * @return OK on success, SYSERR on error
+   * @return GNUNET_OK on success, GNUNET_SYSERR on error
    */
-  int (*helloToAddress) (const P2P_hello_MESSAGE * hello,
+  int (*helloToAddress) (const GNUNET_MessageHello * hello,
                          void **sa, unsigned int *sa_len);
 
   /**
@@ -343,10 +343,10 @@
    * even bother to construct (and encrypt) this kind
    * of message.
    *
-   * @return YES if the transport would try (i.e. queue
+   * @return GNUNET_YES if the transport would try (i.e. queue
    *         the message or call the OS to send),
-   *         NO if the transport would just drop the message,
-   *         SYSERR if the size/session is invalid
+   *         GNUNET_NO if the transport would just drop the message,
+   *         GNUNET_SYSERR if the size/session is invalid
    */
   int (*testWouldTry) (TSession * tsession, unsigned int size, int important);
 

Modified: GNUnet/src/include/gnunet_transport_service.h
===================================================================
--- GNUnet/src/include/gnunet_transport_service.h       2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/include/gnunet_transport_service.h       2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -61,7 +61,7 @@
 
   /**
    * Is this transport mechanism available (for sending)?
-   * @return YES or NO
+   * @return GNUNET_YES or GNUNET_NO
    */
   int (*isAvailable) (unsigned short ttype);
 
@@ -74,7 +74,7 @@
    * Iterate over all available transport mechanisms.
    * @param callback the method to call on each transport API implementation
    * @param data second argument to callback
-   * @return number of transports, SYSERR on error
+   * @return number of transports, GNUNET_SYSERR on error
    */
   int (*forEach) (TransportCallback callback, void *data);
 
@@ -90,7 +90,7 @@
    *              (must match when disconnect is called)
    * @return session handle on success, NULL on error
    */
-  TSession *(*connect) (const P2P_hello_MESSAGE * hello, const char *token,
+  TSession *(*connect) (const GNUNET_MessageHello * hello, const char *token,
                         int may_reuse);
 
   /**
@@ -104,8 +104,8 @@
    *              (must match when disconnect is called)
    * @return session handle on success, NULL on error
    */
-  TSession *(*connectFreely) (const PeerIdentity * peer, int allowTempList,
-                              const char *token);
+  TSession *(*connectFreely) (const GNUNET_PeerIdentity * peer,
+                              int allowTempList, const char *token);
 
   /**
    * A (core) Session is to be associated with a transport session. The
@@ -119,8 +119,8 @@
    *   layer
    * @param token string identifying who is holding the reference
    *              (must match when disconnect is called)
-   * @return OK if the session could be associated,
-   *         SYSERR if not.
+   * @return GNUNET_OK if the session could be associated,
+   *         GNUNET_SYSERR if not.
    */
   int (*associate) (TSession * tsession, const char *token);
 
@@ -136,7 +136,7 @@
    * @param msg the message to send
    * @param size the size of the message
    * @param important the message is important
-   * @return OK on success, SYSERR on persistent error, NO on
+   * @return GNUNET_OK on success, GNUNET_SYSERR on persistent error, 
GNUNET_NO on
    *         temporary error
    */
   int (*send) (TSession * session,
@@ -148,24 +148,24 @@
    * @param token string identifying who is holding the reference
    *              (must match when connect/assciate call)
    *
-   * @return OK on success, SYSERR on error
+   * @return GNUNET_OK on success, GNUNET_SYSERR on error
    */
   int (*disconnect) (TSession * session, const char *token);
 
   /**
    * Verify that a hello is ok. Call a method
    * if the verification was successful.
-   * @return OK if the attempt to verify is on the way,
-   *        SYSERR if the transport mechanism is not supported
+   * @return GNUNET_OK if the attempt to verify is on the way,
+   *        GNUNET_SYSERR if the transport mechanism is not supported
    */
-  int (*verifyhello) (const P2P_hello_MESSAGE * hello);
+  int (*verifyhello) (const GNUNET_MessageHello * hello);
 
   /**
    * Get the network address from a HELLO.
    *
-   * @return OK on success, SYSERR on error
+   * @return GNUNET_OK on success, GNUNET_SYSERR on error
    */
-  int (*helloToAddress) (const P2P_hello_MESSAGE * hello,
+  int (*helloToAddress) (const GNUNET_MessageHello * hello,
                          void **sa, unsigned int *sa_len);
 
   /**
@@ -177,7 +177,7 @@
    * Create a hello advertisement for the given
    * transport type for this node.
    */
-  P2P_hello_MESSAGE *(*createhello) (unsigned short ttype);
+  GNUNET_MessageHello *(*createhello) (unsigned short ttype);
 
   /**
    * Get a message consisting of (if possible) all addresses that this
@@ -202,10 +202,10 @@
    * even bother to construct (and encrypt) this kind
    * of message.
    *
-   * @return YES if the transport would try (i.e. queue
+   * @return GNUNET_YES if the transport would try (i.e. queue
    *         the message or call the OS to send),
-   *         NO if the transport would just drop the message,
-   *         SYSERR if the size/session is invalid
+   *         GNUNET_NO if the transport would just drop the message,
+   *         GNUNET_SYSERR if the size/session is invalid
    */
   int (*testWouldTry) (TSession * tsession, unsigned int size, int important);
 

Modified: GNUnet/src/include/gnunet_upnp_service.h
===================================================================
--- GNUnet/src/include/gnunet_upnp_service.h    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_upnp_service.h    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -47,9 +47,10 @@
    * Get the external IP address for the local machine.
    * @param protocol "UDP" or "TCP".
    *
-   * @return SYSERR on error, OK on success
+   * @return GNUNET_SYSERR on error, GNUNET_OK on success
    */
-  int (*get_ip) (unsigned short port, const char *protocol, IPaddr * address);
+  int (*get_ip) (unsigned short port, const char *protocol,
+                 GNUNET_IPv4Address * address);
 
 } UPnP_ServiceAPI;
 

Modified: GNUnet/src/include/gnunet_uritrack_lib.h
===================================================================
--- GNUnet/src/include/gnunet_uritrack_lib.h    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_uritrack_lib.h    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -40,7 +40,7 @@
 /**
  * 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 URITRACK_trackURIS (struct GE_Context *ectx, struct GC_Configuration 
*cfg, int onOff);     /* file_info.c */
@@ -53,7 +53,7 @@
 /**
  * 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);       /* file_info.c */
 
@@ -67,8 +67,8 @@
 /**
  * List all URIs.
  *
- * @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)
  */
 int URITRACK_listURIs (struct GE_Context *ectx, struct GC_Configuration *cfg, 
int need_metadata, ECRS_SearchProgressCallback iterator, void *closure);  /* 
file_info.c */
 
@@ -109,7 +109,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

Modified: GNUnet/src/include/gnunet_util.h
===================================================================
--- GNUnet/src/include/gnunet_util.h    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/include/gnunet_util.h    2007-11-23 11:51:54 UTC (rev 5742)
@@ -55,6 +55,12 @@
 #include "gnunet_util_getopt.h"
 #include "gnunet_util_network.h"
 #include "gnunet_util_os.h"
+#include "gnunet_util_network_client.h"
+#include "gnunet_util_crypto.h"
+#include "gnunet_util_error_loggers.h"
+#include "gnunet_util_containers.h"
+#include "gnunet_util_cron.h"
+#include "gnunet_util_boot.h"
 
 #ifdef __cplusplus
 extern "C"
@@ -76,7 +82,7 @@
  * especially the least significant bits may change
  * frequently, even between different SVN versions.
  */
-#define GNUNET_UTIL_VERSION 0x00070202
+#define GNUNET_UTIL_VERSION 0x00070203
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

Modified: GNUnet/src/include/gnunet_util_boot.h
===================================================================
--- GNUnet/src/include/gnunet_util_boot.h       2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_util_boot.h       2007-11-23 11:51:54 UTC (rev 
5742)
@@ -55,7 +55,7 @@
                  char *const *argv,
                  const char *binaryName,
                  char **configurationFileName,
-                 const struct CommandLineOption *options,
+                 const struct GNUNET_CommandLineOption *options,
                  struct GE_Context **ectx, struct GC_Configuration **cfg);
 
 /**

Modified: GNUnet/src/include/gnunet_util_common.h
===================================================================
--- GNUnet/src/include/gnunet_util_common.h     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_util_common.h     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -30,13 +30,13 @@
 
 /**
  * Named constants for return values.  The following
- * invariants hold: "NO == 0" (to allow "if (NO)")
- * "OK != SYSERR", "OK != NO", "NO != SYSERR"
- * and finally "YES != NO".
+ * invariants hold: "GNUNET_NO == 0" (to allow "if (GNUNET_NO)")
+ * "GNUNET_OK != GNUNET_SYSERR", "GNUNET_OK != GNUNET_NO", "GNUNET_NO != 
GNUNET_SYSERR"
+ * and finally "GNUNET_YES != GNUNET_NO".
  */
-#define OK      1
-#define SYSERR -1
-#define YES     1
-#define NO      0
+#define GNUNET_OK      1
+#define GNUNET_SYSERR -1
+#define GNUNET_YES     1
+#define GNUNET_NO      0
 
 #endif /*GNUNET_UTIL_COMMON_H_ */

Modified: GNUnet/src/include/gnunet_util_config.h
===================================================================
--- GNUnet/src/include/gnunet_util_config.h     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_util_config.h     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -98,7 +98,7 @@
 
 /**
  * Test if we have a value for a particular option
- * @return YES if so, NO if not.
+ * @return GNUNET_YES if so, GNUNET_NO if not.
  */
 int GC_have_configuration_value (struct GC_Configuration *cfg,
                                  const char *section, const char *option);
@@ -150,11 +150,11 @@
 
 /**
  * Get a configuration value that should be in a set of
- * "YES" or "NO".
+ * "GNUNET_YES" or "GNUNET_NO".
  *
  * @param def default value (use indicated by return value;
  *        will NOT be aliased, maybe NULL)
- * @return YES, NO or SYSERR
+ * @return GNUNET_YES, GNUNET_NO or GNUNET_SYSERR
  */
 int GC_get_configuration_value_yesno (struct GC_Configuration *cfg,
                                       const char *section,
@@ -238,7 +238,12 @@
 int GC_detach_change_listener (struct GC_Configuration *cfg,
                                GC_ChangeListener callback, void *ctx);
 
+/**
+ * Create a GC_Configuration
+ */
+struct GC_Configuration *GC_create (void);
 
+
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif

Deleted: GNUnet/src/include/gnunet_util_config_impl.h
===================================================================
--- GNUnet/src/include/gnunet_util_config_impl.h        2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/include/gnunet_util_config_impl.h        2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -1,233 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2006 Christian Grothoff (and other contributing authors)
-
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-*/
-
-/**
- * @file include/gnunet_config_impl.h
- * @brief configuration API
- *
- * @author Christian Grothoff
- */
-
-#ifndef GNUNET_UTIL_CONFIG_IMPL_H
-#define GNUNET_UTIL_CONFIG_IMPL_H
-
-#include "gnunet_util_config.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#if 0                           /* keep Emacsens' auto-indent happy */
-}
-#endif
-#endif
-
-struct GC_ConfigurationData;
-
-typedef struct GC_Configuration
-{
-
-  /**
-   * Internal configuration data.
-   */
-  struct GC_ConfigurationData *data;
-
-  void (*free) (struct GC_Configuration * cfg);
-
-  /**
-   * Set the context for reporting configuration IO errors
-   * (and errors reported by configuration change notification
-   * callbacks when reading a new configuration).
-   *
-   * Note that for setting options a different context can be
-   * used (since failing to change an option may have to be reported
-   * in a fundamentally different way to the user).
-   *
-   * @parm ectx maybe NULL, in that case errors will no longer
-   *       be reported
-   */
-  void (*set_error_context) (struct GC_Configuration * cfg,
-                             struct GE_Context * ectx);
-
-  /**
-   * Parse a configuration file, add all of the options in the
-   * file to the configuration environment.
-   * @return 0 on success, -1 on error
-   */
-  int (*parse_configuration) (struct GC_Configuration * cfg,
-                              const char *filename);
-
-  /**
-   * Test if there are configuration options that were
-   * changed since the last save.
-   * @return 0 if clean, 1 if dirty, -1 on error (i.e. last save failed)
-   */
-  int (*test_dirty) (struct GC_Configuration * cfg);
-
-
-  /**
-   * Write configuration file.
-   * @return 0 on success, -1 on error
-   */
-  int (*write_configuration) (struct GC_Configuration * cfg,
-                              const char *filename);
-
-
-  /**
-   * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR"
-   * where either in the current section or globally FOO is set to
-   * DIRECTORY.
-   *
-   * @param old string to $-expand (will be freed!)
-   * @return $-expanded string
-   */
-  char *(*configuration_expand_dollar) (struct GC_Configuration * cfg,
-                                        char *old);
-
-  /**
-   * Get a configuration value that should be a number.
-   * @param min minimal legal value
-   * @param max maximal legal value
-   * @param def default value (use indicated by return value)
-   * @return 0 on success, -1 on error, 1 for default
-   */
-  int (*get_configuration_value_number) (struct GC_Configuration * cfg,
-                                         const char *section,
-                                         const char *option,
-                                         unsigned long long min,
-                                         unsigned long long max,
-                                         unsigned long long def,
-                                         unsigned long long *number);
-
-
-  /**
-   * Get a configuration value that should be a string.
-   * @param default default value (use indicated by return value;
-   *        will NOT be aliased, maybe NULL)
-   * @param value will be set to a freshly allocated configuration
-   *        value, or NULL if option is not specified and no default given
-   * @return 0 on success, -1 on error, 1 for default
-   */
-  int (*get_configuration_value_string) (struct GC_Configuration * cfg,
-                                         const char *section,
-                                         const char *option,
-                                         const char *def, char **value);
-
-  /**
-   * Get a configuration value that should be a file name.
-   * @param default default value (use indicated by return value;
-   *        will NOT be aliased, maybe NOT be NULL)
-   * @param value will be set to a freshly allocated configuration
-   *        value, or NULL if option is not specified and no default given
-   * @return 0 on success, -1 on error, 1 for default
-   */
-  int (*get_configuration_value_filename) (struct GC_Configuration * cfg,
-                                           const char *section,
-                                           const char *option,
-                                           const char *def, char **value);
-
-  /**
-   * Get a configuration value that should be in a set of
-   * predefined strings
-   * @param choices NULL-terminated list of legal values
-   * @param default default value (use indicated by return value;
-   *        will NOT be aliased, maybe NULL), must be reference
-   *        into set given by choices
-   * @param value will be set to an entry in the legal list,
-   *        or NULL if option is not specified and no default given
-   * @return 0 on success, -1 on error, 1 for default
-   */
-  int (*get_configuration_value_choice) (struct GC_Configuration * cfg,
-                                         const char *section,
-                                         const char *option,
-                                         const char **choices,
-                                         const char *def, const char **value);
-
-  /**
-   * Set a configuration value that should be a number.
-   * @return 0 on success, -1 on error (i.e. out of memory,
-   *   or update refused by registered callback)
-   */
-  int (*set_configuration_value_number) (struct GC_Configuration * cfg,
-                                         struct GE_Context * ectx,
-                                         const char *section,
-                                         const char *option,
-                                         unsigned long long number);
-
-
-  /**
-   * Set a configuration value that should be a string.
-   * @param value
-   * @return 0 on success, -1 on error (i.e. out of memory,
-   *   or update refused by registered callback)
-   */
-  int (*set_configuration_value_string) (struct GC_Configuration * cfg,
-                                         struct GE_Context * ectx,
-                                         const char *section,
-                                         const char *option,
-                                         const char *value);
-
-  /**
-   * Set a configuration value that should be in a set of
-   * predefined strings.
-   * @param value
-   * @return 0 on success, -1 on error (i.e. out of memory,
-   *   or update refused by registered callback)
-   */
-  int (*set_configuration_value_choice) (struct GC_Configuration * cfg,
-                                         struct GE_Context * ectx,
-                                         const char *section,
-                                         const char *option,
-                                         const char *choice);
-
-  /**
-   * Attach a callback that is notified whenever a
-   * configuration option changes.
-   * @return 0 on success, -1 on error
-   */
-  int (*attach_change_listener) (struct GC_Configuration * cfg,
-                                 GC_ChangeListener callback, void *ctx);
-
-  /**
-   * Attach a callback that is notified whenever a
-   * configuration option changes.
-   * @return 0 on success, -1 on error, 1 for no such handler registered
-   */
-  int (*detach_change_listener) (struct GC_Configuration * cfg,
-                                 GC_ChangeListener callback, void *ctx);
-
-  int (*have_configuration_value) (struct GC_Configuration * cfg,
-                                   const char *section, const char *option);
-
-} GC_Configuration;
-
-/**
- * Create a GC_Configuration (C implementation).
- */
-GC_Configuration *GC_create_C_impl (void);
-
-
-#if 0                           /* keep Emacsens' auto-indent happy */
-{
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-#endif

Modified: GNUnet/src/include/gnunet_util_containers.h
===================================================================
--- GNUnet/src/include/gnunet_util_containers.h 2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_util_containers.h 2007-11-23 11:51:54 UTC (rev 
5742)
@@ -28,8 +28,6 @@
  * @author Ioana Patrascu
  * @author Tzvetan Horozov
  * @author Nils Durner
- *
- * TODO: refactor APIs (more consistent naming conventions, etc.)
  */
 
 #ifndef GNUNET_UTIL_CONTAINERS_H
@@ -50,57 +48,56 @@
 /**
  * @brief bloomfilter representation (opaque)
  */
-struct Bloomfilter;
+struct GNUNET_BloomFilter;
 
 /**
- * Iterator over all HashCodes stored in a Bloomfilter.
+ * Iterator over HashCodes.
  */
-typedef HashCode512 *(*ElementIterator) (void *arg);
+typedef GNUNET_HashCode *(*GNUNET_HashCodeIterator) (void *arg);
 
 /**
- * @brief a Vector (ordered variable size set of elements), opaque
+ * @brief a GNUNET_Vector (ordered variable size set of elements), opaque
  */
-struct Vector;
+struct GNUNET_Vector;
 
 /**
- * @brief a hash table, opaque
- */
-struct HashTable;
-
-/**
  * Load a bloom-filter from a file.
  * @param filename the name of the file (or the prefix)
  * @param size the size of the bloom-filter (number of
  *        bytes of storage space to use)
- * @param k the number of hash-functions to apply per
+ * @param k the number of GNUNET_hash-functions to apply per
  *        element (number of bits set per element in the set)
  * @return the bloomfilter
  */
-struct Bloomfilter *loadBloomfilter (struct GE_Context *ectx,
-                                     const char *filename,
-                                     unsigned int size, unsigned int k);
+struct GNUNET_BloomFilter *GNUNET_bloomfilter_load (struct GE_Context *ectx,
+                                                    const char *filename,
+                                                    unsigned int size,
+                                                    unsigned int k);
 
 /**
  * Test if an element is in the filter.
  * @param e the element
  * @param bf the filter
- * @return YES if the element is in the filter, NO if not
+ * @return GNUNET_YES if the element is in the filter, GNUNET_NO if not
  */
-int testBloomfilter (struct Bloomfilter *bf, const HashCode512 * e);
+int GNUNET_bloomfilter_test (struct GNUNET_BloomFilter *bf,
+                             const GNUNET_HashCode * e);
 
 /**
  * Add an element to the filter
  * @param bf the filter
  * @param e the element
  */
-void addToBloomfilter (struct Bloomfilter *bf, const HashCode512 * e);
+void GNUNET_bloomfilter_add (struct GNUNET_BloomFilter *bf,
+                             const GNUNET_HashCode * e);
 
 /**
  * Remove an element from the filter.
  * @param bf the filter
  * @param e the element to remove
  */
-void delFromBloomfilter (struct Bloomfilter *bf, const HashCode512 * e);
+void GNUNET_bloomfilter_remove (struct GNUNET_BloomFilter *bf,
+                                const GNUNET_HashCode * e);
 
 /**
  * Free the space associcated with a filter
@@ -108,13 +105,13 @@
  * free the space on the drive)
  * @param bf the filter
  */
-void freeBloomfilter (struct Bloomfilter *bf);
+void GNUNET_bloomfilter_free (struct GNUNET_BloomFilter *bf);
 
 /**
  * Reset a bloom filter to empty.
  * @param bf the filter
  */
-void resetBloomfilter (struct Bloomfilter *bf);
+void GNUNET_bloomfilter_clear (struct GNUNET_BloomFilter *bf);
 
 /**
  * Resize a bloom filter.  Note that this operation
@@ -125,17 +122,17 @@
  * @param iterator an iterator over all elements stored in the BF
  * @param iterator_arg argument to the iterator function
  * @param size the new size for the filter
- * @param k the new number of hash-function to apply per element
+ * @param k the new number of GNUNET_hash-function to apply per element
  */
-void resizeBloomfilter (struct Bloomfilter *bf,
-                        ElementIterator iterator,
-                        void *iterator_arg,
-                        unsigned int size, unsigned int k);
+void GNUNET_bloomfilter_resize (struct GNUNET_BloomFilter *bf,
+                                GNUNET_HashCodeIterator iterator,
+                                void *iterator_arg,
+                                unsigned int size, unsigned int k);
 
 /**
  * A debug function that dumps the vector to stderr.
  */
-void vectorDump (struct Vector *v);
+void GNUNET_vector_dump (struct GNUNET_Vector *v);
 
 /**
  * @param vss Size of the VectorSegment data area. The "correct" value for this
@@ -145,261 +142,116 @@
  * or otherwise the increased length of the linked list will become a
  * bottleneck for operations that are performed on arbitrary indexes.
  */
-struct Vector *vectorNew (unsigned int vss);
+struct GNUNET_Vector *GNUNET_vector_create (unsigned int vss);
 
 /**
  * Free vector structure including its data segments, but _not_ including the
  * stored void pointers. It is the user's responsibility to empty the vector
  * when necessary to avoid memory leakage.
  */
-void vectorFree (struct Vector *v);
+void GNUNET_vector_destroy (struct GNUNET_Vector *v);
 
-size_t vectorSize (struct Vector *v);
+size_t GNUNET_vector_get_size (struct GNUNET_Vector *v);
 
 /**
  * Insert a new element in the vector at given index.
- * @return OK on success, SYSERR if the index is out of bounds.
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the index is out of bounds.
  */
-int vectorInsertAt (struct Vector *v, void *object, unsigned int index);
+int GNUNET_vector_insert_at (struct GNUNET_Vector *v, void *object,
+                             unsigned int index);
 
 /**
  * Insert a new element at the end of the vector.
  */
-void vectorInsertLast (struct Vector *v, void *object);
+void GNUNET_vector_insert_last (struct GNUNET_Vector *v, void *object);
 
 /**
  * Return the element at given index in the vector or NULL if the index is out
  * of bounds. The iterator is set to point to the returned element.
  */
-void *vectorGetAt (struct Vector *v, unsigned int index);
+void *GNUNET_vector_get (struct GNUNET_Vector *v, unsigned int index);
 
 /**
  * Return the first element in the vector, whose index is 0, or NULL if the
  * vector is empty. The iterator of the vector is set to point to the first
  * element.
  */
-void *vectorGetFirst (struct Vector *v);
+void *GNUNET_vector_get_first (struct GNUNET_Vector *v);
 
 /**
  * Return the last element in the vector or NULL if the vector is empty. The
  * iterator of the vector is set to point to the last element.
  */
-void *vectorGetLast (struct Vector *v);
+void *GNUNET_vector_get_last (struct GNUNET_Vector *v);
 
 /**
  * Return the next element in the vector, as called after vector_get_at() or
  * vector_get_first(). The return value is NULL if there are no more elements
  * in the vector or if the iterator has not been set.
  */
-void *vectorGetNext (struct Vector *v);
+void *GNUNET_vector_get_next (struct GNUNET_Vector *v);
 
 /**
  * Return the previous element in the vector, as called after vector_get_at()
  * or vector_get_last(). The return value is NULL if there are no more
  * elements in the vector or if the iterator has not been set.
  */
-void *vectorGetPrevious (struct Vector *v);
+void *GNUNET_vector_get_prev (struct GNUNET_Vector *v);
 
 /**
  * Delete and return the element at given index. NULL is returned if index is
  * out of bounds.
  */
-void *vectorRemoveAt (struct Vector *v, unsigned int index);
+void *GNUNET_vector_delete_at (struct GNUNET_Vector *v, unsigned int index);
 
 /**
  * Delete and return the last element in the vector, or NULL if the vector
  * is empty.
  */
-void *vectorRemoveLast (struct Vector *v);
+void *GNUNET_vector_delete_last (struct GNUNET_Vector *v);
 
 /**
  * Delete and return given object from the vector, or return NULL if the object
  * is not found.
  */
-void *vectorRemoveObject (struct Vector *v, void *object);
+void *GNUNET_vector_delete (struct GNUNET_Vector *v, void *object);
 
 /**
  * Set the given index in the vector. The old value of the index is
  * returned, or NULL if the index is out of bounds.
  */
-void *vectorSetAt (struct Vector *v, void *object, unsigned int index);
+void *GNUNET_vector_update_at (struct GNUNET_Vector *v, void *object,
+                               unsigned int index);
 
 /**
  * Set the index occupied by the given object to point to the new object.
  * The old object is returned, or NULL if it's not found.
  */
-void *vectorSetObject (struct Vector *v, void *object, void *old_object);
+void *GNUNET_vector_update (struct GNUNET_Vector *v, void *object,
+                            void *old_object);
 
 /**
- * Swaps the contents of index1 and index2. Return value is OK
- * on success, SYSERR if either index is out of bounds.
+ * Swaps the contents of index1 and index2. Return value is GNUNET_OK
+ * on success, GNUNET_SYSERR if either index is out of bounds.
  */
-int vectorSwap (struct Vector *v, unsigned int index1, unsigned int index2);
+int GNUNET_vector_swap_elements (struct GNUNET_Vector *v, unsigned int index1,
+                                 unsigned int index2);
 
 /**
  * Return the index of given element or -1 if the element is not found.
  */
-unsigned int vectorIndexOf (struct Vector *v, void *object);
+unsigned int GNUNET_vector_index_of (struct GNUNET_Vector *v, void *object);
 
 /**
  * Return the data stored in the vector as a single dynamically
- * allocated array of (void *), which must be FREEed by the caller.
+ * allocated array of (void *), which must be GNUNET_freeed by the caller.
  * Use the functions get_{at,first,last,next,previous} instead, unless
  * you really need to access everything in the vector as fast as
  * possible.
  */
-void **vectorElements (struct Vector *v);
+void **GNUNET_vector_to_array (struct GNUNET_Vector *v);
 
-/**
- * @brief creates a new HashTable
- * @param numOfBuckets the number of buckets to start the HashTable out with.
- *                     Must be greater than zero, and should be prime.
- *                     Ideally, the number of buckets should between 1/5
- *                     and 1 times the expected number of elements in the
- *                     HashTable.  Values much more or less than this will
- *                     result in wasted memory or decreased performance
- *                     respectively.  The number of buckets in a HashTable
- *                     can be re-calculated to an appropriate number by
- *                     calling the HashTableRehash() function once the
- *                     HashTable has been populated.  The number of buckets
- *                     in a HashTable may also be re-calculated
- *                     automatically if the ratio of elements to buckets
- *                     passes the thresholds set by ht_setIdealRatio().
- * @return a new Hashtable, or NULL on error
- */
-struct HashTable *ht_create (long numOfBuckets);
 
-/**
- * @brief destroys an existing HashTable
- * @param hashTable the HashTable to destroy
- */
-void ht_destroy (struct HashTable *hashTable);
-
-/**
- * @brief checks the existence of a key in a HashTable
- * @param hashTable the HashTable to search
- * @param key the key to search for
- * @return whether or not the specified HashTable contains the
- *         specified key
- */
-int ht_containsKey (const struct HashTable *hashTable, const void *key,
-                    const unsigned int keylen);
-
-/**
- * @brief checks the existence of a value in a HashTable
- * @param hashTable the HashTable to search
- * @param value the value to search for
- * @return whether or not the specified HashTable contains the
- *         specified value
- */
-int ht_containsValue (const struct HashTable *hashTable, const void *value,
-                      const unsigned int valuelen);
-
-/**
- * @brief adds a key/value pair to a HashTable
- * @param hashTable the HashTable to add to
- * @param key the key to add or whose value to replace
- * @param value the value associated with the key
- * @return 0 if successful, -1 if an error was encountered
- */
-int ht_put (struct HashTable *hashTable,
-            const void *key,
-            const unsigned int keylen,
-            void *value, const unsigned int valuelen);
-
-/**
- * @brief retrieves the value of a key in a HashTable
- * @param hashTable the HashTable to search
- * @param key the key whose value is desired
- * @param value the corresponding value
- * @param valuelen the length of the value
- * @return YES if found, NO otherwise
- */
-int ht_get (const struct HashTable *hashTable,
-            const void *key,
-            const unsigned int keylen, void **value, unsigned int *valuelen);
-
-/**
- * @brief removes a key/value pair from a HashTable
- * @param hashTable the HashTable to remove the key/value pair from
- * @param key the key specifying the key/value pair to be removed
- */
-void ht_remove (struct HashTable *hashTable,
-                const void *key, const unsigned int keylen);
-
-/**
- * @brief removes all key/value pairs from a HashTable
- * @param hashTable the HashTable to remove all key/value pairs from
- */
-void ht_removeAll (struct HashTable *hashTable);
-
-/**
- * @brief returns the number of elements in a HashTable
- * @param hashTable the HashTable whose size is requested
- * @return the number of key/value pairs that are present in
- *         the specified HashTable
- */
-long ht_size (const struct HashTable *hashTable);
-
-/**
- * @brief returns the number of buckets in a HashTable
- * @param hashTable the HashTable whose number of buckets is requested
- * @return the number of buckets that are in the specified
- *         HashTable
- */
-long ht_buckets (const struct HashTable *hashTable);
-
-/**
- * @brief reorganizes a HashTable to be more efficient
- * @param hashTable the HashTable to be reorganized
- * @param numOfBuckets the number of buckets to rehash the HashTable to.
- *                     Should be prime.  Ideally, the number of buckets
- *                     should be between 1/5 and 1 times the expected
- *                     number of elements in the HashTable.  Values much
- *                     more or less than this will result in wasted memory
- *                     or decreased performance respectively.  If 0 is
- *                     specified, an appropriate number of buckets is
- *                     automatically calculated.
- */
-void ht_rehash (struct HashTable *hashTable, long numOfBuckets);
-
-/**
- * @brief sets the ideal element-to-bucket ratio of a HashTable
- * @param hashTable a HashTable
- * @param idealRatio the ideal element-to-bucket ratio.  When a rehash
- *                   occurs (either manually via a call to the
- *                   HashTableRehash() function or automatically due the
- *                   the triggering of one of the thresholds below), the
- *                   number of buckets in the HashTable will be
- *                   recalculated to be a prime number that achieves (as
- *                   closely as possible) this ideal ratio.  Must be a
- *                   positive number.
- * @param lowerRehashThreshold the element-to-bucket ratio that is considered
- *                     unacceptably low (i.e., too few elements per bucket).
- *                     If the actual ratio falls below this number, a
- *                     rehash will automatically be performed.  Must be
- *                     lower than the value of idealRatio.  If no ratio
- *                     is considered unacceptably low, a value of 0.0 can
- *                     be specified.
- * @param upperRehashThreshold the element-to-bucket ratio that is considered
- *                     unacceptably high (i.e., too many elements per bucket).
- *                     If the actual ratio rises above this number, a
- *                     rehash will automatically be performed.  Must be
- *                     higher than idealRatio.  However, if no ratio
- *                     is considered unacceptably high, a value of 0.0 can
- *                     be specified.
- */
-void ht_setIdealRatio (struct HashTable *hashTable,
-                       float idealRatio,
-                       float lowerRehashThreshold,
-                       float upperRehashThreshold);
-
-#define HT_PUT(ht, key, val) ht_put(ht, key, sizeof(key), val, sizeof(val))
-#define HT_GET(ht, key, val, vallen) ht_get(ht, key, sizeof(key), val, vallen)
-#define HT_CONTAINS_KEY(ht, key) ht_containsKey(ht, key, sizeof(key))
-#define HT_CONTAINS_VALUE(ht, value) ht_containsValue(ht, value, sizeof(value))
-#define HT_REMOVE(ht, key) ht_remove(ht, key, sizeof(key))
-
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif

Modified: GNUnet/src/include/gnunet_util_core.h
===================================================================
--- GNUnet/src/include/gnunet_util_core.h       2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_util_core.h       2007-11-23 11:51:54 UTC (rev 
5742)
@@ -36,7 +36,7 @@
  * (if we fall below this, strong countermeasures
  * maybe used).
  */
-#define MIN_CONNECTION_TARGET 4
+#define GNUNET_MIN_CONNECTION_TARGET 4
 
 /**
  * Until which load do we consider the peer overly idle
@@ -46,41 +46,41 @@
  * to consume resources "idly" (i.e. up to 85%) and then
  * still have some room for "paid for" resource consumption.
  */
-#define IDLE_LOAD_THRESHOLD 70
+#define GNUNET_IDLE_LOAD_THRESHOLD 70
 
 /**
  * @brief hello.  A hello body contains the current HostAddress, the
- * host identity (hash), the time how long the HostAddress is valid, a
+ * host identity (GNUNET_hash), the time how long the HostAddress is valid, a
  * signature signing the information above and the public key of the
- * host.  The hash of the public key must match the host identity.<p>
+ * host.  The GNUNET_hash of the public key must match the host identity.<p>
  *
- * The signature goes over the message starting at the PeerIdentity
+ * The signature goes over the message starting at the GNUNET_PeerIdentity
  * and includes the senderAddress.  Since the senderAddress may be
- * long, what is actually signed is the hash of these bytes.
+ * long, what is actually signed is the GNUNET_hash of these bytes.
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * The signature
    */
-  Signature signature;
+  GNUNET_RSA_Signature signature;
 
   /**
    * The public key
    */
-  PublicKey publicKey;
+  GNUNET_RSA_PublicKey publicKey;
 
   /**
-   * Whose identity follows? Must be hash of PublicKey.
+   * Whose identity follows? Must be GNUNET_hash of GNUNET_RSA_PublicKey.
    */
-  PeerIdentity senderIdentity;
+  GNUNET_PeerIdentity senderIdentity;
 
   /**
    * time this address expires  (network byte order)
    */
-  TIME_T expirationTime;
+  GNUNET_Int32Time expirationTime;
 
   /**
    * advertised MTU for sending (replies can have a different
@@ -101,9 +101,9 @@
    */
   unsigned short protocol;
 
-} P2P_hello_MESSAGE;
+} GNUNET_MessageHello;
 
-#define P2P_hello_MESSAGE_size(hello) ((sizeof(P2P_hello_MESSAGE) + 
ntohs((hello)->senderAddressSize)))
+#define GNUNET_sizeof_hello(hello) ((sizeof(GNUNET_MessageHello) + 
ntohs((hello)->senderAddressSize)))
 
 
 

Modified: GNUnet/src/include/gnunet_util_cron.h
===================================================================
--- GNUnet/src/include/gnunet_util_cron.h       2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_util_cron.h       2007-11-23 11:51:54 UTC (rev 
5742)
@@ -43,42 +43,42 @@
 /**
  * Type of a cron-job method.
  */
-typedef void (*CronJob) (void *);
+typedef void (*GNUNET_CronJob) (void *);
 
-struct CronManager;
+struct GNUNET_CronManager;
 
-struct CronManager *cron_create (struct GE_Context *ectx);
+struct GNUNET_CronManager *cron_create (struct GE_Context *ectx);
 
-void cron_destroy (struct CronManager *mgr);
+void GNUNET_cron_destroy (struct GNUNET_CronManager *mgr);
 
-void cron_start (struct CronManager *mgr);
+void GNUNET_cron_start (struct GNUNET_CronManager *mgr);
 
-void cron_stop (struct CronManager *mgr);
+void GNUNET_cron_stop (struct GNUNET_CronManager *mgr);
 
 /**
  * Stop running cron-jobs for a short time.  This method may only be
  * called by a thread that is not holding any locks.  It will cause
  * a deadlock if this method is called from within a cron-job and
- * checkself is NO.  If checkself is YES and this method is called
+ * checkself is GNUNET_NO.  If checkself is GNUNET_YES and this method is 
called
  * within a cron-job, nothing happens.
  *
- * @param checkself, if YES and this thread is the cron thread, do nothing
+ * @param checkself, if GNUNET_YES and this thread is the cron thread, do 
nothing
  */
-void cron_suspend (struct CronManager *mgr, int checkself);
+void GNUNET_cron_suspend_jobs (struct GNUNET_CronManager *mgr, int checkself);
 
 /**
  * Resume running cron-jobs.  Call must be matched by
  * previous call to cron_suspend_jobs with identical
  * arguments.
  *
- * @param checkself, if YES and this thread is the cron thread, do nothing
+ * @param checkself, if GNUNET_YES and this thread is the cron thread, do 
nothing
  */
-void cron_resume_jobs (struct CronManager *mgr, int checkself);
+void GNUNET_cron_resume_jobs (struct GNUNET_CronManager *mgr, int checkself);
 
 /**
  * Is the cron-thread currently running?
  */
-int cron_test_running (struct CronManager *mgr);
+int GNUNET_cron_test_running (struct GNUNET_CronManager *mgr);
 
 /**
  * Add a cron-job to the delta list.
@@ -88,9 +88,10 @@
  *        the runs, otherwise 0.
  * @param data argument to pass to the method
  */
-void cron_add_job (struct CronManager *mgr,
-                   CronJob method,
-                   unsigned int delta, unsigned int deltaRepeat, void *data);
+void GNUNET_cron_add_job (struct GNUNET_CronManager *mgr,
+                          GNUNET_CronJob method,
+                          unsigned int delta, unsigned int deltaRepeat,
+                          void *data);
 
 /**
  * If the specified cron-job exists in th delta-list, move it to the
@@ -104,8 +105,9 @@
  *        non-null and cron is shutdown before the job is
  *        run and/or delCronJob is called
  */
-void cron_advance_job (struct CronManager *mgr,
-                       CronJob method, unsigned int deltaRepeat, void *data);
+void GNUNET_cron_advance_job (struct GNUNET_CronManager *mgr,
+                              GNUNET_CronJob method, unsigned int deltaRepeat,
+                              void *data);
 
 /**
  * Remove first matching cron-job from the list. This method should
@@ -120,8 +122,9 @@
  * @param data what was the data given to the method
  * @return the number of jobs removed (0 or 1)
  */
-int cron_del_job (struct CronManager *mgr,
-                  CronJob method, unsigned int repeat, void *data);
+int GNUNET_cron_del_job (struct GNUNET_CronManager *mgr,
+                         GNUNET_CronJob method, unsigned int repeat,
+                         void *data);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

Modified: GNUnet/src/include/gnunet_util_crypto.h
===================================================================
--- GNUnet/src/include/gnunet_util_crypto.h     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_util_crypto.h     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other 
contributing authors)
+     (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Christian Grothoff (and 
other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -42,13 +42,13 @@
 #endif
 #endif
 
-#define STRONG YES
-#define WEAK NO
+#define GNUNET_RANDOM_QUALITY_STRONG GNUNET_YES
+#define GNUNET_RANDOM_QUALITY_WEAK GNUNET_NO
 
 /**
  * @brief length of the sessionkey in bytes (256 BIT sessionkey)
  */
-#define SESSIONKEY_LEN (256/8)
+#define GNUNET_SESSIONKEY_LEN (256/8)
 
 /**
  * @brief Length of RSA encrypted data (2048 bit)
@@ -57,28 +57,28 @@
  * that can not be done in a single call to the
  * RSA methods (read: large chunks of data).
  * We should never need that, as we can use
- * the hash for larger pieces of data for signing,
+ * the GNUNET_hash for larger pieces of data for signing,
  * and for encryption, we only need to encode sessionkeys!
  */
-#define RSA_ENC_LEN 256
+#define GNUNET_RSA_DATA_ENCODING_LEN 256
 
 /**
  * Length of an RSA KEY (d,e,len), 2048 bit (=256 octests) key d, 2 byte e
  */
-#define RSA_KEY_LEN 258
+#define GNUNET_RSA_KEY_LEN 258
 
 /**
  * The private information of an RSA key pair.
  */
-struct PrivateKey;
+struct GNUNET_RSA_PrivateKey;
 
 /**
- * @brief 0-terminated ASCII encoding of a HashCode512.
+ * @brief 0-terminated ASCII encoding of a GNUNET_HashCode.
  */
 typedef struct
 {
   unsigned char encoding[104];
-} EncName;
+} GNUNET_EncName;
 
 /**
  * GNUnet mandates a certain format for the encoding
@@ -101,15 +101,15 @@
   unsigned short sizedmp1;      /*  in big-endian! */
   unsigned short sizedmq1;      /*  in big-endian! */
   /* followed by the actual values */
-} PrivateKeyEncoded;
+} GNUNET_RSA_PrivateKeyEncoded;
 
 /**
  * @brief an RSA signature
  */
 typedef struct
 {
-  unsigned char sig[RSA_ENC_LEN];
-} Signature;
+  unsigned char sig[GNUNET_RSA_DATA_ENCODING_LEN];
+} GNUNET_RSA_Signature;
 
 /**
  * @brief A public key.
@@ -117,7 +117,7 @@
 typedef struct
 {
   /**
-   * In big-endian, must be RSA_KEY_LEN+4
+   * In big-endian, must be GNUNET_RSA_KEY_LEN+4
    */
   unsigned short len;
   /**
@@ -127,40 +127,40 @@
   /**
    * The key itself, contains n followed by e.
    */
-  unsigned char key[RSA_KEY_LEN];
+  unsigned char key[GNUNET_RSA_KEY_LEN];
   /**
    * Padding (must be 0)
    */
   unsigned short padding;
-} PublicKey;
+} GNUNET_RSA_PublicKey;
 
 /**
  * RSA Encrypted data.
  */
 typedef struct
 {
-  unsigned char encoding[RSA_ENC_LEN];
-} RSAEncryptedData;
+  unsigned char encoding[GNUNET_RSA_DATA_ENCODING_LEN];
+} GNUNET_RSA_EncryptedData;
 
 /**
  * @brief type for session keys
  */
 typedef struct
 {
-  unsigned char key[SESSIONKEY_LEN];
+  unsigned char key[GNUNET_SESSIONKEY_LEN];
   int crc32;                    /* checksum! */
-} SESSIONKEY;
+} GNUNET_AES_SessionKey;
 
 /**
  * @brief IV for sym cipher
  *
  * NOTE: must be smaller (!) in size than the
- * HashCode512.
+ * GNUNET_HashCode.
  */
 typedef struct
 {
-  unsigned char iv[SESSIONKEY_LEN / 2];
-} INITVECTOR;
+  unsigned char iv[GNUNET_SESSIONKEY_LEN / 2];
+} GNUNET_AES_InitializationVector;
 
 /* **************** Functions and Macros ************* */
 
@@ -172,7 +172,7 @@
  * @param len the length of the buffer in bytes
  * @return the resulting CRC32 checksum
  */
-int crc32N (const void *buf, int len);
+int GNUNET_crc32_n (const void *buf, unsigned int len);
 
 /**
  * Produce a random value.
@@ -180,37 +180,27 @@
  * @param i the upper limit (exclusive) for the random number
  * @return a random value in the interval [0,i[.
  */
-unsigned int randomi (unsigned int i);
+unsigned int GNUNET_random_u32 (int mode, unsigned int i);
 
 /**
  * Random on unsigned 64-bit values.  We break them down into signed
  * 32-bit values and reassemble the 64-bit random value bit-wise.
  */
-unsigned long long randomi64 (unsigned long long u);
+unsigned long long GNUNET_random_u64 (int mode, unsigned long long u);
 
-unsigned long long weak_randomi64 (unsigned long long u);
-
 /**
  * Get an array with a random permutation of the
  * numbers 0...n-1.
- * @param mode STRONG if the strong (but expensive) PRNG should be used, WEAK 
otherwise
+ * @param mode GNUNET_RANDOM_QUALITY_STRONG if the strong (but expensive) PRNG 
should be used, GNUNET_RANDOM_QUALITY_WEAK otherwise
  * @param n the size of the array
  * @return the permutation array (allocated from heap)
  */
-int *permute (int mode, int n);
+unsigned int *GNUNET_permute (int mode, unsigned int n);
 
 /**
- * Produce a cryptographically weak random value.
- *
- * @param i the upper limit (exclusive) for the random number
- * @return a random value in the interval [0,i[.
- */
-unsigned int weak_randomi (unsigned int i);
-
-/**
  * Create a new Session key.
  */
-void makeSessionkey (SESSIONKEY * key);
+void GNUNET_AES_create_session_key (GNUNET_AES_SessionKey * key);
 
 /**
  * Encrypt a block with the public key of another
@@ -222,10 +212,11 @@
  *        for streams.
  * @returns the size of the encrypted block, -1 for errors
  */
-int encryptBlock (const void *block,
-                  unsigned short len,
-                  const SESSIONKEY * sessionkey,
-                  const INITVECTOR * iv, void *result);
+int GNUNET_AES_encrypt (const void *block,
+                        unsigned short len,
+                        const GNUNET_AES_SessionKey * sessionkey,
+                        const GNUNET_AES_InitializationVector * iv,
+                        void *result);
 
 /**
  * Decrypt a given block with the sessionkey.
@@ -236,25 +227,28 @@
  * @param result address to store the result at
  * @return -1 on failure, size of decrypted block on success
  */
-int decryptBlock (const SESSIONKEY * sessionkey,
-                  const void *block,
-                  unsigned short size, const INITVECTOR * iv, void *result);
+int GNUNET_AES_decrypt (const GNUNET_AES_SessionKey * sessionkey,
+                        const void *block,
+                        unsigned short size,
+                        const GNUNET_AES_InitializationVector * iv,
+                        void *result);
 
 /**
- * Convert hash to ASCII encoding.
- * @param block the hash code
- * @param result where to store the encoding (EncName can be
+ * Convert GNUNET_hash to ASCII encoding.
+ * @param block the GNUNET_hash code
+ * @param result where to store the encoding (GNUNET_EncName can be
  *  safely cast to char*, a '\0' termination is set).
  */
-void hash2enc (const HashCode512 * block, EncName * result);
+void GNUNET_hash_to_enc (const GNUNET_HashCode * block,
+                         GNUNET_EncName * result);
 
 /**
- * Convert ASCII encoding back to hash
+ * Convert ASCII encoding back to GNUNET_hash
  * @param enc the encoding
- * @param result where to store the hash code
- * @return OK on success, SYSERR if result has the wrong encoding
+ * @param result where to store the GNUNET_hash code
+ * @return GNUNET_OK on success, GNUNET_SYSERR if result has the wrong encoding
  */
-int enc2hash (const char *enc, HashCode512 * result);
+int GNUNET_enc_to_hash (const char *enc, GNUNET_HashCode * result);
 
 /**
  * Compute the distance between 2 hashcodes.
@@ -264,94 +258,97 @@
  * result should be a positive number.
  * @return number between 0 and 65536
  */
-unsigned int distanceHashCode512 (const HashCode512 * a,
-                                  const HashCode512 * b);
+unsigned int GNUNET_hash_distance_u32 (const GNUNET_HashCode * a,
+                                       const GNUNET_HashCode * b);
 
 /**
- * compare two hashcodes.
- */
-int equalsHashCode512 (const HashCode512 * a, const HashCode512 * b);
-
-/**
  * Hash block of given size.
- * @param block the data to hash, length is given as a second argument
+ * @param block the data to GNUNET_hash, length is given as a second argument
  * @param ret pointer to where to write the hashcode
  */
-void hash (const void *block, unsigned int size, HashCode512 * ret);
+void GNUNET_hash (const void *block, unsigned int size,
+                  GNUNET_HashCode * ret);
 
 
 /**
- * Compute the hash of an entire file.
- * @return OK on success, SYSERR on error
+ * Compute the GNUNET_hash of an entire file.
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int getFileHash (struct GE_Context *ectx,
-                 const char *filename, HashCode512 * ret);
+int GNUNET_hash_file (struct GE_Context *ectx,
+                      const char *filename, GNUNET_HashCode * ret);
 
-void makeRandomId (HashCode512 * result);
+void GNUNET_create_random_hash (GNUNET_HashCode * result);
 
 /* compute result(delta) = b - a */
-void deltaId (const HashCode512 * a,
-              const HashCode512 * b, HashCode512 * result);
+void GNUNET_hash_difference (const GNUNET_HashCode * a,
+                             const GNUNET_HashCode * b,
+                             GNUNET_HashCode * result);
 
 /* compute result(b) = a + delta */
-void addHashCodes (const HashCode512 * a,
-                   const HashCode512 * delta, HashCode512 * result);
+void GNUNET_hash_sum (const GNUNET_HashCode * a,
+                      const GNUNET_HashCode * delta,
+                      GNUNET_HashCode * result);
 
 /* compute result = a ^ b */
-void xorHashCodes (const HashCode512 * a,
-                   const HashCode512 * b, HashCode512 * result);
+void GNUNET_hash_xor (const GNUNET_HashCode * a,
+                      const GNUNET_HashCode * b, GNUNET_HashCode * result);
 
 /**
  * Convert a hashcode into a key.
  */
-void hashToKey (const HashCode512 * hc, SESSIONKEY * skey, INITVECTOR * iv);
+void GNUNET_hash_to_AES_key (const GNUNET_HashCode * hc,
+                             GNUNET_AES_SessionKey * skey,
+                             GNUNET_AES_InitializationVector * iv);
 
 /**
  * Obtain a bit from a hashcode.
- * @param code the hash to index bit-wise
+ * @param code the GNUNET_hash to index bit-wise
  * @param bit index into the hashcode, [0...159]
  * @return Bit \a bit from hashcode \a code, -1 for invalid index
  */
-int getHashCodeBit (const HashCode512 * code, unsigned int bit);
+int GNUNET_hash_get_bit (const GNUNET_HashCode * code, unsigned int bit);
 
 /**
  * Compare function for HashCodes, producing a total ordering
  * of all hashcodes.
  * @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2.
  */
-int hashCodeCompare (const HashCode512 * h1, const HashCode512 * h2);
+int GNUNET_hash_cmp (const GNUNET_HashCode * h1, const GNUNET_HashCode * h2);
 
 /**
- * Find out which of the two hash codes is closer to target
+ * Find out which of the two GNUNET_hash codes is closer to target
  * in the XOR metric (Kademlia).
  * @return -1 if h1 is closer, 1 if h2 is closer and 0 if h1==h2.
  */
-int hashCodeCompareDistance (const HashCode512 * h1,
-                             const HashCode512 * h2,
-                             const HashCode512 * target);
+int GNUNET_hash_xorcmp (const GNUNET_HashCode * h1,
+                        const GNUNET_HashCode * h2,
+                        const GNUNET_HashCode * target);
 
 /**
  * create a new hostkey. Callee must free return value.
  */
-struct PrivateKey *makePrivateKey (void);
+struct GNUNET_RSA_PrivateKey *GNUNET_RSA_create_key (void);
 
 /**
  * Deterministically (!) create a hostkey using only the
  * given HashCode as input to the PRNG.
  */
-struct PrivateKey *makeKblockKey (const HashCode512 * input);
+struct GNUNET_RSA_PrivateKey *GNUNET_RSA_create_key_from_hash (const
+                                                               GNUNET_HashCode
+                                                               * input);
 
 /**
  * Free memory occupied by hostkey
  * @param hostkey pointer to the memory to free
  */
-void freePrivateKey (struct PrivateKey *hostkey);
+void GNUNET_RSA_free_key (struct GNUNET_RSA_PrivateKey *hostkey);
 
 /**
  * Extract the public key of the host.
  * @param result where to write the result.
  */
-void getPublicKey (const struct PrivateKey *hostkey, PublicKey * result);
+void GNUNET_RSA_get_public_key (const struct GNUNET_RSA_PrivateKey *hostkey,
+                                GNUNET_RSA_PublicKey * result);
 
 /**
  * Encode the private key in a format suitable for
@@ -359,7 +356,9 @@
  * @param hostkey the hostkey to use
  * @returns encoding of the private key.
  */
-PrivateKeyEncoded *encodePrivateKey (const struct PrivateKey *hostkey);
+GNUNET_RSA_PrivateKeyEncoded *GNUNET_RSA_encode_key (const struct
+                                                     GNUNET_RSA_PrivateKey
+                                                     *hostkey);
 
 /**
  * Decode the private key from the file-format back
@@ -367,7 +366,9 @@
  * @param encoded the encoded hostkey
  * @returns the decoded hostkey
  */
-struct PrivateKey *decodePrivateKey (const PrivateKeyEncoded * encoding);
+struct GNUNET_RSA_PrivateKey *GNUNET_RSA_decode_key (const
+                                                     
GNUNET_RSA_PrivateKeyEncoded
+                                                     * encoding);
 
 /**
  * Encrypt a block with the public key of another host that uses the
@@ -377,12 +378,12 @@
  * @param size the size of block
  * @param publicKey the encoded public key used to encrypt
  * @param target where to store the encrypted block
- * @returns SYSERR on error, OK if ok
+ * @returns GNUNET_SYSERR on error, GNUNET_OK if ok
  */
-int encryptPrivateKey (const void *block,
-                       unsigned short size,
-                       const PublicKey * publicKey,
-                       RSAEncryptedData * target);
+int GNUNET_RSA_encrypt (const void *block,
+                        unsigned short size,
+                        const GNUNET_RSA_PublicKey * publicKey,
+                        GNUNET_RSA_EncryptedData * target);
 
 /**
  * Decrypt a given block with the hostkey.
@@ -393,20 +394,21 @@
  * @param size how many bytes of a result are expected? Must be exact.
  * @returns the size of the decrypted block (that is, size) or -1 on error
  */
-int decryptPrivateKey (const struct PrivateKey *key,
-                       const RSAEncryptedData * block,
-                       void *result, unsigned short size);
+int GNUNET_RSA_decrypt (const struct GNUNET_RSA_PrivateKey *key,
+                        const GNUNET_RSA_EncryptedData * block,
+                        void *result, unsigned short size);
 
 /**
  * Sign a given block.
  *
- * @param block the data to sign, first unsigned short_SIZE bytes give length
- * @param size how many bytes to sign
+ * @param block the data to GNUNET_RSA_sign, first unsigned short_SIZE bytes 
give length
+ * @param size how many bytes to GNUNET_RSA_sign
  * @param result where to write the signature
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
-int sign (const struct PrivateKey *key,
-          unsigned short size, const void *block, Signature * result);
+int GNUNET_RSA_sign (const struct GNUNET_RSA_PrivateKey *key,
+                     unsigned short size, const void *block,
+                     GNUNET_RSA_Signature * result);
 
 /**
  * Verify signature.
@@ -414,11 +416,12 @@
  * @param len the length of the block
  * @param sig signature
  * @param publicKey public key of the signer
- * @returns OK if ok, SYSERR if invalid
+ * @returns GNUNET_OK if ok, GNUNET_SYSERR if invalid
  */
-int verifySig (const void *block,
-               unsigned short len,
-               const Signature * sig, const PublicKey * publicKey);
+int GNUNET_RSA_verify (const void *block,
+                       unsigned short len,
+                       const GNUNET_RSA_Signature * sig,
+                       const GNUNET_RSA_PublicKey * publicKey);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

Modified: GNUnet/src/include/gnunet_util_disk.h
===================================================================
--- GNUnet/src/include/gnunet_util_disk.h       2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_util_disk.h       2007-11-23 11:51:54 UTC (rev 
5742)
@@ -49,16 +49,17 @@
  * @param part a file on the partition to check
  * @return -1 on errors, otherwise the number of free blocks
  */
-long disk_get_blocks_available (struct GE_Context *ectx, const char *part);
+long GNUNET_disk_get_blocks_available (struct GE_Context *ectx,
+                                       const char *part);
 
 /**
  * Check that fil corresponds to a filename
  * (of a file that exists and that is not a directory).
  *
- * @returns YES if yes, NO if not a file, SYSERR if something
+ * @returns GNUNET_YES if yes, GNUNET_NO if not a file, GNUNET_SYSERR if 
something
  * else (will print an error message in that case, too).
  */
-int disk_file_test (struct GE_Context *ectx, const char *fil);
+int GNUNET_disk_file_test (struct GE_Context *ectx, const char *fil);
 
 /**
  * Get the size of the file (or directory)
@@ -67,24 +68,25 @@
  * @param includeSymLinks should symbolic links be
  *        included?
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int disk_file_size (struct GE_Context *ectx,
-                    const char *filename,
-                    unsigned long long *size, int includeSymLinks);
+int GNUNET_disk_file_size (struct GE_Context *ectx,
+                           const char *filename,
+                           unsigned long long *size, int includeSymLinks);
 
 /**
  * Wrapper around "open()".  Opens a file.
  *
  * @return file handle, -1 on error
  */
-int disk_file_open (struct GE_Context *ectx,
-                    const char *filename, int oflag, ...);
+int GNUNET_disk_file_open (struct GE_Context *ectx,
+                           const char *filename, int oflag, ...);
 
 /**
  * Wrapper around "close()".  Closes a file.
  */
-void disk_file_close (struct GE_Context *ectx, const char *filename, int fd);
+void GNUNET_disk_file_close (struct GE_Context *ectx, const char *filename,
+                             int fd);
 
 /**
  * Read the contents of a binary file into a buffer.
@@ -94,8 +96,8 @@
  * @param result the buffer to write the result to
  * @return the number of bytes read on success, -1 on failure
  */
-int disk_file_read (struct GE_Context *ectx,
-                    const char *fileName, int len, void *result);
+int GNUNET_disk_file_read (struct GE_Context *ectx,
+                           const char *fileName, int len, void *result);
 
 /**
  * Write a buffer to a file.
@@ -103,26 +105,28 @@
  * @param buffer the data to write
  * @param n number of bytes to write
  * @param mode the mode for file permissions
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int disk_file_write (struct GE_Context *ectx,
-                     const char *fileName,
-                     const void *buffer, unsigned int n, const char *mode);
+int GNUNET_disk_file_write (struct GE_Context *ectx,
+                            const char *fileName,
+                            const void *buffer, unsigned int n,
+                            const char *mode);
 
 /**
  * Copy a file.
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int disk_file_copy (struct GE_Context *ectx,
-                    const char *src, const char *dst);
+int GNUNET_disk_file_copy (struct GE_Context *ectx,
+                           const char *src, const char *dst);
 
 /**
  * Function called on each file in a directory.
- * @return OK to continue to iterate,
- *  SYSERR to abort iteration with error!
+ * @return GNUNET_OK to continue to iterate,
+ *  GNUNET_SYSERR to abort iteration with error!
  */
-typedef int (*DirectoryEntryCallback) (const char *filename,
-                                       const char *dirName, void *data);
+typedef int (*GNUNET_DirectoryEntryCallback) (const char *filename,
+                                              const char *dirName,
+                                              void *data);
 
 /**
  * Scan a directory for files. The name of the directory
@@ -133,9 +137,10 @@
  * @param data argument to pass to callback
  * @return the number of files found, -1 on error
  */
-int disk_directory_scan (struct GE_Context *ectx,
-                         const char *dirName,
-                         DirectoryEntryCallback callback, void *data);
+int GNUNET_disk_directory_scan (struct GE_Context *ectx,
+                                const char *dirName,
+                                GNUNET_DirectoryEntryCallback callback,
+                                void *data);
 
 
 /**
@@ -143,44 +148,45 @@
  * a file.
  *
  * @param filename name of a file in the directory
- * @returns OK on success, SYSERR on failure
+ * @returns GNUNET_OK on success, GNUNET_SYSERR on failure
  */
-int disk_directory_create_for_file (struct GE_Context *ectx,
-                                    const char *filename);
+int GNUNET_disk_directory_create_for_file (struct GE_Context *ectx,
+                                           const char *filename);
 
 /**
  * Test if fil is a directory that can be accessed.
  * Will not print an error message if the directory
- * does not exist.  Will log errors if SYSERR is
+ * does not exist.  Will log errors if GNUNET_SYSERR is
  * returned.
  *
- * @return YES if yes, NO if does not exist, SYSERR
+ * @return GNUNET_YES if yes, GNUNET_NO if does not exist, GNUNET_SYSERR
  *   on any error and if exists but not directory
  */
-int disk_directory_test (struct GE_Context *ectx, const char *fil);
+int GNUNET_disk_directory_test (struct GE_Context *ectx, const char *fil);
 
 /**
  * Remove all files in a directory (rm -rf). Call with
  * caution.
  *
  * @param fileName the file to remove
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int disk_directory_remove (struct GE_Context *ectx, const char *fileName);
+int GNUNET_disk_directory_remove (struct GE_Context *ectx,
+                                  const char *fileName);
 
 /**
  * Implementation of "mkdir -p"
  *
  * @param dir the directory to create
- * @returns SYSERR on failure, OK otherwise
+ * @returns GNUNET_SYSERR on failure, GNUNET_OK otherwise
  */
-int disk_directory_create (struct GE_Context *ectx, const char *dir);
+int GNUNET_disk_directory_create (struct GE_Context *ectx, const char *dir);
 
 /**
  * @brief Removes special characters as ':' from a filename.
  * @param fn the filename to canonicalize
  */
-void disk_filename_canonicalize (char *fn);
+void GNUNET_disk_filename_canonicalize (char *fn);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

Modified: GNUnet/src/include/gnunet_util_error.h
===================================================================
--- GNUnet/src/include/gnunet_util_error.h      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_util_error.h      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -165,7 +165,7 @@
  *
  * @param have the event type
  * @param mask the filter mask
- * @return YES or NO
+ * @return GNUNET_YES or GNUNET_NO
  */
 int GE_applies (GE_KIND have, GE_KIND mask);
 
@@ -175,7 +175,7 @@
  *
  * @param ctx the logger
  * @param have the kind of event
- * @return YES or NO
+ * @return GNUNET_YES or GNUNET_NO
  */
 int GE_isLogged (struct GE_Context *ctx, GE_KIND kind);
 

Modified: GNUnet/src/include/gnunet_util_error_loggers.h
===================================================================
--- GNUnet/src/include/gnunet_util_error_loggers.h      2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/include/gnunet_util_error_loggers.h      2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -55,6 +55,7 @@
 struct GE_Context *GE_create_context_logfile (struct GE_Context *ectx,
                                               GE_KIND mask,
                                               const char *filename,
+                                              const char *owner,
                                               int logDate, int logrotate);
 
 

Modified: GNUnet/src/include/gnunet_util_getopt.h
===================================================================
--- GNUnet/src/include/gnunet_util_getopt.h     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_util_getopt.h     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -57,7 +57,7 @@
   /**
    * Array with all command line options.
    */
-  const struct CommandLineOption *allOptions;
+  const struct GNUNET_CommandLineOption *allOptions;
 
   /**
    * Original command line
@@ -84,7 +84,7 @@
    */
   struct GC_Configuration *cfg;
 
-} CommandLineProcessorContext;
+} GNUNET_CommandLineProcessorContext;
 
 /**
  * @brief Process a command line option
@@ -93,17 +93,18 @@
  * @param scls specific closure (for this processor)
  * @param option long name of the option (i.e. "config" for --config)
  * @param value argument, NULL if none was given
- * @return OK to continue processing other options, SYSERR to abort
+ * @return GNUNET_OK to continue processing other options, GNUNET_SYSERR to 
abort
  */
-typedef int (*CommandLineOptionProcessor) (CommandLineProcessorContext * ctx,
-                                           void *scls,
-                                           const char *option,
-                                           const char *value);
+typedef
+  int (*GNUNET_CommandLineOptionProcessor) (GNUNET_CommandLineProcessorContext
+                                            * ctx, void *scls,
+                                            const char *option,
+                                            const char *value);
 
 /**
  * @brief Definition of a command line option.
  */
-typedef struct CommandLineOption
+typedef struct GNUNET_CommandLineOption
 {
 
   /**
@@ -127,21 +128,21 @@
   const char *description;
 
   /**
-   * Is an argument required?  0: NO (includes optional), 1: YES.
+   * Is an argument required?  0: GNUNET_NO (includes optional), 1: GNUNET_YES.
    */
   int require_argument;
 
   /**
    * Handler for the option.
    */
-  CommandLineOptionProcessor processor;
+  GNUNET_CommandLineOptionProcessor processor;
 
   /**
    * Specific closure to pass to the processor.
    */
   void *scls;
 
-} CommandLineOption;
+} GNUNET_CommandLineOption;
 
 /**
  * Macro defining the option to print the command line
@@ -149,8 +150,8 @@
  *
  * @param about string with brief description of the application
  */
-#define COMMAND_LINE_OPTION_HELP(about) \
-  { 'h', "help", (const char *) NULL, gettext_noop("print this help"), 0, 
&gnunet_getopt_format_help, (void *) about }
+#define GNUNET_COMMAND_LINE_OPTION_HELP(about) \
+  { 'h', "help", (const char *) NULL, gettext_noop("print this help"), 0, 
&GNUNET_getopt_format_help_, (void *) about }
 
 /**
  * Macro defining the option to print the version of
@@ -158,37 +159,37 @@
  *
  * @param version string with the version number
  */
-#define COMMAND_LINE_OPTION_VERSION(version) \
-  { 'v', "version", (const char *) NULL, gettext_noop("print the version 
number"), 0, &gnunet_getopt_print_version, (void *) version }
+#define GNUNET_COMMAND_LINE_OPTION_VERSION(version) \
+  { 'v', "version", (const char *) NULL, gettext_noop("print the version 
number"), 0, &GNUNET_getopt_print_version_, (void *) version }
 
 /**
  * Set the configuration option for logging.
  */
-#define COMMAND_LINE_OPTION_LOGGING \
-  { 'L', "log", "LOGLEVEL", gettext_noop("configure logging to use LOGLEVEL"), 
1, &gnunet_getopt_configure_set_option, (void *) "LOGGING:USER-LEVEL" }
+#define GNUNET_COMMAND_LINE_OPTION_LOGGING \
+  { 'L', "log", "LOGLEVEL", gettext_noop("configure logging to use LOGLEVEL"), 
1, &GNUNET_getopt_configure_set_option, (void *) "LOGGING:USER-LEVEL" }
 
 /**
  * Set the configuration option for increasing verbosity.
  */
-#define COMMAND_LINE_OPTION_VERBOSE \
-  { 'V', "verbose", (const char *) NULL, gettext_noop("be verbose"), 0, 
&gnunet_getopt_configure_increment_value, (void *) "GNUNET:VERBOSE" }
+#define GNUNET_COMMAND_LINE_OPTION_VERBOSE \
+  { 'V', "verbose", (const char *) NULL, gettext_noop("be verbose"), 0, 
&GNUNET_getopt_configure_increment_value, (void *) "GNUNET:VERBOSE" }
 
 /**
  * Set the configuration option for the configuration file.
  */
-#define COMMAND_LINE_OPTION_CFG_FILE(fn)                               \
-  { 'c', "config", "FILENAME", gettext_noop("use configuration file 
FILENAME"), 1, &gnunet_getopt_configure_set_string, (void *) fn }
+#define GNUNET_COMMAND_LINE_OPTION_CFG_FILE(fn)                                
\
+  { 'c', "config", "FILENAME", gettext_noop("use configuration file 
FILENAME"), 1, &GNUNET_getopt_configure_set_string, (void *) fn }
 
 /**
  * Set the configuration option for the configuration file.
  */
-#define COMMAND_LINE_OPTION_HOSTNAME \
-  { 'H', "host", "HOSTNAME", gettext_noop("specify host on which gnunetd is 
running"), 1, &gnunet_getopt_configure_set_option, (void *) "NETWORK:HOST" }
+#define GNUNET_COMMAND_LINE_OPTION_HOSTNAME \
+  { 'H', "host", "HOSTNAME", gettext_noop("specify host on which gnunetd is 
running"), 1, &GNUNET_getopt_configure_set_option, (void *) "NETWORK:HOST" }
 
 /**
  * Marker to end the list of options.
  */
-#define COMMAND_LINE_OPTION_END \
+#define GNUNET_COMMAND_LINE_OPTION_END \
   { '\0', NULL, NULL, NULL, 0, NULL, NULL }
 
 /**
@@ -203,48 +204,46 @@
  * @return index into argv with first non-option
  *   argument, or -1 on error
  */
-int gnunet_parse_options (const char *binaryName,
+int GNUNET_parse_options (const char *binaryName,
                           struct GE_Context *ectx,
                           struct GC_Configuration *cfg,
-                          const CommandLineOption * allOptions,
+                          const GNUNET_CommandLineOption * allOptions,
                           unsigned int argc, char *const *argv);
 
-int gnunet_getopt_configure_set_option (CommandLineProcessorContext * ctx,
-                                        void *scls,
-                                        const char *option,
+int GNUNET_getopt_configure_set_option (GNUNET_CommandLineProcessorContext *
+                                        ctx, void *scls, const char *option,
                                         const char *value);
 
-int gnunet_getopt_configure_set_ulong (CommandLineProcessorContext * ctx,
-                                       void *scls,
-                                       const char *option, const char *value);
+int GNUNET_getopt_configure_set_ulong (GNUNET_CommandLineProcessorContext *
+                                       ctx, void *scls, const char *option,
+                                       const char *value);
 
-int gnunet_getopt_configure_set_uint (CommandLineProcessorContext * ctx,
-                                      void *scls,
-                                      const char *option, const char *value);
+int GNUNET_getopt_configure_set_uint (GNUNET_CommandLineProcessorContext *
+                                      ctx, void *scls, const char *option,
+                                      const char *value);
 
-int gnunet_getopt_configure_set_one (CommandLineProcessorContext * ctx,
+int GNUNET_getopt_configure_set_one (GNUNET_CommandLineProcessorContext * ctx,
                                      void *scls,
                                      const char *option, const char *value);
 
-int gnunet_getopt_configure_set_string (CommandLineProcessorContext * ctx,
-                                        void *scls,
-                                        const char *option,
+int GNUNET_getopt_configure_set_string (GNUNET_CommandLineProcessorContext *
+                                        ctx, void *scls, const char *option,
                                         const char *value);
 
-int gnunet_getopt_configure_increment_value (CommandLineProcessorContext *
-                                             ctx, void *scls,
-                                             const char *option,
-                                             const char *value);
+int
+GNUNET_getopt_configure_increment_value (GNUNET_CommandLineProcessorContext *
+                                         ctx, void *scls, const char *option,
+                                         const char *value);
 
 /* *************** internal prototypes - use macros above! ************* */
 
-int gnunet_getopt_format_help (CommandLineProcessorContext * ctx,
-                               void *scls,
-                               const char *option, const char *value);
+int GNUNET_getopt_format_help_ (GNUNET_CommandLineProcessorContext * ctx,
+                                void *scls,
+                                const char *option, const char *value);
 
-int gnunet_getopt_print_version (CommandLineProcessorContext * ctx,
-                                 void *scls,
-                                 const char *option, const char *value);
+int GNUNET_getopt_print_version_ (GNUNET_CommandLineProcessorContext * ctx,
+                                  void *scls,
+                                  const char *option, const char *value);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

Modified: GNUnet/src/include/gnunet_util_network.h
===================================================================
--- GNUnet/src/include/gnunet_util_network.h    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_util_network.h    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -48,7 +48,7 @@
 /**
  * We use an unsigned short in the protocol header, thus:
  */
-#define MAX_BUFFER_SIZE 65536
+#define GNUNET_MAX_BUFFER_SIZE 65536
 
 /**
  * @brief Specify low-level network IO behavior
@@ -59,18 +59,18 @@
   /**
    * Do not block.
    */
-  NC_Nonblocking = 0x000,
+  GNUNET_NC_NONBLOCKING = 0x000,
 
   /**
    * Call may block.
    */
-  NC_Blocking = 0x001,
+  GNUNET_NC_BLOCKING = 0x001,
 
   /**
    * Ignore interrupts (re-try if operation
    * was aborted due to interrupt)
    */
-  NC_IgnoreInt = 0x010,
+  GNUNET_NC_IGNORE_INT = 0x010,
 
   /**
    * Always try to read/write the maximum
@@ -78,9 +78,9 @@
    * calls).  Only return on non-interrupt
    * error or if completely done.
    */
-  NC_Complete = 0x111,
+  GNUNET_NC_COMPLETE_TRANSFER = 0x111,
 
-} NC_KIND;
+} GNUNET_NC_KIND;
 
 /**
  * @brief 512-bit hashcode
@@ -88,7 +88,7 @@
 typedef struct
 {
   unsigned int bits[512 / 8 / sizeof (unsigned int)];   /* = 16 */
-} HashCode512;
+} GNUNET_HashCode;
 
 /**
  * The identity of the host (basically the SHA-512 hashcode of
@@ -96,8 +96,8 @@
  */
 typedef struct
 {
-  HashCode512 hashPubKey;
-} PeerIdentity;
+  GNUNET_HashCode hashPubKey;
+} GNUNET_PeerIdentity;
 
 /**
  * Header for all Client-Server communications.
@@ -115,7 +115,7 @@
    */
   unsigned short type;
 
-} MESSAGE_HEADER;
+} GNUNET_MessageHeader;
 
 /**
  * Client-server communication: simple return value
@@ -126,14 +126,14 @@
   /**
    * The CS header (values: sizeof(CS_returnvalue_MESSAGE) + error-size, 
CS_PROTO_RETURN_VALUE)
    */
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * The return value (network byte order)
    */
   int return_value;
 
-} RETURN_VALUE_MESSAGE;
+} GNUNET_MessageReturnValue;
 
 /**
  * Client-server communication: simple error message
@@ -144,14 +144,14 @@
   /**
    * The CS header (values: sizeof(CS_returnvalue_MESSAGE) + error-size, 
CS_PROTO_RETURN_VALUE)
    */
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * The return value (network byte order)
    */
   GE_KIND kind;
 
-} RETURN_ERROR_MESSAGE;
+} GNUNET_MessageReturnErrorMessage;
 
 
 /**
@@ -163,12 +163,12 @@
    * struct in_addr
    */
   unsigned int addr;
-} IPaddr;
+} GNUNET_IPv4Address;
 
 /**
  * @brief IPV4 network in CIDR notation.
  */
-struct CIDRNetwork;
+struct GNUNET_IPv4NetworkSet;
 
 /**
  * @brief an IPV6 address.
@@ -179,36 +179,36 @@
    * struct in6_addr addr;
    */
   unsigned int addr[4];
-} IP6addr;
+} GNUNET_IPv6Address;
 
 /**
  * @brief IPV6 network in CIDR notation.
  */
-struct CIDR6Network;
+struct GNUNET_IPv6NetworkSet;
 
 /**
  * @brief handle for a system socket
  */
-struct SocketHandle;
+struct GNUNET_SocketHandle;
 
 /**
  * @brief handle for a select manager
  */
-struct SelectHandle;
+struct GNUNET_SelectHandle;
 
 /**
  * @brief callback for handling messages received by select
  *
  * @param sock socket on which the message was received
  *        (should ONLY be used to queue reply using select methods)
- * @return OK if message was valid, SYSERR if corresponding
+ * @return GNUNET_OK if message was valid, GNUNET_SYSERR if corresponding
  *  socket should be closed
  */
-typedef int (*SelectMessageHandler) (void *mh_cls,
-                                     struct SelectHandle * sh,
-                                     struct SocketHandle * sock,
-                                     void *sock_ctx,
-                                     const MESSAGE_HEADER * msg);
+typedef int (*GNUNET_SelectMessageHandler) (void *mh_cls,
+                                            struct GNUNET_SelectHandle * sh,
+                                            struct GNUNET_SocketHandle * sock,
+                                            void *sock_ctx,
+                                            const GNUNET_MessageHeader * msg);
 
 /**
  * We've accepted a connection, check that
@@ -221,20 +221,20 @@
  * @return NULL to reject connection, otherwise value of sock_ctx
  *         for the new connection
  */
-typedef void *(*SelectAcceptHandler) (void *ah_cls,
-                                      struct SelectHandle * sh,
-                                      struct SocketHandle * sock,
-                                      const void *addr,
-                                      unsigned int addr_len);
+typedef void *(*GNUNET_SelectAcceptHandler) (void *ah_cls,
+                                             struct GNUNET_SelectHandle * sh,
+                                             struct GNUNET_SocketHandle *
+                                             sock, const void *addr,
+                                             unsigned int addr_len);
 
 /**
  * Select has been forced to close a connection.
  * Free the associated context.
  */
-typedef void (*SelectCloseHandler) (void *ch_cls,
-                                    struct SelectHandle * sh,
-                                    struct SocketHandle * sock,
-                                    void *sock_ctx);
+typedef void (*GNUNET_SelectCloseHandler) (void *ch_cls,
+                                           struct GNUNET_SelectHandle * sh,
+                                           struct GNUNET_SocketHandle * sock,
+                                           void *sock_ctx);
 
 /* *********************** endianess conversion ************* */
 
@@ -243,14 +243,14 @@
  * @param n the value in network byte order
  * @return the same value in host byte order
  */
-unsigned long long ntohll (unsigned long long n);
+unsigned long long GNUNET_ntohll (unsigned long long n);
 
 /**
  * Convert a long long to network-byte-order.
  * @param n the value in host byte order
  * @return the same value in network byte order
  */
-unsigned long long htonll (unsigned long long n);
+unsigned long long GNUNET_htonll (unsigned long long n);
 
 /* ***************** basic parsing **************** */
 
@@ -265,8 +265,12 @@
  * @param routeList a string specifying the forbidden networks
  * @return the converted list, NULL if the synatx is flawed
  */
-struct CIDRNetwork *parse_ipv4_network_specification (struct GE_Context *ectx,
-                                                      const char *routeList);
+struct GNUNET_IPv4NetworkSet *GNUNET_parse_ipv4_network_specification (struct
+                                                                       
GE_Context
+                                                                       *ectx,
+                                                                       const
+                                                                       char
+                                                                       
*routeList);
 
 /**
  * Parse a network specification. The argument specifies
@@ -279,29 +283,34 @@
  * @param routeList a string specifying the forbidden networks
  * @return the converted list, NULL if the synatx is flawed
  */
-struct CIDR6Network *parse_ipv6_network_specification (struct GE_Context
-                                                       *ectx,
-                                                       const char *routeList);
+struct GNUNET_IPv6NetworkSet *GNUNET_parse_ipv6_network_specification (struct
+                                                                       
GE_Context
+                                                                       *ectx,
+                                                                       const
+                                                                       char
+                                                                       
*routeList);
 
 /**
  * Check if the given IP address is in the list of
  * IP addresses.
  * @param list a list of networks
  * @param ip the IP to check (in network byte order)
- * @return NO if the IP is not in the list, YES if it it is
+ * @return GNUNET_NO if the IP is not in the list, GNUNET_YES if it it is
  */
-int check_ipv4_listed (const struct CIDRNetwork *list, IPaddr ip);
+int GNUNET_check_ipv4_listed (const struct GNUNET_IPv4NetworkSet *list,
+                              GNUNET_IPv4Address ip);
 
 /**
  * Check if the given IP address is in the list of
  * IP addresses.
  * @param list a list of networks
  * @param ip the IP to check (in network byte order)
- * @return NO if the IP is not in the list, YES if it it is
+ * @return GNUNET_NO if the IP is not in the list, GNUNET_YES if it it is
  */
-int check_ipv6_listed (const struct CIDR6Network *list, IP6addr ip);
+int GNUNET_check_ipv6_listed (const struct GNUNET_IPv6NetworkSet *list,
+                              GNUNET_IPv6Address ip);
 
-#define PRIP(ip) (unsigned int)(((unsigned int)(ip))>>24), \
+#define GNUNET_PRIP(ip) (unsigned int)(((unsigned int)(ip))>>24), \
                  (unsigned int)((((unsigned)(ip)))>>16 & 255), \
                  (unsigned int)((((unsigned int)(ip)))>>8 & 255), \
                  (unsigned int)((((unsigned int)(ip))) & 255)
@@ -309,30 +318,31 @@
 /**
  * Get the IP address of the given host.
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int get_host_by_name (struct GE_Context *ectx,
-                      const char *hostname, IPaddr * ip);
+int GNUNET_get_host_by_name (struct GE_Context *ectx,
+                             const char *hostname, GNUNET_IPv4Address * ip);
 
 /* ********************* low-level socket operations **************** */
 
 /**
  * Create a socket handle by boxing an OS socket.
  * The OS socket should henceforth be no longer used
- * directly.  socket_destroy will close it.
+ * directly.  GNUNET_socket_destroy will close it.
  */
-struct SocketHandle *socket_create (struct GE_Context *ectx,
-                                    struct LoadMonitor *mon, int osSocket);
+struct GNUNET_SocketHandle *socket_create (struct GE_Context *ectx,
+                                           struct GNUNET_LoadMonitor *mon,
+                                           int osSocket);
 
 /**
  * Close the socket (does NOT destroy it)
  */
-void socket_close (struct SocketHandle *s);
+void GNUNET_socket_close (struct GNUNET_SocketHandle *s);
 
 /**
  * Destroy the socket (also closes it).
  */
-void socket_destroy (struct SocketHandle *s);
+void GNUNET_socket_destroy (struct GNUNET_SocketHandle *s);
 
 /**
  * Depending on doBlock, enable or disable the nonblocking mode
@@ -341,14 +351,14 @@
  * @return Upon successful completion, it returns zero.
  * @return Otherwise -1 is returned.
  */
-int socket_set_blocking (struct SocketHandle *s, int doBlock);
+int GNUNET_socket_set_blocking (struct GNUNET_SocketHandle *s, int doBlock);
 
 /**
  * Check whether the socket is blocking
  * @param s the socket
- * @return YES if blocking, NO non-blocking
+ * @return GNUNET_YES if blocking, GNUNET_NO non-blocking
  */
-int socket_test_blocking (struct SocketHandle *s);
+int GNUNET_socket_test_blocking (struct GNUNET_SocketHandle *s);
 
 /**
  * Do a read on the given socket.
@@ -360,17 +370,19 @@
  * @param max maximum number of bytes to read
  * @param read number of bytes actually read.
  *             0 is returned if no more bytes can be read
- * @return SYSERR on error, YES on success or NO if the operation
+ * @return GNUNET_SYSERR on error, GNUNET_YES on success or GNUNET_NO if the 
operation
  *         would have blocked
  */
-int socket_recv (struct SocketHandle *s,
-                 NC_KIND nc, void *buf, size_t max, size_t * read);
+int GNUNET_socket_recv (struct GNUNET_SocketHandle *s,
+                        GNUNET_NC_KIND nc, void *buf, size_t max,
+                        size_t * read);
 
-int socket_recv_from (struct SocketHandle *s,
-                      NC_KIND nc,
-                      void *buf,
-                      size_t max,
-                      size_t * read, char *from, unsigned int *fromlen);
+int GNUNET_socket_recv_from (struct GNUNET_SocketHandle *s,
+                             GNUNET_NC_KIND nc,
+                             void *buf,
+                             size_t max,
+                             size_t * read, char *from,
+                             unsigned int *fromlen);
 
 /**
  * Do a write on the given socket.
@@ -380,23 +392,25 @@
  * @param buf buffer to send
  * @param max maximum number of bytes to send
  * @param sent number of bytes actually sent
- * @return SYSERR on error, YES on success or
- *         NO if the operation would have blocked.
+ * @return GNUNET_SYSERR on error, GNUNET_YES on success or
+ *         GNUNET_NO if the operation would have blocked.
  */
-int socket_send (struct SocketHandle *s,
-                 NC_KIND nc, const void *buf, size_t max, size_t * sent);
+int GNUNET_socket_send (struct GNUNET_SocketHandle *s,
+                        GNUNET_NC_KIND nc, const void *buf, size_t max,
+                        size_t * sent);
 
-int socket_send_to (struct SocketHandle *s,
-                    NC_KIND nc,
-                    const void *buf,
-                    size_t max,
-                    size_t * sent, const char *dst, unsigned int dstlen);
+int GNUNET_socket_send_to (struct GNUNET_SocketHandle *s,
+                           GNUNET_NC_KIND nc,
+                           const void *buf,
+                           size_t max,
+                           size_t * sent, const char *dst,
+                           unsigned int dstlen);
 
 /**
  * Check if socket is valid
- * @return YES if valid, NO otherwise
+ * @return GNUNET_YES if valid, GNUNET_NO otherwise
  */
-int socket_test_valid (struct SocketHandle *s);
+int GNUNET_socket_test_valid (struct GNUNET_SocketHandle *s);
 
 
 /* ********************* select operations **************** */
@@ -420,66 +434,67 @@
  *        accept at most? 0 for unbounded
  * @return NULL on error
  */
-struct SelectHandle *select_create (const char *desc,
-                                    int is_udp,
-                                    struct GE_Context *ectx,
-                                    struct LoadMonitor *mon,
-                                    int sock,
-                                    unsigned int max_addr_len,
-                                    cron_t timeout,
-                                    SelectMessageHandler mh,
-                                    void *mh_cls,
-                                    SelectAcceptHandler ah,
-                                    void *ah_cls,
-                                    SelectCloseHandler ch,
-                                    void *ch_cls,
-                                    unsigned int memory_quota,
-                                    int socket_quota);
+struct GNUNET_SelectHandle *GNUNET_select_create (const char *desc,
+                                                  int is_udp,
+                                                  struct GE_Context *ectx,
+                                                  struct GNUNET_LoadMonitor
+                                                  *mon, int sock,
+                                                  unsigned int max_addr_len,
+                                                  GNUNET_CronTime timeout,
+                                                  GNUNET_SelectMessageHandler
+                                                  mh, void *mh_cls,
+                                                  GNUNET_SelectAcceptHandler
+                                                  ah, void *ah_cls,
+                                                  GNUNET_SelectCloseHandler
+                                                  ch, void *ch_cls,
+                                                  unsigned int memory_quota,
+                                                  int socket_quota);
 
 /**
  * Terminate the select thread, close the socket and
  * all associated connections.
  */
-void select_destroy (struct SelectHandle *sh);
+void GNUNET_select_destroy (struct GNUNET_SelectHandle *sh);
 
 /**
  * Queue the given message with the select thread.
  *
- * @param mayBlock if YES, blocks this thread until message
+ * @param mayBlock if GNUNET_YES, blocks this thread until message
  *        has been sent
  * @param force message is important, queue even if
  *        there is not enough space
- * @return OK if the message was sent or queued
- *         NO if there was not enough memory to queue it,
- *         SYSERR if the sock does not belong with this select
+ * @return GNUNET_OK if the message was sent or queued
+ *         GNUNET_NO if there was not enough memory to queue it,
+ *         GNUNET_SYSERR if the sock does not belong with this select
  */
-int select_write (struct SelectHandle *sh,
-                  struct SocketHandle *sock,
-                  const MESSAGE_HEADER * msg, int mayBlock, int force);
+int GNUNET_select_write (struct GNUNET_SelectHandle *sh,
+                         struct GNUNET_SocketHandle *sock,
+                         const GNUNET_MessageHeader * msg, int mayBlock,
+                         int force);
 
 
 /**
  * Would select queue or send the given message at this time?
  *
- * @param mayBlock if YES, blocks this thread until message
+ * @param mayBlock if GNUNET_YES, blocks this thread until message
  *        has been sent
  * @param size size of the message
  * @param force message is important, queue even if
  *        there is not enough space
- * @return OK if the message would be sent or queued,
- *         NO if there was not enough memory to queue it,
- *         SYSERR if the sock does not belong with this select
+ * @return GNUNET_OK if the message would be sent or queued,
+ *         GNUNET_NO if there was not enough memory to queue it,
+ *         GNUNET_SYSERR if the sock does not belong with this select
  */
-int select_would_try (struct SelectHandle *sh,
-                      struct SocketHandle *sock,
-                      unsigned int size, int mayBlock, int force);
+int GNUNET_select_test_write_now (struct GNUNET_SelectHandle *sh,
+                                  struct GNUNET_SocketHandle *sock,
+                                  unsigned int size, int mayBlock, int force);
 
 /**
  * Add another (already connected) socket to the set of
  * sockets managed by the select.
  */
-int select_connect (struct SelectHandle *sh,
-                    struct SocketHandle *sock, void *sock_ctx);
+int GNUNET_select_connect (struct GNUNET_SelectHandle *sh,
+                           struct GNUNET_SocketHandle *sock, void *sock_ctx);
 
 
 /**
@@ -487,20 +502,22 @@
  * value.  Use 0 to use the default timeout for
  * this select.
  */
-int select_change_timeout (struct SelectHandle *sh,
-                           struct SocketHandle *sock, cron_t timeout);
+int GNUNET_select_change_timeout (struct GNUNET_SelectHandle *sh,
+                                  struct GNUNET_SocketHandle *sock,
+                                  GNUNET_CronTime timeout);
 
 /**
  */
-int select_update_closure (struct SelectHandle *sh,
-                           struct SocketHandle *sock,
-                           void *old_sock_ctx, void *new_sock_ctx);
+int GNUNET_select_update_closure (struct GNUNET_SelectHandle *sh,
+                                  struct GNUNET_SocketHandle *sock,
+                                  void *old_sock_ctx, void *new_sock_ctx);
 
 /**
  * Close the associated socket and remove it from the
  * set of sockets managed by select.
  */
-int select_disconnect (struct SelectHandle *sh, struct SocketHandle *sock);
+int GNUNET_select_disconnect (struct GNUNET_SelectHandle *sh,
+                              struct GNUNET_SocketHandle *sock);
 
 
 /**
@@ -511,23 +528,24 @@
  *
  * @param sa should be of type "struct sockaddr*"
  */
-char *network_get_ip_as_string (const void *sa,
-                                unsigned int salen, int do_resolve);
+char *GNUNET_get_ip_as_string (const void *sa,
+                               unsigned int salen, int do_resolve);
 
 /**
  * Get the IP address for the local machine.
  * @return NULL on error, IP as string otherwise
  */
-char *network_get_local_ip (struct GC_Configuration *cfg,
-                            struct GE_Context *ectx, IPaddr * addr);
+char *GNUNET_get_local_ip (struct GC_Configuration *cfg,
+                           struct GE_Context *ectx,
+                           GNUNET_IPv4Address * addr);
 
 
 /**
  * Change a file descriptor that refers to a pipe
  * to non-blocking IO.
- * @return OK on success
+ * @return GNUNET_OK on success
  */
-int network_make_pipe_nonblocking (struct GE_Context *ectx, int pipe);
+int GNUNET_pipe_make_nonblocking (struct GE_Context *ectx, int pipe);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

Modified: GNUnet/src/include/gnunet_util_network_client.h
===================================================================
--- GNUnet/src/include/gnunet_util_network_client.h     2007-11-23 11:22:59 UTC 
(rev 5741)
+++ GNUnet/src/include/gnunet_util_network_client.h     2007-11-23 11:51:54 UTC 
(rev 5742)
@@ -42,59 +42,69 @@
 #endif
 #endif
 
-struct ClientServerConnection;
+struct GNUNET_ClientServerConnection;
 
 /**
  * Get a connection with gnunetd.
  */
-struct ClientServerConnection *client_connection_create (struct GE_Context
-                                                         *ectx,
-                                                         struct
-                                                         GC_Configuration
-                                                         *cfg);
+struct GNUNET_ClientServerConnection *GNUNET_client_connection_create (struct
+                                                                       
GE_Context
+                                                                       *ectx,
+                                                                       struct
+                                                                       
GC_Configuration
+                                                                       *cfg);
 
 /**
  * Close a GNUnet TCP socket for now (use to temporarily close
  * a TCP connection that will probably not be used for a long
  * time; the socket will still be auto-reopened by the
- * connection_read/connection_write methods if it is a client-socket).
+ * GNUNET_client_connection_read/GNUNET_client_connection_write methods if it 
is a client-socket).
  *
- * Also, you must still call connection_destroy to free all
+ * Also, you must still call GNUNET_client_connection_destroy to free all
  * resources associated with the connection.
  */
-void connection_close_temporarily (struct ClientServerConnection *sock);
+void GNUNET_client_connection_close_temporarily (struct
+                                                 GNUNET_ClientServerConnection
+                                                 *sock);
 
 /**
  * Close a GNUnet TCP socket forever.
  * Prevent it from being opened again.
  *
- * Also, you must still call connection_destroy to free all
+ * Also, you must still call GNUNET_client_connection_destroy to free all
  * resources associated with the connection.
  */
-void connection_close_forever (struct ClientServerConnection *sock);
+void GNUNET_client_connection_close_forever (struct
+                                             GNUNET_ClientServerConnection
+                                             *sock);
 
 /**
  * Destroy connection between gnunetd and clients.
  * Also closes the connection if it is still active.
  */
-void connection_destroy (struct ClientServerConnection *con);
+void GNUNET_client_connection_destroy (struct GNUNET_ClientServerConnection
+                                       *con);
 
 /**
  * Check if a socket is open. Will ALWAYS return 'true' for a valid
  * client socket (even if the connection is closed), but will return
  * false for a closed server socket.
  *
- * @return 1 if open, 0 if closed
+ * @return GNUNET_YES if open, GNUNET_NO if closed
  */
-int connection_test_open (struct ClientServerConnection *sock);
+int GNUNET_client_connection_test_connected (struct
+                                             GNUNET_ClientServerConnection
+                                             *sock);
 
 /**
  * Check a socket, open and connect if it is closed and it is a
  * client-socket.
  *
- * @return OK if the socket is now open, SYSERR if not
+ * @return GNUNET_OK if the socket is now open, GNUNET_SYSERR if not
  */
-int connection_ensure_connected (struct ClientServerConnection *sock);
+int GNUNET_client_connection_ensure_connected (struct
+                                               GNUNET_ClientServerConnection
+                                               *sock);
 
 /**
  * Read from a GNUnet client-server connection.
@@ -102,49 +112,53 @@
  * @param sock the socket
  * @param buffer the buffer to write data to
  *        if NULL == *buffer, *buffer is allocated (caller frees)
- * @return OK if the read was successful, SYSERR if the socket
+ * @return GNUNET_OK if the read was successful, GNUNET_SYSERR if the socket
  *         was closed by the other side (if the socket is a
  *         client socket and is used again, the next
  *         read/write call will automatically attempt
  *         to re-establish the connection).
  */
-int connection_read (struct ClientServerConnection *sock,
-                     MESSAGE_HEADER ** buffer);
+int GNUNET_client_connection_read (struct GNUNET_ClientServerConnection *sock,
+                                   GNUNET_MessageHeader ** buffer);
 
 /**
  * Write to a GNUnet TCP socket.
  *
  * @param sock the socket to write to
  * @param buffer the buffer to write
- * @return OK if the write was sucessful,
- *         SYSERR if the write failed (error will be logged)
+ * @return GNUNET_OK if the write was sucessful,
+ *         GNUNET_SYSERR if the write failed (error will be logged)
  */
-int connection_write (struct ClientServerConnection *sock,
-                      const MESSAGE_HEADER * buffer);
+int GNUNET_client_connection_write (struct GNUNET_ClientServerConnection
+                                    *sock,
+                                    const GNUNET_MessageHeader * buffer);
 
 /**
  * Obtain a simple return value from the connection.
  * Note that the protocol will automatically communicate
  * errors and pass those to the error context used when
  * the socket was created.  In that case, read_result
- * will return SYSERR for the corresponding communication.
+ * will return GNUNET_SYSERR for the corresponding communication.
  *
  * @param sock the TCP socket
  * @param ret the return value from TCP
- * @return SYSERR on error, OK if the return value was
+ * @return GNUNET_SYSERR on error, GNUNET_OK if the return value was
  *         read successfully
  */
-int connection_read_result (struct ClientServerConnection *sock, int *ret);
+int GNUNET_client_connection_read_result (struct GNUNET_ClientServerConnection
+                                          *sock, int *ret);
 
 /**
  * Send a simple return value to the other side.
  *
  * @param sock the TCP socket
  * @param ret the return value to send via TCP
- * @return SYSERR on error, OK if the return value was
+ * @return GNUNET_SYSERR on error, GNUNET_OK if the return value was
  *         send successfully
  */
-int connection_write_result (struct ClientServerConnection *sock, int ret);
+int GNUNET_client_connection_write_result (struct
+                                           GNUNET_ClientServerConnection
+                                           *sock, int ret);
 
 /**
  * Stop gnunetd
@@ -152,7 +166,7 @@
  * Note that returning an error does NOT mean that
  * gnunetd will continue to run (it may have been
  * shutdown by something else in the meantime or
- * crashed).  Call connection_test_running() frequently
+ * crashed).  Call GNUNET_test_daemon_running() frequently
  * to check the status of gnunetd.
  *
  * Furthermore, note that this WILL potentially kill
@@ -162,9 +176,11 @@
  * This function does NOT need the PID and will also
  * kill daemonized gnunetd's.
  *
- * @return OK successfully stopped, SYSERR: error
+ * @return GNUNET_OK successfully stopped, GNUNET_SYSERR: error
  */
-int connection_request_shutdown (struct ClientServerConnection *sock);
+int GNUNET_client_connection_request_daemon_shutdown (struct
+                                                      
GNUNET_ClientServerConnection
+                                                      *sock);
 
 /**
  * Checks if gnunetd is running
@@ -172,21 +188,21 @@
  * Uses CS_PROTO_traffic_COUNT query to determine if gnunetd is
  * running.
  *
- * @return OK if gnunetd is running, SYSERR if not
+ * @return GNUNET_OK if gnunetd is running, GNUNET_SYSERR if not
  */
-int connection_test_running (struct GE_Context *ectx,
-                             struct GC_Configuration *cfg);
+int GNUNET_test_daemon_running (struct GE_Context *ectx,
+                                struct GC_Configuration *cfg);
 
 /**
  * Wait until the gnunet daemon is
  * running.
  *
  * @param timeout how long to wait at most in ms
- * @return OK if gnunetd is now running
+ * @return GNUNET_OK if gnunetd is now running
  */
-int connection_wait_for_running (struct GE_Context *ectx,
-                                 struct GC_Configuration *cfg,
-                                 cron_t timeout);
+int GNUNET_wait_for_daemon_running (struct GE_Context *ectx,
+                                    struct GC_Configuration *cfg,
+                                    GNUNET_CronTime timeout);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

Modified: GNUnet/src/include/gnunet_util_os.h
===================================================================
--- GNUnet/src/include/gnunet_util_os.h 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/include/gnunet_util_os.h 2007-11-23 11:51:54 UTC (rev 5742)
@@ -46,83 +46,90 @@
 /**
  * 32-bit timer value.
  */
-typedef unsigned int TIME_T;
+typedef unsigned int GNUNET_Int32Time;
 
 /**
  * @brief Inter-process semaphore.
  */
-struct IPC_SEMAPHORE;
+struct GNUNET_IPC_Semaphore;
 
 /**
  * @brief plugin (shared library) handle
  */
-struct PluginHandle;
+struct GNUNET_PluginHandle;
 
 /**
- * TIME prototype. "man time".
+ * GNUNET_get_time_int32 prototype. "man time".
  */
-TIME_T TIME (TIME_T * t);
+GNUNET_Int32Time GNUNET_get_time_int32 (GNUNET_Int32Time * t);
 
 /**
  * "man ctime_r".
  * @return character sequence describing the time,
  *  must be freed by caller
  */
-char *GN_CTIME (const TIME_T * t);
+char *GNUNET_int32_time_to_string (const GNUNET_Int32Time * t);
 
 /**
  * @param isDefault is this presumably the default interface
- * @return OK to continue iteration, SYSERR to abort
+ * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
  */
-typedef int (*NetworkIfcProcessor) (const char *name,
-                                    int isDefault, void *cls);
+typedef int (*GNUNET_NetworkInterfaceProcessor) (const char *name,
+                                                 int isDefault, void *cls);
 
 typedef enum
 {
-  Download,
-  Upload,
-} NetworkDirection;
+  GNUNET_ND_DOWNLOAD,
+  GNUNET_ND_UPLOAD,
+} GNUNET_NETWORK_DIRECTION;
 
-struct LoadMonitor;
+struct GNUNET_LoadMonitor;
 
-struct IPC_SEMAPHORE *IPC_SEMAPHORE_CREATE (struct GE_Context *ectx,
-                                            const char *basename,
-                                            unsigned int initialValue);
+struct GNUNET_IPC_Semaphore *GNUNET_IPC_semaphore_create (struct GE_Context
+                                                          *ectx,
+                                                          const char
+                                                          *basename,
+                                                          unsigned int
+                                                          initialValue);
 
-void IPC_SEMAPHORE_DESTROY (struct IPC_SEMAPHORE *sem);
+void GNUNET_IPC_semaphore_destroy (struct GNUNET_IPC_Semaphore *sem);
 
-void IPC_SEMAPHORE_UP (struct IPC_SEMAPHORE *sem);
+void GNUNET_IPC_semaphore_up (struct GNUNET_IPC_Semaphore *sem);
 
 /**
- * @return OK on success, SYSERR if would block
+ * @return GNUNET_OK on success, GNUNET_SYSERR if would block
  */
-int IPC_SEMAPHORE_DOWN (struct IPC_SEMAPHORE *sem, int mayBlock);
+int GNUNET_IPC_semaphore_down (struct GNUNET_IPC_Semaphore *sem,
+                               int mayBlock);
 
 /**
  * Load plugin
  */
-struct PluginHandle *os_plugin_load (struct GE_Context *ectx,
-                                     const char *libprefix,
-                                     const char *dsoname);
+struct GNUNET_PluginHandle *GNUNET_plugin_load (struct GE_Context *ectx,
+                                                const char *libprefix,
+                                                const char *dsoname);
 
 /**
  * Try resolving a function provided by the plugin
- * @param logError YES if failure to find the function
+ * @param logError GNUNET_YES if failure to find the function
  *        is an error that should be logged
  * @param methodprefix prefix for the method; the
  *        method name will be automatically extended
  *        with the respective dsoname of the plugin
  * @return NULL on error, otherwise pointer to the function
  */
-void *os_plugin_resolve_function (struct PluginHandle *plugin,
-                                  const char *methodprefix, int logError);
+void *GNUNET_plugin_resolve_function (struct GNUNET_PluginHandle *plugin,
+                                      const char *methodprefix, int logError);
 
-void os_plugin_unload (struct PluginHandle *plugin);
+void GNUNET_plugin_unload (struct GNUNET_PluginHandle *plugin);
 
-struct LoadMonitor *os_network_monitor_create (struct GE_Context *ectx,
-                                               struct GC_Configuration *cfg);
+struct GNUNET_LoadMonitor *GNUNET_network_monitor_create (struct GE_Context
+                                                          *ectx,
+                                                          struct
+                                                          GC_Configuration
+                                                          *cfg);
 
-void os_network_monitor_destroy (struct LoadMonitor *mon);
+void GNUNET_network_monitor_destroy (struct GNUNET_LoadMonitor *mon);
 
 /**
  * Get the load of the network relative to what is allowed.
@@ -130,8 +137,8 @@
  * @return the network load as a percentage of allowed
  *        (100 is equivalent to full load)
  */
-int os_network_monitor_get_load (struct LoadMonitor *monitor,
-                                 NetworkDirection dir);
+int GNUNET_network_monitor_get_load (struct GNUNET_LoadMonitor *monitor,
+                                     GNUNET_NETWORK_DIRECTION dir);
 
 /**
  * Get the total amoung of bandwidth this load monitor allows
@@ -139,55 +146,59 @@
  *
  * @return the maximum bandwidth in bytes per second, -1 for no limit
  */
-unsigned long long os_network_monitor_get_limit (struct LoadMonitor *monitor,
-                                                 NetworkDirection dir);
+unsigned long long GNUNET_network_monitor_get_limit (struct GNUNET_LoadMonitor
+                                                     *monitor,
+                                                     GNUNET_NETWORK_DIRECTION
+                                                     dir);
 
 /**
  * Tell monitor to increment the number of bytes sent/received
  */
-void os_network_monitor_notify_transmission (struct LoadMonitor *monitor,
-                                             NetworkDirection dir,
-                                             unsigned long long delta);
+void GNUNET_network_monitor_notify_transmission (struct GNUNET_LoadMonitor
+                                                 *monitor,
+                                                 GNUNET_NETWORK_DIRECTION dir,
+                                                 unsigned long long delta);
 
 /**
  * @brief Enumerate all network interfaces
  * @param callback the callback function
  */
-void os_list_network_interfaces (struct GE_Context *ectx,
-                                 NetworkIfcProcessor proc, void *cls);
+void GNUNET_list_network_interfaces (struct GE_Context *ectx,
+                                     GNUNET_NetworkInterfaceProcessor proc,
+                                     void *cls);
 
 /**
  * @brief Set maximum number of open file descriptors
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int os_set_fd_limit (struct GE_Context *ectx, int n);
+int GNUNET_set_fd_limit (struct GE_Context *ectx, int n);
 
 /**
  * Set our process priority
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int os_set_process_priority (struct GE_Context *ectx, const char *str);
+int GNUNET_set_process_priority (struct GE_Context *ectx, const char *str);
 
 /**
  * @brief Make "application" start automatically
  *
- * @param testCapability YES to merely probe if the OS has this
+ * @param testCapability GNUNET_YES to merely probe if the OS has this
  *        functionality (in that case, no actual operation is
- *        performed).  SYSERR is returned if
+ *        performed).  GNUNET_SYSERR is returned if
  *        a) autostart is not supported,
  *        b) the application does not seem to exist
  *        c) the user or group do not exist
  *        d) the user has insufficient permissions for
  *           changing autostart
- *        e) doAutoStart is NO, but autostart is already
+ *        e) doAutoStart is GNUNET_NO, but autostart is already
  *           disabled
- *        f) doAutoStart is YES, but autostart is already
+ *        f) doAutoStart is GNUNET_YES, but autostart is already
  *           enabled
- * @param doAutoStart YES to enable autostart of the
- *        application, NO to disable it
+ * @param doAutoStart GNUNET_YES to enable autostart of the
+ *        application, GNUNET_NO to disable it
  * @param username name of the user account to use
  * @param groupname name of the group to use
- * @returns YES on success, NO if unsupported, SYSERR on failure or one of
+ * @returns GNUNET_YES on success, GNUNET_NO if unsupported, GNUNET_SYSERR on 
failure or one of
  *          these error codes:
  *  Windows
  *    2 SCM could not be opened
@@ -198,44 +209,45 @@
  *  Unix
  *    2 startup script could not be opened
  */
-int os_modify_autostart (struct GE_Context *ectx,
-                         int testCapability,
-                         int doAutoStart,
-                         const char *application,
-                         const char *username, const char *groupname);
+int GNUNET_configure_autostart (struct GE_Context *ectx,
+                                int testCapability,
+                                int doAutoStart,
+                                const char *application,
+                                const char *username, const char *groupname);
 
 /**
  * @brief Add or remove a service account for GNUnet
  *
- * @param testCapability YES to merely probe if the OS has this
+ * @param testCapability GNUNET_YES to merely probe if the OS has this
  *        functionality (in that case, no actual operation is
- *        performed).  SYSERR is returned if
+ *        performed).  GNUNET_SYSERR is returned if
  *        a) adding users is not supported,
  *        b) the user has insufficient permissions for
  *           adding/removing users
- *        c) doAdd is NO, but user does not exist
- *        d) doAdd is YES, and user already exists
- * @param doAdd YES to add, NO to remove user, SYSERR to
+ *        c) doAdd is GNUNET_NO, but user does not exist
+ *        d) doAdd is GNUNET_YES, and user already exists
+ * @param doAdd GNUNET_YES to add, GNUNET_NO to remove user, GNUNET_SYSERR to
  *        purge (removes user AND group)
  * @param name the name of the user
  * @param group name of the group
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int os_modify_user (int testCapability,
-                    int doAdd, const char *name, const char *group);
+int GNUNET_configure_user_account (int testCapability,
+                                   int doAdd, const char *name,
+                                   const char *group);
 
 /**
  * Change current process to run as the given
  * user
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int os_change_user (struct GE_Context *ectx, const char *user);
+int GNUNET_change_user (struct GE_Context *ectx, const char *user);
 
 /**
  * @brief Change owner of a file
  */
-int os_change_owner (struct GE_Context *ectx,
-                     const char *filename, const char *user);
+int GNUNET_file_change_owner (struct GE_Context *ectx,
+                              const char *filename, const char *user);
 
 /**
  * Get the current CPU load.
@@ -244,7 +256,8 @@
  * @return -1 on error, otherwise load value (between 0 and 100,
  *        (100 is equivalent to full load for one CPU)
  */
-int os_cpu_get_load (struct GE_Context *ectx, struct GC_Configuration *cfg);
+int GNUNET_cpu_get_load (struct GE_Context *ectx,
+                         struct GC_Configuration *cfg);
 
 /**
  * Get the current IO load.
@@ -255,19 +268,20 @@
  *       100 means that we spend all of our cycles waiting for
  *       the disk)
  */
-int os_disk_get_load (struct GE_Context *ectx, struct GC_Configuration *cfg);
+int GNUNET_disk_get_load (struct GE_Context *ectx,
+                          struct GC_Configuration *cfg);
 
 /**
  * Start gnunetd process
  *
  * @param cfgFile configuration file to use, NULL for default
- * @param daemonize YES if gnunetd should be daemonized
+ * @param daemonize GNUNET_YES if gnunetd should be daemonized
  * @return pid_t of gnunetd if NOT daemonized, 0 if
  *  daemonized sucessfully, -1 on error
  */
-int os_daemon_start (struct GE_Context *ectx,
-                     struct GC_Configuration *cfg,
-                     const char *cfgFile, int daemonize);
+int GNUNET_daemon_start (struct GE_Context *ectx,
+                         struct GC_Configuration *cfg,
+                         const char *cfgFile, int daemonize);
 
 /**
  * Wait until the gnunet daemon (or any other CHILD process for that
@@ -275,23 +289,23 @@
  * the daemon was started with daemon_start in no-daemonize mode.
  * On arbitrary PIDs, this function may fail unexpectedly.
  *
- * @return YES if gnunetd shutdown with
- *  return value 0, SYSERR if waitpid
- *  failed, NO if gnunetd shutdown with
+ * @return GNUNET_YES if gnunetd shutdown with
+ *  return value 0, GNUNET_SYSERR if waitpid
+ *  failed, GNUNET_NO if gnunetd shutdown with
  *  some error
  */
-int os_daemon_stop (struct GE_Context *ectx, int pid);
+int GNUNET_daemon_stop (struct GE_Context *ectx, int pid);
 
 /**
  * List of install paths
  */
-enum InstallPathKind
+enum GNUNET_INSTALL_PATH_KIND
 {
-  IPK_PREFIX,
-  IPK_BINDIR,
-  IPK_LIBDIR,
-  IPK_DATADIR,
-  IPK_LOCALEDIR
+  GNUNET_IPK_PREFIX,
+  GNUNET_IPK_BINDIR,
+  GNUNET_IPK_LIBDIR,
+  GNUNET_IPK_DATADIR,
+  GNUNET_IPK_LOCALEDIR
 };
 
 /**
@@ -301,24 +315,24 @@
  * @param cfg the context to get configuration values from
  * @return a pointer to the dir path (to be freed by the caller)
  */
-char *os_get_installation_path (enum InstallPathKind dirkind);
+char *GNUNET_get_installation_path (enum GNUNET_INSTALL_PATH_KIND dirkind);
 
 /**
  * Write our process ID to the pid file.  Use only
- * if you are not calling os_terminal_detach, since
- * os_terminal_detach will already write the pid file.
+ * if you are not calling GNUNET_terminal_detach, since
+ * GNUNET_terminal_detach will already write the pid file.
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
-int os_write_pid_file (struct GE_Context *ectx,
-                       struct GC_Configuration *cfg, unsigned int pid);
+int GNUNET_pid_file_write (struct GE_Context *ectx,
+                           struct GC_Configuration *cfg, unsigned int pid);
 
 /**
  * Delete the PID file (to be called when the daemon
  * shuts down)
  */
-int os_delete_pid_file (struct GE_Context *ectx,
-                        struct GC_Configuration *cfg);
+int GNUNET_pid_file_delete (struct GE_Context *ectx,
+                            struct GC_Configuration *cfg);
 
 
 /**
@@ -329,22 +343,22 @@
  * @param filedes pointer to an array of 2 file descriptors
  *        to complete the detachment protocol (handshake)
  */
-int os_terminal_detach (struct GE_Context *ectx,
-                        struct GC_Configuration *cfg, int *filedes);
+int GNUNET_terminal_detach (struct GE_Context *ectx,
+                            struct GC_Configuration *cfg, int *filedes);
 
 /**
  * Complete the handshake of detaching from the terminal.
- * @param success use NO for error, YES for successful start
+ * @param success use GNUNET_NO for error, GNUNET_YES for successful start
  */
-void os_terminal_detach_complete (struct GE_Context *ectx,
-                                  int *filedes, int success);
+void GNUNET_terminal_detach_complete (struct GE_Context *ectx,
+                                      int *filedes, int success);
 
 /**
  * @brief Perform OS specific initalization
  * @param ectx logging context, NULL means stderr
- * @returns OK on success, SYSERR otherwise
+ * @returns GNUNET_OK on success, GNUNET_SYSERR otherwise
  */
-int os_init (struct GE_Context *ectx);
+int GNUNET_os_init (struct GE_Context *ectx);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

Modified: GNUnet/src/include/gnunet_util_string.h
===================================================================
--- GNUnet/src/include/gnunet_util_string.h     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_util_string.h     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other 
contributing authors)
+     (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Christian Grothoff (and 
other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -51,9 +51,9 @@
 #include "gnunet_util_config.h"
 
 /**
- * Maximum allocation with MALLOC macro.
+ * Maximum allocation with GNUNET_malloc macro.
  */
-#define MAX_MALLOC_CHECKED (1024 * 1024 * 40)
+#define GNUNET_MAX_GNUNET_malloc_CHECKED (1024 * 1024 * 40)
 
 /**
  * Wrapper around malloc. Allocates size bytes of memory.
@@ -62,7 +62,7 @@
  *        smaller than 40 MB.
  * @return pointer to size bytes of memory
  */
-#define MALLOC(size) xmalloc_(size, __FILE__, __LINE__, __FUNCTION__)
+#define GNUNET_malloc(size) GNUNET_xmalloc_(size, __FILE__, __LINE__, 
__FUNCTION__)
 
 /**
  * Wrapper around malloc. Allocates size bytes of memory.
@@ -70,7 +70,7 @@
  * @param size the number of bytes to allocate
  * @return pointer to size bytes of memory
  */
-#define MALLOC_LARGE(size) xmalloc_unchecked_(size, __FILE__, __LINE__, 
__FUNCTION__)
+#define GNUNET_malloc_large(size) GNUNET_xmalloc_unchecked_(size, __FILE__, 
__LINE__, __FUNCTION__)
 
 /**
  * Wrapper around realloc. Rellocates size bytes of memory.
@@ -79,46 +79,36 @@
  * @param size the number of bytes to reallocate
  * @return pointer to size bytes of memory
  */
-#define REALLOC(ptr, size) xrealloc_(ptr, size, __FILE__, __LINE__, 
__FUNCTION__)
+#define GNUNET_realloc(ptr, size) GNUNET_xrealloc_(ptr, size, __FILE__, 
__LINE__, __FUNCTION__)
 
 /**
  * Wrapper around free. Frees the memory referred to by ptr.
  * Note that is is generally better to free memory that was
- * allocated with GROW using GROW(mem, size, 0) instead of FREE.
+ * allocated with GNUNET_array_grow using GNUNET_array_grow(mem, size, 0) 
instead of GNUNET_free.
  *
  * @param ptr location where to free the memory. ptr must have
- *     been returned by STRDUP, MALLOC or GROW earlier.
+ *     been returned by GNUNET_strdup, GNUNET_malloc or GNUNET_array_grow 
earlier.
  */
-#define FREE(ptr) xfree_(ptr, __FILE__, __LINE__,  __FUNCTION__)
+#define GNUNET_free(ptr) GNUNET_xfree_(ptr, __FILE__, __LINE__,  __FUNCTION__)
 
 /**
  * Free the memory pointed to by ptr if ptr is not NULL.
- * Equivalent to if (ptr!=null)FREE(ptr).
+ * Equivalent to if (ptr!=null)GNUNET_free(ptr).
  *
  * @param ptr the location in memory to free
  */
-#define FREENONNULL(ptr) do { void * __x__ = ptr; if (__x__ != NULL) { 
FREE(__x__); } } while(0)
+#define GNUNET_free_non_null(ptr) do { void * __x__ = ptr; if (__x__ != NULL) 
{ GNUNET_free(__x__); } } while(0)
 
 /**
- * Wrapper around STRDUP.  Makes a copy of the zero-terminated string
+ * Wrapper around GNUNET_strdup.  Makes a copy of the zero-terminated string
  * pointed to by a.
  *
  * @param a pointer to a zero-terminated string
  * @return a copy of the string including zero-termination
  */
-#define STRDUP(a) xstrdup_(a,__FILE__,__LINE__, __FUNCTION__)
+#define GNUNET_strdup(a) GNUNET_xstrdup_(a,__FILE__,__LINE__, __FUNCTION__)
 
 /**
- * Wrapper around STRNDUP.  Makes a copy of the zero-terminated string
- * pointed to by a.
- *
- * @param a pointer to a zero-terminated string
- * @param n the maximum number of characters to copy (+1 for 0-termination)
- * @return a copy of the string including zero-termination
- */
-#define STRNDUP(a,n) xstrndup_(a, n, __FILE__, __LINE__, __FUNCTION__)
-
-/**
  * Grow a well-typed (!) array.  This is a convenience
  * method to grow a vector <tt>arr</tt> of size <tt>size</tt>
  * to the new (target) size <tt>tsize</tt>.
@@ -131,14 +121,14 @@
  * static int myVecLen = 0;
  *
  * static void push(struct foo * elem) {
- *   GROW(myVector, myVecLen, myVecLen+1);
+ *   GNUNET_array_grow(myVector, myVecLen, myVecLen+1);
  *   memcpy(&myVector[myVecLen-1], elem, sizeof(struct foo));
  * }
  *
  * static void pop(struct foo * elem) {
  *   if (myVecLen == 0) die();
  *   memcpy(elem, myVector[myVecLen-1], sizeof(struct foo));
- *   GROW(myVector, myVecLen, myVecLen-1);
+ *   GNUNET_array_grow(myVector, myVecLen, myVecLen-1);
  * }
  * </pre>
  *
@@ -151,29 +141,29 @@
  * @param tsize the target size for the resulting vector, use 0 to
  *        free the vector (then, arr will be NULL afterwards).
  */
-#define GROW(arr,size,tsize) xgrow_((void**)&arr, sizeof(arr[0]), &size, 
tsize, __FILE__, __LINE__, __FUNCTION__)
+#define GNUNET_array_grow(arr,size,tsize) GNUNET_xgrow_((void**)&arr, 
sizeof(arr[0]), &size, tsize, __FILE__, __LINE__, __FUNCTION__)
 
 /**
  * Append an element to a list (growing the
  * list by one).
  */
-#define APPEND(arr,size,element) do { GROW(arr,size,size+1); arr[size-1] = 
element; } while(0)
+#define GNUNET_array_append(arr,size,element) do { 
GNUNET_array_grow(arr,size,size+1); arr[size-1] = element; } while(0)
 
 /**
  * Like snprintf, just aborts if the buffer is of insufficient size.
  */
-int SNPRINTF (char *buf, size_t size, const char *format, ...);
+int GNUNET_snprintf (char *buf, size_t size, const char *format, ...);
 
 /**
  * Give relative time in human-readable fancy format.
  * @param delta time in milli seconds
  */
-char *string_get_fancy_time_interval (unsigned long long delta);
+char *GNUNET_get_time_interval_as_fancy_string (unsigned long long delta);
 
 /**
  * Convert a given filesize into a fancy human-readable format.
  */
-char *string_get_fancy_byte_size (unsigned long long size);
+char *GNUNET_get_byte_size_as_fancy_string (unsigned long long size);
 
 /**
  * Convert the len characters long character sequence
@@ -182,9 +172,9 @@
  *
  * @return the converted string (0-terminated)
  */
-char *string_convertToUtf8 (struct GE_Context *ectx,
-                            const char *input,
-                            size_t len, const char *charset);
+char *GNUNET_convert_string_to_utf8 (struct GE_Context *ectx,
+                                     const char *input,
+                                     size_t len, const char *charset);
 
 /**
  * Complete filename (a la shell) from abbrevition.
@@ -194,82 +184,61 @@
  * @returns the full file name,
  *          NULL is returned on error
  */
-char *string_expandFileName (struct GE_Context *ectx, const char *fil);
+char *GNUNET_expand_file_name (struct GE_Context *ectx, const char *fil);
 
-/**
- * String functions
- */
-#if !HAVE_STRLCPY
-size_t strlcpy (char *dest, const char *src, size_t size);
-#endif
-
-#if !HAVE_STRLCAT
-size_t strlcat (char *dest, const char *src, size_t count);
-#endif
-
-
 /* ************** internal implementations, use macros above! ************** */
 
 /**
  * Allocate memory. Checks the return value, aborts if no more
- * memory is available.  Don't use xmalloc_ directly. Use the
- * MALLOC macro.
+ * memory is available.  Don't use GNUNET_xmalloc_ directly. Use the
+ * GNUNET_malloc macro.
  */
-void *xmalloc_ (size_t size,
-                const char *filename, int linenumber, const char *function);
+void *GNUNET_xmalloc_ (size_t size,
+                       const char *filename, int linenumber,
+                       const char *function);
 
 /**
  * Allocate memory.  This function does not check if the
  * allocation request is within reasonable bounds, allowing
  * allocations larger than 40 MB.  If you don't expect the
- * possibility of very large allocations, use MALLOC instead.
+ * possibility of very large allocations, use GNUNET_malloc instead.
  */
-void *xmalloc_unchecked_ (size_t size,
-                          const char *filename,
-                          int linenumber, const char *function);
+void *GNUNET_xmalloc_unchecked_ (size_t size,
+                                 const char *filename,
+                                 int linenumber, const char *function);
 
 /**
  * Reallocate memory. Checks the return value, aborts if no more
  * memory is available.
  */
-void *xrealloc_ (void *ptr,
-                 const size_t n,
-                 const char *filename, int linenumber, const char *function);
+void *GNUNET_xrealloc_ (void *ptr,
+                        const size_t n,
+                        const char *filename, int linenumber,
+                        const char *function);
 
 /**
  * Free memory. Merely a wrapper for the case that we
- * want to keep track of allocations.  Don't use xfree_
- * directly. Use the FREE macro.
+ * want to keep track of allocations.  Don't use GNUNET_xfree_
+ * directly. Use the GNUNET_free macro.
  */
-void xfree_ (void *ptr,
-             const char *filename, int linenumber, const char *function);
+void GNUNET_xfree_ (void *ptr,
+                    const char *filename, int linenumber,
+                    const char *function);
 
 
 /**
- * Dup a string. Don't call xstrdup_ directly. Use the STRDUP macro.
+ * Dup a string. Don't call GNUNET_xstrdup_ directly. Use the GNUNET_strdup 
macro.
  */
-char *xstrdup_ (const char *str,
-                const char *filename, int linenumber, const char *function);
+char *GNUNET_xstrdup_ (const char *str,
+                       const char *filename, int linenumber,
+                       const char *function);
 
 /**
- * Dup a string. Don't call xstrdup_ directly. Use the STRDUP macro.
- *
- * @param str the string to dup
- * @param n the maximum number of characters to copy (+1 for 0-termination)
- * @param filename where in the code was the call to GROW
- * @param linenumber where in the code was the call to GROW
- * @return strdup(str)
- */
-char *xstrndup_ (const char *str,
-                 const size_t n,
-                 const char *filename, int linenumber, const char *function);
-
-/**
  * Grow an array, the new elements are zeroed out.
  * Grows old by (*oldCount-newCount)*elementSize
  * bytes and sets *oldCount to newCount.
  *
- * Don't call xgrow_ directly. Use the GROW macro.
+ * Don't call GNUNET_xgrow_ directly. Use the GNUNET_array_grow macro.
  *
  * @param old address of the pointer to the array
  *        *old may be NULL
@@ -277,11 +246,12 @@
  * @param oldCount address of the number of elements in the *old array
  * @param newCount number of elements in the new array, may be 0 (then *old 
will be NULL afterwards)
  */
-void xgrow_ (void **old,
-             size_t elementSize,
-             unsigned int *oldCount,
-             unsigned int newCount,
-             const char *filename, int linenumber, const char *function);
+void GNUNET_xgrow_ (void **old,
+                    size_t elementSize,
+                    unsigned int *oldCount,
+                    unsigned int newCount,
+                    const char *filename, int linenumber,
+                    const char *function);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

Modified: GNUnet/src/include/gnunet_util_threads.h
===================================================================
--- GNUnet/src/include/gnunet_util_threads.h    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/include/gnunet_util_threads.h    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -43,63 +43,63 @@
 /**
  * Time for absolute times used by cron (64 bit)
  */
-typedef unsigned long long cron_t;
+typedef unsigned long long GNUNET_CronTime;
 
 
 /**
  * @brief constants to specify time
  */
-#define cronMILLIS ((cron_t)1)
-#define cronSECONDS ((cron_t)(1000 * cronMILLIS))
-#define cronMINUTES ((cron_t) (60 * cronSECONDS))
-#define cronHOURS ((cron_t)(60 * cronMINUTES))
-#define cronDAYS ((cron_t)(24 * cronHOURS))
-#define cronWEEKS ((cron_t)(7 * cronDAYS))
-#define cronMONTHS ((cron_t)(30 * cronDAYS))
-#define cronYEARS ((cron_t)(365 * cronDAYS))
+#define GNUNET_CRON_MILLISECONDS ((GNUNET_CronTime)1L)
+#define GNUNET_CRON_SECONDS ((GNUNET_CronTime)(1000 * 
GNUNET_CRON_MILLISECONDS))
+#define GNUNET_CRON_MINUTES ((GNUNET_CronTime) (60 * GNUNET_CRON_SECONDS))
+#define GNUNET_CRON_HOURS ((GNUNET_CronTime)(60 * GNUNET_CRON_MINUTES))
+#define GNUNET_CRON_DAYS ((GNUNET_CronTime)(24 * GNUNET_CRON_HOURS))
+#define GNUNET_CRON_WEEKS ((GNUNET_CronTime)(7 * GNUNET_CRON_DAYS))
+#define GNUNET_CRON_MONTHS ((GNUNET_CronTime)(30 * GNUNET_CRON_DAYS))
+#define GNUNET_CRON_YEARS ((GNUNET_CronTime)(365 * GNUNET_CRON_DAYS))
 
 /**
  * How long will we accept locks to be held before
  * reporting that there maybe a problem?  Set to
  * zero to disable reporting.
  */
-#define REALTIME_LIMIT (000 * cronMILLIS)
+#define GNUNET_REALTIME_LIMIT (000 * GNUNET_CRON_MILLISECONDS)
 
 /**
  * Main method of a thread.
  */
-typedef void *(*PThreadMain) (void *);
+typedef void *(*GNUNET_ThreadMainFunction) (void *);
 
 /**
  * @brief Encapsulation of a pthread handle.
  */
-struct PTHREAD;
+struct GNUNET_ThreadHandle;
 
 /**
  * @brief Structure for MUTual EXclusion (Mutex).
  */
-struct MUTEX;
+struct GNUNET_Mutex;
 
 /**
  * @brief semaphore abstraction (for pthreads)
  */
-struct SEMAPHORE;
+struct GNUNET_Semaphore;
 
 /**
- * Returns YES if pt is the handle for THIS thread.
+ * Returns GNUNET_YES if pt is the handle for THIS thread.
  */
-int PTHREAD_TEST_SELF (struct PTHREAD *pt);
+int GNUNET_thread_test_self (struct GNUNET_ThreadHandle *pt);
 
 /**
  * Get the handle for THIS thread.
  */
-struct PTHREAD *PTHREAD_GET_SELF (void);
+struct GNUNET_ThreadHandle *GNUNET_thread_get_self (void);
 
 /**
  * Release handle for a thread (should have been
- * obtained using PTHREAD_GET_SELF).
+ * obtained using GNUNET_thread_get_self).
  */
-void PTHREAD_REL_SELF (struct PTHREAD *pt);
+void GNUNET_thread_release_self (struct GNUNET_ThreadHandle *pt);
 
 /**
  * Create a thread. Use this method instead of pthread_create since
@@ -112,8 +112,9 @@
  *        will just segfault and gdb will give a messed-up stacktrace.
  * @return the handle
  */
-struct PTHREAD *PTHREAD_CREATE (PThreadMain main,
-                                void *arg, unsigned int stackSize);
+struct GNUNET_ThreadHandle *GNUNET_thread_create (GNUNET_ThreadMainFunction
+                                                  main, void *arg,
+                                                  unsigned int stackSize);
 
 
 
@@ -123,8 +124,9 @@
  *
  * @param ret set to the return value of the other thread.
  */
-void PTHREAD_JOIN_FL (struct PTHREAD *handle,
-                      void **ret, const char *file, unsigned int line);
+void GNUNET_thread_join_at_file_line_ (struct GNUNET_ThreadHandle *handle,
+                                       void **ret, const char *file,
+                                       unsigned int line);
 
 /**
  * Wait for the other thread to terminate.  May only be called
@@ -132,75 +134,77 @@
  *
  * @param ret set to the return value of the other thread.
  */
-#define PTHREAD_JOIN(handle,ret) PTHREAD_JOIN_FL(handle,ret,__FILE__,__LINE__)
+#define GNUNET_thread_join(handle,ret) 
GNUNET_thread_join_at_file_line_(handle,ret,__FILE__,__LINE__)
 
 /**
- * Sleep for the specified time interval.  PTHREAD_STOP_SLEEP can be
+ * Sleep for the specified time interval.  GNUNET_thread_stop_sleep can be
  * used to interrupt the sleep.  Caller is responsible to check that
  * the sleep was long enough.
  *
  * @param time how long to sleep (in milli seconds)
  */
-void PTHREAD_SLEEP (cron_t time);
+void GNUNET_thread_sleep (GNUNET_CronTime time);
 
 /**
  * Get the current time (in cron-units).
  *
  * @return the current time
  */
-cron_t get_time (void);
+GNUNET_CronTime GNUNET_get_time (void);
 
 /**
- * Stop the sleep of anothe thread.
+ * Stop the sleep of another thread.
  */
-void PTHREAD_STOP_SLEEP (struct PTHREAD *handle);
+void GNUNET_thread_stop_sleep (struct GNUNET_ThreadHandle *handle);
 
-struct MUTEX *MUTEX_CREATE (int isRecursive);
+struct GNUNET_Mutex *GNUNET_mutex_create (int isRecursive);
 
-void MUTEX_DESTROY (struct MUTEX *mutex);
+void GNUNET_mutex_destroy (struct GNUNET_Mutex *mutex);
 
-void MUTEX_LOCK_FL (struct MUTEX *mutex, const char *file, unsigned int line);
+void GNUNET_mutex_lock_at_file_line_ (struct GNUNET_Mutex *mutex,
+                                      const char *file, unsigned int line);
 
-#define MUTEX_LOCK(mutex) MUTEX_LOCK_FL(mutex, __FILE__, __LINE__)
+#define GNUNET_mutex_lock(mutex) GNUNET_mutex_lock_at_file_line_(mutex, 
__FILE__, __LINE__)
 
-void MUTEX_UNLOCK (struct MUTEX *mutex);
+void GNUNET_mutex_unlock (struct GNUNET_Mutex *mutex);
 
-struct SEMAPHORE *SEMAPHORE_CREATE (int value);
+struct GNUNET_Semaphore *GNUNET_semaphore_create (int value);
 
-void SEMAPHORE_DESTROY (struct SEMAPHORE *sem);
+void GNUNET_semaphore_destroy (struct GNUNET_Semaphore *sem);
 
 /**
- * @param block set to NO to never block (and
+ * @param block set to GNUNET_NO to never block (and
  *        thus fail if semaphore counter is 0)
- * @return SYSERR if would block, otherwise
+ * @return GNUNET_SYSERR if would block, otherwise
  *  new count value after change
  */
-int SEMAPHORE_DOWN_FL (struct SEMAPHORE *sem,
-                       int mayblock,
-                       int longwait, const char *file, unsigned int line);
+int GNUNET_semaphore_down_at_file_line_ (struct GNUNET_Semaphore *sem,
+                                         int mayblock,
+                                         int longwait, const char *file,
+                                         unsigned int line);
 
 
 /**
- * @param block set to NO to never block (and
+ * @param block set to GNUNET_NO to never block (and
  *        thus fail if semaphore counter is 0)
- * @return SYSERR if would block, otherwise
+ * @return GNUNET_SYSERR if would block, otherwise
  *  new count value after change
  */
-#define SEMAPHORE_DOWN(sem, mayblock) SEMAPHORE_DOWN_FL(sem, mayblock, YES, 
__FILE__, __LINE__)
+#define GNUNET_semaphore_down(sem, mayblock) 
GNUNET_semaphore_down_at_file_line_(sem, mayblock, GNUNET_YES, __FILE__, 
__LINE__)
 
 
 /**
- * Like SEMAPHORE_DOWN, just with the expectation
+ * Like GNUNET_semaphore_down, just with the expectation
  * that this operation does not take a long time.
  * (used for debugging unexpected high-latency
  * behavior).
  *
- * @param block set to NO to never block (and
+ * @param block set to GNUNET_NO to never block (and
  *        thus fail if semaphore counter is 0)
- * @return SYSERR if would block, otherwise
+ * @return GNUNET_SYSERR if would block, otherwise
  *  new count value after change
  */
-#define SEMAPHORE_DOWN_FAST(sem, mayblock) SEMAPHORE_DOWN_FL(sem, mayblock, 
NO, __FILE__, __LINE__)
+#define GNUNET_semaphore_down_fast(sem, mayblock) 
GNUNET_semaphore_down_at_file_line_(sem, mayblock, GNUNET_NO, __FILE__, 
__LINE__)
 
 /**
  * function increments the semaphore and signals any threads that
@@ -208,19 +212,19 @@
  *
  * @return new count value of the semaphore after increment
  */
-int SEMAPHORE_UP (struct SEMAPHORE *sem);
+int GNUNET_semaphore_up (struct GNUNET_Semaphore *sem);
 
 /**
  * Programatically shutdown the application.
  */
-void GNUNET_SHUTDOWN_INITIATE (void);
+void GNUNET_shutdown_initiate (void);
 
 /**
  * Test if the shutdown has been initiated.
  *
- * @return YES if we are shutting down, NO otherwise
+ * @return GNUNET_YES if we are shutting down, GNUNET_NO otherwise
  */
-int GNUNET_SHUTDOWN_TEST (void);
+int GNUNET_shutdown_test (void);
 
 /**
  * Wait until the shutdown has been initiated.  This
@@ -228,9 +232,9 @@
  * nothing better to do) to wait for a user signal
  * (or other thread) to initiate the shutdown.
  */
-void GNUNET_SHUTDOWN_WAITFOR (void);
+void GNUNET_shutdown_wait_for (void);
 
-struct SignalHandlerContext;
+struct GNUNET_SignalHandlerContext;
 
 /**
  * A signal handler.  Since different OSes have different signatures
@@ -240,18 +244,20 @@
  * the implementation must guarantee that this handler is not called
  * for signals other than the one that it has been registered for.
  */
-typedef void (*SignalHandler) (void);
+typedef void (*GNUNET_SignalHandler) (void);
 
 /**
  * Install a signal handler that will be run if the
  * given signal is received.
  */
-struct SignalHandlerContext *signal_handler_install (int signal,
-                                                     SignalHandler handler);
+struct GNUNET_SignalHandlerContext *GNUNET_signal_handler_install (int signal,
+                                                                   
GNUNET_SignalHandler
+                                                                   handler);
 
-void signal_handler_uninstall (int signal,
-                               SignalHandler handler,
-                               struct SignalHandlerContext *ctx);
+void GNUNET_signal_handler_uninstall (int signal,
+                                      GNUNET_SignalHandler handler,
+                                      struct GNUNET_SignalHandlerContext
+                                      *ctx);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {

Modified: GNUnet/src/include/platform.h
===================================================================
--- GNUnet/src/include/platform.h       2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/include/platform.h       2007-11-23 11:51:54 UTC (rev 5742)
@@ -47,7 +47,7 @@
 #include <dlfcn.h>
 #endif
 
-#define ALLOW_EXTRA_CHECKS NO
+#define ALLOW_EXTRA_CHECKS GNUNET_NO
 
 /**
  * For strptime (glibc2 needs this).
@@ -128,7 +128,7 @@
 #ifdef SOMEBSD
 #include <net/if.h>
 #endif
-#ifdef FREEBSD
+#ifdef GNUNET_freeBSD
 #include <semaphore.h>
 #endif
 #ifdef OSX

Modified: GNUnet/src/include/plibc.h
===================================================================
--- GNUnet/src/include/plibc.h  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/include/plibc.h  2007-11-23 11:51:54 UTC (rev 5742)
@@ -6,12 +6,12 @@
      modify it under the terms of the GNU Lesser General Public
      License as published by the Free Software Foundation; either
      version 2.1 of the License, or (at your option) any later version.
-  
+
      This library is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      Lesser General Public License for more details.
-  
+
      You should have received a copy of the GNU Lesser General Public
      License along with this library; if not, write to the Free Software
      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

Modified: GNUnet/src/server/Makefile.am
===================================================================
--- GNUnet/src/server/Makefile.am       2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/server/Makefile.am       2007-11-23 11:51:54 UTC (rev 5742)
@@ -18,34 +18,28 @@
  startup.c startup.h \
  version.c version.h
 libgnunetcore_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 
 
 
 gnunetd_SOURCES = \
  gnunetd.c 
 gnunetd_LDADD = \
- $(top_builddir)/src/server/libgnunetcore.la \
- $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
+ $(top_builddir)/src/server/libgnunetcore.la
 
 
 gnunet_update_SOURCES = \
  gnunet-update.c 
 gnunet_update_LDADD = \
- $(top_builddir)/src/server/libgnunetcore.la \
- $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
+ $(top_builddir)/src/server/libgnunetcore.la
 
 gnunet_peer_info_SOURCES = \
  gnunet-peer-info.c 
 gnunet_peer_info_LDADD  = \
  $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/server/libgnunetcore.la \
- $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
+ $(top_builddir)/src/server/libgnunetcore.la
 
 gnunet_transport_check_SOURCES = \
  gnunet-transport-check.c 
 gnunet_transport_check_LDADD  = \
- $(top_builddir)/src/server/libgnunetcore.la \
- $(top_builddir)/src/util/boot/libgnunetutil_boot.la 
+ $(top_builddir)/src/server/libgnunetcore.la
 

Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c      2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/server/connection.c      2007-11-23 11:51:54 UTC (rev 5742)
@@ -62,17 +62,17 @@
 
 /* tuning parameters */
 
-#define DEBUG_CONNECTION NO
+#define DEBUG_CONNECTION GNUNET_NO
 
 /**
  * output knapsack priorities into a file?
  */
-#define DEBUG_COLLECT_PRIO NO
+#define DEBUG_COLLECT_PRIO GNUNET_NO
 
 /**
  * strictly mark TSessions as down
  */
-#define STRICT_STAT_DOWN YES
+#define STRICT_STAT_DOWN GNUNET_YES
 
 /**
  * If an attempt to establish a connection is not answered
@@ -155,7 +155,7 @@
  * code? (depends on MINIMUM_SAMPLE_COUNT and MIN_BPM_PER_PEER
  * and MTU size). [2 * 32 M / 50 = 75s ]
  */
-#define MIN_SAMPLE_TIME (MINIMUM_SAMPLE_COUNT * cronMINUTES * EXPECTED_MTU / 
MIN_BPM_PER_PEER)
+#define MIN_SAMPLE_TIME (MINIMUM_SAMPLE_COUNT * GNUNET_CRON_MINUTES * 
EXPECTED_MTU / MIN_BPM_PER_PEER)
 
 /**
  * Hard limit on the send buffer size (per connection, in bytes),
@@ -280,8 +280,8 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
-  PeerIdentity sender;
+  GNUNET_MessageHeader header;
+  GNUNET_PeerIdentity sender;
 } P2P_hangup_MESSAGE;
 
 
@@ -323,7 +323,7 @@
   /**
    * when do/did we intend to transmit?
    */
-  cron_t transmissionTime;
+  GNUNET_CronTime transmissionTime;
 
   /**
    * callback to call to create the message part
@@ -331,13 +331,13 @@
   BuildMessageCallback callback;
 
   /**
-   * argument to callback, call FREENONNULL(closure) if we
+   * argument to callback, call GNUNET_free_non_null(closure) if we
    * can not transmit this MessagePart.
    */
   void *closure;
 
   /**
-   * YES if selected by knapsack for sending
+   * GNUNET_YES if selected by knapsack for sending
    */
   int knapsackSolution;
 } SendEntry;
@@ -345,14 +345,14 @@
 /**
  * A tsession is a token provided by the transport
  * API to refer to a connection of the transport
- * layer.  
+ * layer.
  */
 typedef struct
 {
   /**
    * To whom are we connected with this session?
    */
-  PeerIdentity sender;
+  GNUNET_PeerIdentity sender;
 
   /**
    * The MTU for this session, 0 for streaming transports.
@@ -380,35 +380,35 @@
   /**
    * the current session key used for encryption
    */
-  SESSIONKEY skey_local;
+  GNUNET_AES_SessionKey skey_local;
 
   /**
    * at which time was the local sessionkey created
    */
-  TIME_T skey_local_created;
+  GNUNET_Int32Time skey_local_created;
 
   /**
    * the current session key used for decryption
    */
-  SESSIONKEY skey_remote;
+  GNUNET_AES_SessionKey skey_remote;
 
   /**
    * at which time was the remote sessionkey created
    */
-  TIME_T skey_remote_created;
+  GNUNET_Int32Time skey_remote_created;
 
   /**
    * is this host alive? timestamp of the time of the last-active
    * point (as witnessed by some higher-level application, typically
    * topology+pingpong)
    */
-  cron_t isAlive;
+  GNUNET_CronTime isAlive;
 
   /**
    * At what time did we initially establish (STAT_UP) this connection?
    * Should be zero if status != STAT_UP.
    */
-  cron_t time_established;
+  GNUNET_CronTime time_established;
 
   /**
    * Status of the connection (STAT_XXX)
@@ -446,10 +446,10 @@
    * time of the last send-attempt (to avoid
    * solving knapsack's too often)
    */
-  cron_t lastSendAttempt;
+  GNUNET_CronTime lastSendAttempt;
 
   /**
-   * a hash collision overflow chain
+   * a GNUNET_hash collision overflow chain
    */
   struct BufferEntry_ *overflowChain;
 
@@ -473,7 +473,7 @@
   /**
    * time of the last increment of available_send_window
    */
-  cron_t last_bps_update;
+  GNUNET_CronTime last_bps_update;
 
   /* *********** inbound bandwidth accounting ******** */
 
@@ -583,7 +583,7 @@
  * Experimental configuration: disable random padding of encrypted
  * messages.
  */
-static int disable_random_padding = NO;
+static int disable_random_padding = GNUNET_NO;
 
 /**
  * Send callbacks for making better use of noise padding...
@@ -594,7 +594,7 @@
 /**
  * Lock for the connection module.
  */
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 /**
  * What is the available downstream bandwidth (in bytes
@@ -617,9 +617,9 @@
 
 static struct GC_Configuration *cfg;
 
-static struct LoadMonitor *load_monitor;
+static struct GNUNET_LoadMonitor *load_monitor;
 
-static struct CronManager *cron;
+static struct GNUNET_CronManager *cron;
 
 
 /**
@@ -667,7 +667,7 @@
   int i;
   BufferEntry *root;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < CONNECTION_MAX_HOSTS_; i++)
     {
       root = CONNECTION_buffer_[i];
@@ -675,13 +675,13 @@
         {
           if (root->session.tsession != NULL)
             GE_ASSERT (NULL,
-                       OK ==
+                       GNUNET_OK ==
                        transport->assertAssociated (root->session.tsession,
                                                     __FILE__));
           root = root->overflowChain;
         }
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 /**
@@ -693,7 +693,7 @@
 {
   BufferEntry *be;
 
-  be = MALLOC (sizeof (BufferEntry));
+  be = GNUNET_malloc (sizeof (BufferEntry));
   memset (be, 0, sizeof (BufferEntry));
   be->isAlive = 0;
   be->status = STAT_DOWN;
@@ -708,8 +708,8 @@
   be->idealized_limit = MIN_BPM_PER_PEER;
   be->max_transmitted_limit = MIN_BPM_PER_PEER;
   be->lastSendAttempt = 0;      /* never */
-  be->inSendBuffer = NO;
-  be->last_bps_update = get_time ();    /* now */
+  be->inSendBuffer = GNUNET_NO;
+  be->last_bps_update = GNUNET_get_time ();     /* now */
   return be;
 }
 
@@ -720,16 +720,16 @@
 void
 updateCurBPS (BufferEntry * be)
 {
-  cron_t now;
-  cron_t delta;
+  GNUNET_CronTime now;
+  GNUNET_CronTime delta;
   long long increment;
   long long limit;
 
-  now = get_time ();
+  now = GNUNET_get_time ();
   if (now <= be->last_bps_update)
     return;
   delta = now - be->last_bps_update;
-  increment = (long long) be->max_bpm * delta / cronMINUTES;
+  increment = (long long) be->max_bpm * delta / GNUNET_CRON_MINUTES;
   if (increment < 100)
     return;                     /* avoid loosing > 1% due to rounding */
   if (stats != NULL)
@@ -802,13 +802,13 @@
     {
       if (entries[i]->len <= left)
         {
-          entries[i]->knapsackSolution = YES;
+          entries[i]->knapsackSolution = GNUNET_YES;
           left -= entries[i]->len;
           max += entries[i]->pri;
         }
       else
         {
-          entries[i]->knapsackSolution = NO;
+          entries[i]->knapsackSolution = GNUNET_NO;
         }
     }
   return max;
@@ -851,7 +851,7 @@
     {
       /* short cut: take everything! */
       for (i = 0; i < count; i++)
-        entries[i]->knapsackSolution = YES;
+        entries[i]->knapsackSolution = GNUNET_YES;
       max = 0;
       for (i = 0; i < count; i++)
         max += entries[i]->pri;
@@ -862,7 +862,7 @@
      to reduce cost to O(count*available/gcd) in terms of
      CPU and memory.  Since gcd is almost always at least
      4, this is probably a good idea (TM)  :-) */
-  efflen = MALLOC (sizeof (int) * count);
+  efflen = GNUNET_malloc (sizeof (int) * count);
   max = available;
   for (i = 0; i < count; i++)
     if (entries[i]->len > 0)
@@ -876,7 +876,7 @@
      VARR(i,j) stores the maximum value of any subset
      of objects {1, ... i} that can fit into a knapsack
      of weight j. */
-  v = MALLOC (sizeof (long long) * (count + 1) * (available + 1));
+  v = GNUNET_malloc (sizeof (long long) * (count + 1) * (available + 1));
   memset (v, 0, sizeof (long long) * (count + 1) * (available + 1));
   for (j = 1; j <= available; j++)
     VARR (0, j) = -1;
@@ -917,7 +917,7 @@
 
   /* reconstruct selection */
   for (i = 0; i < count; i++)
-    entries[i]->knapsackSolution = NO;
+    entries[i]->knapsackSolution = GNUNET_NO;
   for (i = count; i > 0; i--)
     {
       if (j >= efflen[i - 1])
@@ -926,13 +926,13 @@
               VARR (i, j))
             {
               j -= efflen[i - 1];
-              entries[i - 1]->knapsackSolution = YES;
+              entries[i - 1]->knapsackSolution = GNUNET_YES;
             }
         }
     }
   GE_ASSERT (ectx, j == 0);
-  FREE (v);
-  FREE (efflen);
+  GNUNET_free (v);
+  GNUNET_free (efflen);
 
   return max;
 }
@@ -946,7 +946,7 @@
  * @param overhead how much is the header-overhead? 1 for just
  *                 the header, 2 for header is 50%, 3 for header is 33%, etc.
  *                 (the higher the better)
- * @return OK if the packet should be handled, SYSERR if the packet should be 
dropped.
+ * @return GNUNET_OK if the packet should be handled, GNUNET_SYSERR if the 
packet should be dropped.
  */
 static int
 outgoingCheck (unsigned int priority, unsigned int overhead)
@@ -954,17 +954,17 @@
   int load;
   unsigned int delta;
 
-  load = os_network_monitor_get_load (load_monitor, Upload);    /* how much 
free bandwidth do we have? */
+  load = GNUNET_network_monitor_get_load (load_monitor, GNUNET_ND_UPLOAD);     
 /* how much free bandwidth do we have? */
   if (load >= 150)
-    return SYSERR;              /* => always drop */
+    return GNUNET_SYSERR;       /* => always drop */
   if (load > 100)
     {
       if (priority >= EXTREME_PRIORITY)
-        return OK;              /* allow administrative msgs */
-      return SYSERR;            /* but nothing else */
+        return GNUNET_OK;       /* allow administrative msgs */
+      return GNUNET_SYSERR;     /* but nothing else */
     }
   if (load <= 75 + overhead)
-    return OK;
+    return GNUNET_OK;
   delta = load - overhead - 75;
   /* Now delta in [0, 25] */
   if (delta * delta * delta > priority)
@@ -975,7 +975,7 @@
               "Network load is too high (%d%%, priority is %u, require %d), "
               "dropping outgoing.\n", load, priority, delta * delta * delta);
 #endif
-      return SYSERR;            /* drop */
+      return GNUNET_SYSERR;     /* drop */
     }
   else
     {
@@ -985,7 +985,7 @@
               "Network load is ok (%d%%, priority is %u >= %d), "
               "sending outgoing.\n", load, priority, delta * delta * delta);
 #endif
-      return OK;                /* allow */
+      return GNUNET_OK;         /* allow */
     }
 }
 
@@ -993,18 +993,18 @@
  * Check that the send frequency for this
  * buffer is not too high.
  *
- * @return OK if sending a message now is acceptable
+ * @return GNUNET_OK if sending a message now is acceptable
  */
 static int
 checkSendFrequency (BufferEntry * be)
 {
-  cron_t msf;
+  GNUNET_CronTime msf;
   int load;
   unsigned int i;
 
   for (i = 0; i < be->sendBufferSize; i++)
     if (be->sendBuffer[i]->pri >= EXTREME_PRIORITY)
-      return OK;
+      return GNUNET_OK;
 
   if (be->max_bpm == 0)
     be->max_bpm = 1;
@@ -1012,19 +1012,19 @@
   if (be->session.mtu == 0)
     {
       msf =                     /* ms per message */
-        EXPECTED_MTU / (be->max_bpm * cronMINUTES / cronMILLIS);        /* 
bytes per ms */
+        EXPECTED_MTU / (be->max_bpm * GNUNET_CRON_MINUTES / 
GNUNET_CRON_MILLISECONDS);  /* bytes per ms */
     }
   else
     {
       msf =                     /* ms per message */
         be->session.mtu         /* byte per message */
-        / (be->max_bpm * cronMINUTES / cronMILLIS);     /* bytes per ms */
+        / (be->max_bpm * GNUNET_CRON_MINUTES / GNUNET_CRON_MILLISECONDS);      
 /* bytes per ms */
     }
   /* Also: allow at least 2 * MINIMUM_SAMPLE_COUNT knapsack
      solutions for any MIN_SAMPLE_TIME! */
   if (msf > 2 * MIN_SAMPLE_TIME / MINIMUM_SAMPLE_COUNT)
     msf = 2 * MIN_SAMPLE_TIME / MINIMUM_SAMPLE_COUNT;
-  load = os_cpu_get_load (ectx, cfg);
+  load = GNUNET_cpu_get_load (ectx, cfg);
   if (load == -1)
     load = 50;
   /* adjust frequency based on send buffer size */
@@ -1037,16 +1037,16 @@
      than i%, decrease frequency, otherwise
      increase it (quadratically)! */
   msf = msf * load * load / i / i;
-  if (be->lastSendAttempt + msf > get_time ())
+  if (be->lastSendAttempt + msf > GNUNET_get_time ())
     {
 #if DEBUG_CONNECTION
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
               "Send frequency too high (CPU load), send deferred.\n");
 #endif
-      return NO;                /* frequency too high, wait */
+      return GNUNET_NO;         /* frequency too high, wait */
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -1064,28 +1064,28 @@
   int i;
   int j;
   int approxProb;
-  cron_t deadline;
+  GNUNET_CronTime deadline;
 
   totalMessageSize = 0;
   (*priority) = 0;
 
   for (i = be->sendBufferSize - 1; i >= 0; i--)
-    be->sendBuffer[i]->knapsackSolution = NO;
+    be->sendBuffer[i]->knapsackSolution = GNUNET_NO;
 
   if (be->session.mtu == 0)
     {
       totalMessageSize = sizeof (P2P_PACKET_HEADER);
-      deadline = (cron_t) - 1L; /* infinity */
+      deadline = (GNUNET_CronTime) - 1L;        /* infinity */
 
       i = 0;
       /* assumes entries are sorted by priority! */
       while (i < be->sendBufferSize)
         {
           entry = be->sendBuffer[i];
-          if ((totalMessageSize + entry->len < MAX_BUFFER_SIZE - 64) &&
+          if ((totalMessageSize + entry->len < GNUNET_MAX_BUFFER_SIZE - 64) &&
               (entry->pri >= EXTREME_PRIORITY))
             {
-              entry->knapsackSolution = YES;
+              entry->knapsackSolution = GNUNET_YES;
               if (entry->transmissionTime < deadline)
                 deadline = entry->transmissionTime;
               (*priority) += entry->pri;
@@ -1093,7 +1093,7 @@
             }
           else
             {
-              entry->knapsackSolution = NO;
+              entry->knapsackSolution = GNUNET_NO;
               break;
             }
           i++;
@@ -1109,9 +1109,9 @@
         {
           entry = be->sendBuffer[i];
           if ((entry->len + totalMessageSize <= be->available_send_window) &&
-              (totalMessageSize + entry->len < MAX_BUFFER_SIZE - 64))
+              (totalMessageSize + entry->len < GNUNET_MAX_BUFFER_SIZE - 64))
             {
-              entry->knapsackSolution = YES;
+              entry->knapsackSolution = GNUNET_YES;
               if (entry->transmissionTime < deadline)
                 deadline = entry->transmissionTime;
               totalMessageSize += entry->len;
@@ -1119,7 +1119,7 @@
             }
           else
             {
-              entry->knapsackSolution = NO;
+              entry->knapsackSolution = GNUNET_NO;
               if (totalMessageSize == sizeof (P2P_PACKET_HEADER))
                 {
                   /* if the highest-priority message does not yet
@@ -1134,8 +1134,8 @@
       if ((totalMessageSize == sizeof (P2P_PACKET_HEADER)) ||
           (((*priority) < EXTREME_PRIORITY) &&
            ((totalMessageSize / sizeof (P2P_PACKET_HEADER)) < 4) &&
-           (deadline > get_time () + 500 * cronMILLIS) &&
-           (weak_randomi (16) != 0)))
+           (deadline > GNUNET_get_time () + 500 * GNUNET_CRON_MILLISECONDS) &&
+           (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 16) != 0)))
         {
           /* randomization necessary to ensure we eventually send
              a small message if there is nothing else to do! */
@@ -1145,7 +1145,7 @@
   else
     {                           /* if (be->session.mtu == 0) */
       /* solve knapsack problem, compute accumulated priority */
-      approxProb = os_cpu_get_load (ectx, cfg);
+      approxProb = GNUNET_cpu_get_load (ectx, cfg);
       if (approxProb < 0)
         approxProb = 50;        /* failed to determine load, assume 50% */
       if (approxProb > 50)
@@ -1155,13 +1155,15 @@
           approxProb = 100 - approxProb;        /* now value between 0 and 50 
*/
           approxProb *= 2;      /* now value between 0 [always approx] and 100 
[never approx] */
           /* control CPU load probabilistically! */
-          if (weak_randomi (1 + approxProb) == 0)
+          if (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 1 + approxProb)
+              == 0)
             {
               (*priority) = approximateKnapsack (be,
                                                  be->session.mtu -
                                                  sizeof (P2P_PACKET_HEADER));
 #if DEBUG_COLLECT_PRIO == YES
-              FPRINTF (prioFile, "%llu 0 %d\n", get_time (), priority);
+              FPRINTF (prioFile, "%llu 0 %u\n", GNUNET_get_time (),
+                       *priority);
 #endif
             }
           else
@@ -1170,7 +1172,8 @@
                                            be->session.mtu -
                                            sizeof (P2P_PACKET_HEADER));
 #if DEBUG_COLLECT_PRIO == YES
-              FPRINTF (prioFile, "%llu 1 %d\n", get_time (), priority);
+              FPRINTF (prioFile, "%llu 1 %u\n", GNUNET_get_time (),
+                       *priority);
 #endif
             }
         }
@@ -1180,14 +1183,14 @@
                                        be->session.mtu -
                                        sizeof (P2P_PACKET_HEADER));
 #if DEBUG_COLLECT_PRIO == YES
-          FPRINTF (prioFile, "%llu 2 %d\n", get_time (), priority);
+          FPRINTF (prioFile, "%llu 2 %u\n", GNUNET_get_time (), *priority);
 #endif
         }
       j = 0;
       totalMessageSize = 0;
       for (i = 0; i < be->sendBufferSize; i++)
         {
-          if (be->sendBuffer[i]->knapsackSolution == YES)
+          if (be->sendBuffer[i]->knapsackSolution == GNUNET_YES)
             {
               totalMessageSize += be->sendBuffer[i]->len;
               j++;
@@ -1245,15 +1248,15 @@
   unsigned long long msgCap;
   int i;
   SendEntry *entry;
-  cron_t expired;
+  GNUNET_CronTime expired;
   int load;
   unsigned long long usedBytes;
   int j;
 
   /* if it's more than one connection "lifetime" old, always kill it! */
-  be->lastSendAttempt = get_time ();
-  expired = be->lastSendAttempt - SECONDS_PINGATTEMPT * cronSECONDS;
-  load = os_cpu_get_load (ectx, cfg);
+  be->lastSendAttempt = GNUNET_get_time ();
+  expired = be->lastSendAttempt - SECONDS_PINGATTEMPT * GNUNET_CRON_SECONDS;
+  load = GNUNET_cpu_get_load (ectx, cfg);
   if (load < 0)
     load = 50;                  /* failed to determine load, assume 50% */
   /* cleanup queue: keep enough buffer for one minute */
@@ -1262,7 +1265,7 @@
     msgCap = EXPECTED_MTU;      /* have at least one MTU */
   if (msgCap > max_bpm_up)
     msgCap = max_bpm_up;        /* have no more than max-bpm for entire daemon 
*/
-  if (load < IDLE_LOAD_THRESHOLD)
+  if (load < GNUNET_IDLE_LOAD_THRESHOLD)
     {                           /* afford more if CPU load is low */
       if (load == 0)
         load = 1;               /* avoid division by zero */
@@ -1283,16 +1286,17 @@
           GE_LOG (ectx,
                   GE_DEBUG | GE_REQUEST | GE_USER,
                   "expiring message, expired %ds ago, queue size is %llu 
(bandwidth stressed)\n",
-                  (int) ((get_time () -
-                          entry->transmissionTime) / cronSECONDS), usedBytes);
+                  (int) ((GNUNET_get_time () -
+                          entry->transmissionTime) / GNUNET_CRON_SECONDS),
+                  usedBytes);
 #endif
           if (stats != NULL)
             {
               stats->change (stat_messagesDropped, 1);
               stats->change (stat_sizeMessagesDropped, entry->len);
             }
-          FREENONNULL (entry->closure);
-          FREE (entry);
+          GNUNET_free_non_null (entry->closure);
+          GNUNET_free (entry);
           be->sendBuffer[i] = NULL;
         }
       else
@@ -1304,7 +1308,7 @@
   for (i = 0; i < be->sendBufferSize; i++)
     if (be->sendBuffer[i] != NULL)
       be->sendBuffer[j++] = be->sendBuffer[i];
-  GROW (be->sendBuffer, be->sendBufferSize, j);
+  GNUNET_array_grow (be->sendBuffer, be->sendBufferSize, j);
 }
 
 /**
@@ -1331,12 +1335,13 @@
     {
       entry = be->sendBuffer[i];
 
-      if (entry->knapsackSolution == YES)
+      if (entry->knapsackSolution == GNUNET_YES)
         {
           if (entry->callback != NULL)
             {
-              tmpMsg = MALLOC (entry->len);
-              if (OK == entry->callback (tmpMsg, entry->closure, entry->len))
+              tmpMsg = GNUNET_malloc (entry->len);
+              if (GNUNET_OK ==
+                  entry->callback (tmpMsg, entry->closure, entry->len))
                 {
                   entry->callback = NULL;
                   entry->closure = tmpMsg;
@@ -1344,10 +1349,10 @@
                 }
               else
                 {
-                  FREE (tmpMsg);
+                  GNUNET_free (tmpMsg);
                   entry->callback = NULL;
                   entry->closure = NULL;
-                  FREE (entry);
+                  GNUNET_free (entry);
                   be->sendBuffer[i] = NULL;
                 }
             }
@@ -1357,15 +1362,15 @@
             }
 #if 0
           {
-            MESSAGE_HEADER *hdr;
-            EncName enc;
+            GNUNET_MessageHeader *hdr;
+            GNUNET_EncName enc;
 
-            hdr = (MESSAGE_HEADER *) entry->closure;
+            hdr = (GNUNET_MessageHeader *) entry->closure;
             IF_GELOG (ectx,
                       GE_DEBUG | GE_REQUEST | GE_USER,
-                      hash2enc (&be->session.sender.hashPubKey, &enc));
-            GE_LOG (ectx,
-                    GE_DEBUG | GE_REQUEST | GE_USER,
+                      GNUNET_hash_to_enc (&be->session.sender.hashPubKey,
+                                          &enc));
+            GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
                     "Core selected message of type %u and size %u for sending 
to peer `%s'.\n",
                     ntohs (hdr->type), ntohs (hdr->size), &enc);
           }
@@ -1402,24 +1407,24 @@
     {
       if (be->sendBuffer[i] == NULL)
         continue;
-      if (be->sendBuffer[i]->knapsackSolution == YES)
+      if (be->sendBuffer[i]->knapsackSolution == GNUNET_YES)
         stotal++;
     }
   *selected_total = stotal;
   if (stotal == 0)
     return NULL;
-  ret = MALLOC (stotal * sizeof (SendEntry *));
+  ret = GNUNET_malloc (stotal * sizeof (SendEntry *));
   j = 0;
   for (i = 0; i < be->sendBufferSize; i++)
     {
       if (be->sendBuffer[i] == NULL)
         continue;
-      if (be->sendBuffer[i]->knapsackSolution == YES)
+      if (be->sendBuffer[i]->knapsackSolution == GNUNET_YES)
         ret[j++] = be->sendBuffer[i];
     }
   for (j = 0; j < stotal; j++)
     {
-      rnd = weak_randomi (stotal);
+      rnd = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, stotal);
       tmp = ret[j];
       ret[j] = ret[rnd];
       ret[rnd] = tmp;
@@ -1465,16 +1470,16 @@
     {
       entry = be->sendBuffer[i];
       GE_ASSERT (ectx, entry != NULL);
-      if (entry->knapsackSolution == YES)
+      if (entry->knapsackSolution == GNUNET_YES)
         {
           GE_ASSERT (ectx, entry->callback == NULL);
-          FREENONNULL (entry->closure);
-          FREE (entry);
+          GNUNET_free_non_null (entry->closure);
+          GNUNET_free (entry);
           be->sendBuffer[i] = NULL;
         }
       else if ((entry->callback == NULL) && (entry->closure == NULL))
         {
-          FREE (entry);
+          GNUNET_free (entry);
           be->sendBuffer[i] = NULL;
         }
     }
@@ -1499,10 +1504,10 @@
     return;                     /* clearly not necessary */
 
   /* MTU change may require new fragmentation! */
-  changed = YES;
+  changed = GNUNET_YES;
   while (changed)
     {
-      changed = NO;
+      changed = GNUNET_NO;
       entries = be->sendBuffer;
       ret = be->sendBufferSize;
       for (i = 0; i < ret; i++)
@@ -1513,17 +1518,17 @@
           ret--;
           for (j = i; j < ret; j++)
             entries[j] = entries[j + 1];        /* preserve ordering */
-          GROW (be->sendBuffer, be->sendBufferSize, ret);
+          GNUNET_array_grow (be->sendBuffer, be->sendBufferSize, ret);
           /* calling fragment will change be->sendBuffer;
              thus we need to restart from the beginning afterwards... */
-          be->consider_transport_switch = YES;
+          be->consider_transport_switch = GNUNET_YES;
           fragmentation->fragment (&be->session.sender,
                                    be->session.mtu -
                                    sizeof (P2P_PACKET_HEADER), entry->pri,
                                    entry->transmissionTime, entry->len,
                                    entry->callback, entry->closure);
-          FREE (entry);
-          changed = YES;
+          GNUNET_free (entry);
+          changed = GNUNET_YES;
           break;                /* "entries" changed as side-effect of 
fragment call */
         }
     }                           /* while changed */
@@ -1535,24 +1540,24 @@
  * ensures that the pending messages are properly fragmented (if
  * needed).
  *
- * @return OK on success, NO on error
+ * @return GNUNET_OK on success, GNUNET_NO on error
  */
 static int
 ensureTransportConnected (BufferEntry * be)
 {
   if (be->session.tsession != NULL)
-    return OK;
+    return GNUNET_OK;
   be->session.tsession =
-    transport->connectFreely (&be->session.sender, NO, __FILE__);
+    transport->connectFreely (&be->session.sender, GNUNET_NO, __FILE__);
   if (be->session.tsession == NULL)
     {
       be->status = STAT_DOWN;
       be->time_established = 0;
-      return NO;
+      return GNUNET_NO;
     }
   be->session.mtu = transport->getMTU (be->session.tsession->ttype);
   fragmentIfNecessary (be);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -1563,7 +1568,7 @@
  * message to the transport service.
  *
  * @param be connection of the buffer that is to be transmitted
- * @return YES if we might want to be re-run
+ * @return GNUNET_YES if we might want to be re-run
  */
 static int
 sendBuffer (BufferEntry * be)
@@ -1588,19 +1593,19 @@
   if (be == NULL)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if ((be->status != STAT_UP) ||
-      (be->sendBufferSize == 0) || (be->inSendBuffer == YES))
+      (be->sendBufferSize == 0) || (be->inSendBuffer == GNUNET_YES))
     {
-      return NO;                /* must not run */
+      return GNUNET_NO;         /* must not run */
     }
-  be->inSendBuffer = YES;
-  if ((OK != ensureTransportConnected (be)) ||
-      (OK != checkSendFrequency (be)))
+  be->inSendBuffer = GNUNET_YES;
+  if ((GNUNET_OK != ensureTransportConnected (be)) ||
+      (GNUNET_OK != checkSendFrequency (be)))
     {
-      be->inSendBuffer = NO;
-      return NO;
+      be->inSendBuffer = GNUNET_NO;
+      return GNUNET_NO;
     }
 
   /* test if receiver has enough bandwidth available!  */
@@ -1611,8 +1616,8 @@
                                    2 * EXPECTED_MTU)))
     {
       expireSendBufferEntries (be);
-      be->inSendBuffer = NO;
-      return NO;                /* deferr further */
+      be->inSendBuffer = GNUNET_NO;
+      return GNUNET_NO;         /* deferr further */
     }
   if (totalMessageSize == 0)
     totalMessageSize = EXPECTED_MTU + sizeof (P2P_PACKET_HEADER);
@@ -1620,15 +1625,16 @@
   if ((be->session.mtu != 0) && (totalMessageSize > be->session.mtu))
     {
       GE_BREAK (ectx, 0);
-      be->inSendBuffer = NO;
-      return NO;
+      be->inSendBuffer = GNUNET_NO;
+      return GNUNET_NO;
     }
   ret = transport->testWouldTry (be->session.tsession,
                                  totalMessageSize,
-                                 (priority >= EXTREME_PRIORITY) ? YES : NO);
-  /* ret: YES: ok to send, NO: not ready yet, SYSERR: session down
+                                 (priority >=
+                                  EXTREME_PRIORITY) ? GNUNET_YES : GNUNET_NO);
+  /* ret: GNUNET_YES: ok to send, GNUNET_NO: not ready yet, GNUNET_SYSERR: 
session down
      or serious internal error */
-  if (ret == SYSERR)
+  if (ret == GNUNET_SYSERR)
     {
       /* transport session is gone! re-establish! */
       tsession = be->session.tsession;
@@ -1639,12 +1645,12 @@
       if (be->session.tsession == NULL)
         {
 #if DEBUG_CONNECTION
-          EncName enc;
+          GNUNET_EncName enc;
           IF_GELOG (ectx,
                     GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
-                    hash2enc (&be->session.sender.hashPubKey, &enc));
-          GE_LOG (ectx,
-                  GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+                    GNUNET_hash_to_enc (&be->session.sender.hashPubKey,
+                                        &enc));
+          GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
                   "Session is DOWN for `%s' due to transport disconnect\n",
                   &enc);
 #endif
@@ -1656,10 +1662,10 @@
             stats->change (stat_closedTransport, 1);
           for (i = 0; i < be->sendBufferSize; i++)
             {
-              FREENONNULL (be->sendBuffer[i]->closure);
-              FREE (be->sendBuffer[i]);
+              GNUNET_free_non_null (be->sendBuffer[i]->closure);
+              GNUNET_free (be->sendBuffer[i]);
             }
-          GROW (be->sendBuffer, be->sendBufferSize, 0);
+          GNUNET_array_grow (be->sendBuffer, be->sendBufferSize, 0);
         }
       /* This may have changed the MTU => need to re-do
          everything.  Since we don't want to possibly
@@ -1667,23 +1673,24 @@
          so even if "ensureTransportConnected" succeded,
          abort for now! */
     }
-  if (YES != ret)
+  if (GNUNET_YES != ret)
     {
       /* transport's buffer full -- no point in
          creating the actual message! */
       expireSendBufferEntries (be);
-      be->inSendBuffer = NO;
-      return NO;
+      be->inSendBuffer = GNUNET_NO;
+      return GNUNET_NO;
     }
   /* check if we (sender) have enough bandwidth available
      if so, trigger callbacks on selected entries; if either
      fails, return (but clean up garbage) */
-  if (SYSERR == outgoingCheck (priority,
-                               totalMessageSize / sizeof (P2P_PACKET_HEADER)))
+  if (GNUNET_SYSERR == outgoingCheck (priority,
+                                      totalMessageSize /
+                                      sizeof (P2P_PACKET_HEADER)))
     {
       expireSendBufferEntries (be);
-      be->inSendBuffer = NO;
-      return NO;                /* deferr further */
+      be->inSendBuffer = GNUNET_NO;
+      return GNUNET_NO;         /* deferr further */
     }
 
   /* get permutation of SendBuffer Entries
@@ -1695,9 +1702,9 @@
         {
           /* no messages selected!? */
           GE_BREAK (ectx, 0);
-          be->inSendBuffer = NO;
-          FREE (entries);
-          return NO;
+          be->inSendBuffer = GNUNET_NO;
+          GNUNET_free (entries);
+          return GNUNET_NO;
         }
     }
   else
@@ -1707,9 +1714,9 @@
     }
 
   /* build message */
-  plaintextMsg = MALLOC (totalMessageSize);
+  plaintextMsg = GNUNET_malloc (totalMessageSize);
   p2pHdr = (P2P_PACKET_HEADER *) plaintextMsg;
-  p2pHdr->timeStamp = htonl (TIME (NULL));
+  p2pHdr->timeStamp = htonl (GNUNET_get_time_int32 (NULL));
   p2pHdr->sequenceNumber = htonl (be->lastSequenceNumberSend);
   p2pHdr->bandwidth = htonl (be->idealized_limit);
   p = sizeof (P2P_PACKET_HEADER);
@@ -1719,20 +1726,20 @@
 
       GE_ASSERT (ectx,
                  (entry != NULL) &&
-                 (entry->knapsackSolution == YES) &&
+                 (entry->knapsackSolution == GNUNET_YES) &&
                  (entry->callback == NULL) &&
                  (p + entry->len <= totalMessageSize));
       memcpy (&plaintextMsg[p], entry->closure, entry->len);
       p += entry->len;
     }
-  FREENONNULL (entries);
+  GNUNET_free_non_null (entries);
   entries = NULL;
   if (p > totalMessageSize)
     {
       GE_BREAK (ectx, 0);
-      FREE (plaintextMsg);
-      be->inSendBuffer = NO;
-      return NO;
+      GNUNET_free (plaintextMsg);
+      be->inSendBuffer = GNUNET_NO;
+      return GNUNET_NO;
     }
   /* still room left? try callbacks! */
   pos = scl_nextHead;
@@ -1747,9 +1754,9 @@
           if ((rsi + p < p) || (rsi + p > totalMessageSize))
             {
               GE_BREAK (ectx, 0);
-              FREE (plaintextMsg);
-              be->inSendBuffer = NO;
-              return NO;
+              GNUNET_free (plaintextMsg);
+              be->inSendBuffer = GNUNET_NO;
+              return GNUNET_NO;
             }
           p += rsi;
         }
@@ -1759,22 +1766,23 @@
        (p > be->session.mtu)) || (p > totalMessageSize))
     {
       GE_BREAK (ectx, 0);
-      FREE (plaintextMsg);
-      be->inSendBuffer = NO;
-      return NO;
+      GNUNET_free (plaintextMsg);
+      be->inSendBuffer = GNUNET_NO;
+      return GNUNET_NO;
     }
   /* finally padd with noise */
-  if ((p + sizeof (MESSAGE_HEADER) <= totalMessageSize) &&
+  if ((p + sizeof (GNUNET_MessageHeader) <= totalMessageSize) &&
       (p < totalMessageSize) &&
-      (p + sizeof (MESSAGE_HEADER) > p) && (disable_random_padding == NO))
+      (p + sizeof (GNUNET_MessageHeader) > p)
+      && (disable_random_padding == GNUNET_NO))
     {
-      MESSAGE_HEADER part;
+      GNUNET_MessageHeader part;
       unsigned short noiseLen = totalMessageSize - p;
 
       part.size = htons (noiseLen);
       part.type = htons (P2P_PROTO_noise);
-      memcpy (&plaintextMsg[p], &part, sizeof (MESSAGE_HEADER));
-      for (i = p + sizeof (MESSAGE_HEADER); i < totalMessageSize; i++)
+      memcpy (&plaintextMsg[p], &part, sizeof (GNUNET_MessageHeader));
+      for (i = p + sizeof (GNUNET_MessageHeader); i < totalMessageSize; i++)
         plaintextMsg[i] = (char) rand ();
       p = totalMessageSize;
       if (stats != NULL)
@@ -1784,25 +1792,28 @@
        (p > be->session.mtu)) || (p > totalMessageSize))
     {
       GE_BREAK (ectx, 0);
-      FREE (plaintextMsg);
-      be->inSendBuffer = NO;
-      return NO;
+      GNUNET_free (plaintextMsg);
+      be->inSendBuffer = GNUNET_NO;
+      return GNUNET_NO;
     }
 
-  encryptedMsg = MALLOC (p);
-  hash (&p2pHdr->sequenceNumber,
-        p - sizeof (HashCode512), (HashCode512 *) encryptedMsg);
-  ret = encryptBlock (&p2pHdr->sequenceNumber, p - sizeof (HashCode512), 
&be->skey_local, (const INITVECTOR *) encryptedMsg,    /* IV */
-                      &((P2P_PACKET_HEADER *) encryptedMsg)->sequenceNumber);
+  encryptedMsg = GNUNET_malloc (p);
+  GNUNET_hash (&p2pHdr->sequenceNumber,
+               p - sizeof (GNUNET_HashCode),
+               (GNUNET_HashCode *) encryptedMsg);
+  ret = GNUNET_AES_encrypt (&p2pHdr->sequenceNumber, p - sizeof 
(GNUNET_HashCode), &be->skey_local, (const GNUNET_AES_InitializationVector *) 
encryptedMsg,     /* IV */
+                            &((P2P_PACKET_HEADER *) encryptedMsg)->
+                            sequenceNumber);
   if (stats != NULL)
-    stats->change (stat_encrypted, p - sizeof (HashCode512));
+    stats->change (stat_encrypted, p - sizeof (GNUNET_HashCode));
   GE_ASSERT (ectx, be->session.tsession != NULL);
-  ret = transport->send (be->session.tsession, encryptedMsg, p, NO);
-  if ((ret == NO) && (priority >= EXTREME_PRIORITY))
+  ret = transport->send (be->session.tsession, encryptedMsg, p, GNUNET_NO);
+  if ((ret == GNUNET_NO) && (priority >= EXTREME_PRIORITY))
     {
-      ret = transport->send (be->session.tsession, encryptedMsg, p, YES);
+      ret =
+        transport->send (be->session.tsession, encryptedMsg, p, GNUNET_YES);
     }
-  if (ret == YES)
+  if (ret == GNUNET_YES)
     {
       if (stats != NULL)
         stats->change (stat_transmitted, p);
@@ -1819,9 +1830,10 @@
           j = sizeof (P2P_PACKET_HEADER);
           while (j < p)
             {
-              MESSAGE_HEADER *part = (MESSAGE_HEADER *) & plaintextMsg[j];
+              GNUNET_MessageHeader *part =
+                (GNUNET_MessageHeader *) & plaintextMsg[j];
               unsigned short plen = ntohs (MAKE_UNALIGNED (part->size));
-              if (plen < sizeof (MESSAGE_HEADER))
+              if (plen < sizeof (GNUNET_MessageHeader))
                 {
                   GE_BREAK (ectx, 0);
                   break;
@@ -1833,13 +1845,13 @@
         }
       freeSelectedEntries (be);
     }
-  if ((ret == SYSERR) && (be->session.tsession != NULL))
+  if ((ret == GNUNET_SYSERR) && (be->session.tsession != NULL))
     {
 #if DEBUG_CONNECTION
-      EncName enc;
+      GNUNET_EncName enc;
       IF_GELOG (ectx,
                 GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
-                hash2enc (&be->session.sender.hashPubKey, &enc));
+                GNUNET_hash_to_enc (&be->session.sender.hashPubKey, &enc));
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
               "Session is DOWN for `%s' due to transmission error\n", &enc);
@@ -1855,17 +1867,17 @@
       transport->disconnect (tsession, __FILE__);
       for (i = 0; i < be->sendBufferSize; i++)
         {
-          FREENONNULL (be->sendBuffer[i]->closure);
-          FREE (be->sendBuffer[i]);
+          GNUNET_free_non_null (be->sendBuffer[i]->closure);
+          GNUNET_free (be->sendBuffer[i]);
         }
-      GROW (be->sendBuffer, be->sendBufferSize, 0);
+      GNUNET_array_grow (be->sendBuffer, be->sendBufferSize, 0);
     }
 
-  FREE (encryptedMsg);
-  FREE (plaintextMsg);
+  GNUNET_free (encryptedMsg);
+  GNUNET_free (plaintextMsg);
   expireSendBufferEntries (be);
-  be->inSendBuffer = NO;
-  return NO;
+  be->inSendBuffer = GNUNET_NO;
+  return GNUNET_NO;
 }
 
 /**
@@ -1879,7 +1891,7 @@
 appendToBuffer (BufferEntry * be, SendEntry * se)
 {
 #if DEBUG_CONNECTION
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
   float apri;
   unsigned int i;
@@ -1890,20 +1902,20 @@
   if ((se == NULL) || (se->len == 0))
     {
       GE_BREAK (ectx, 0);
-      FREENONNULL (se);
+      GNUNET_free_non_null (se);
       return;
     }
   if ((be->session.mtu != 0) &&
       (se->len > be->session.mtu - sizeof (P2P_PACKET_HEADER)))
     {
-      be->consider_transport_switch = YES;
+      be->consider_transport_switch = GNUNET_YES;
       /* this message is so big that it must be fragmented! */
       fragmentation->fragment (&be->session.sender,
                                be->session.mtu - sizeof (P2P_PACKET_HEADER),
                                se->pri,
                                se->transmissionTime,
                                se->len, se->callback, se->closure);
-      FREE (se);
+      GNUNET_free (se);
       return;
     }
 
@@ -1914,13 +1926,13 @@
 #if DEBUG_CONNECTION
       IF_GELOG (ectx,
                 GE_DEBUG | GE_REQUEST | GE_USER,
-                hash2enc (&be->session.sender.hashPubKey, &enc));
+                GNUNET_hash_to_enc (&be->session.sender.hashPubKey, &enc));
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
               "not connected to `%s', message dropped\n", &enc);
 #endif
-      FREE (se->closure);
-      FREE (se);
+      GNUNET_free (se->closure);
+      GNUNET_free (se);
       return;
     }
   queueSize = 0;
@@ -1941,13 +1953,13 @@
         {
           /* we need to enforce some hard limit here, otherwise we may take
              FAR too much memory (200 MB easily) */
-          FREE (se->closure);
-          FREE (se);
+          GNUNET_free (se->closure);
+          GNUNET_free (se);
           return;
         }
     }
   /* grow send buffer, insertion sort! */
-  ne = MALLOC ((be->sendBufferSize + 1) * sizeof (SendEntry *));
+  ne = GNUNET_malloc ((be->sendBufferSize + 1) * sizeof (SendEntry *));
   GE_ASSERT (ectx, se->len != 0);
   apri = (float) se->pri / (float) se->len;
   i = 0;
@@ -1964,7 +1976,7 @@
       ne[i] = be->sendBuffer[i - 1];
       i++;
     }
-  FREENONNULL (be->sendBuffer);
+  GNUNET_free_non_null (be->sendBuffer);
   be->sendBuffer = ne;
   be->sendBufferSize++;
   sendBuffer (be);
@@ -1978,15 +1990,16 @@
  * @return the connection of the host in the table, NULL if not connected
  */
 static BufferEntry *
-lookForHost (const PeerIdentity * hostId)
+lookForHost (const GNUNET_PeerIdentity * hostId)
 {
   BufferEntry *root;
 
   root = CONNECTION_buffer_[computeIndex (hostId)];
   while (root != NULL)
     {
-      if (equalsHashCode512 (&hostId->hashPubKey,
-                             &root->session.sender.hashPubKey))
+      if (0 == memcmp (&hostId->hashPubKey,
+                       &root->session.sender.hashPubKey,
+                       sizeof (GNUNET_HashCode)))
         return root;
       root = root->overflowChain;
     }
@@ -2005,7 +2018,7 @@
  * @return the table entry for the host
  */
 static BufferEntry *
-addHost (const PeerIdentity * hostId, int establishSession)
+addHost (const GNUNET_PeerIdentity * hostId, int establishSession)
 {
   BufferEntry *root;
   BufferEntry *prev;
@@ -2022,8 +2035,9 @@
         {
           /* settle for entry in the linked list that is down */
           if ((root->status == STAT_DOWN) ||
-              (equalsHashCode512 (&hostId->hashPubKey,
-                                  &root->session.sender.hashPubKey)))
+              (0 == memcmp (&hostId->hashPubKey,
+                            &root->session.sender.hashPubKey,
+                            sizeof (GNUNET_HashCode))))
             break;
           prev = root;
           root = root->overflowChain;
@@ -2038,7 +2052,7 @@
         }
       root->session.sender = *hostId;
     }
-  if ((root->status == STAT_DOWN) && (establishSession == YES))
+  if ((root->status == STAT_DOWN) && (establishSession == GNUNET_YES))
     {
       root->lastSequenceNumberReceived = 0;
       session->tryConnect (hostId);
@@ -2110,14 +2124,14 @@
   unsigned int i;
   TSession *tsession;
 #if DEBUG_CONNECTION
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   ENTRY ();
 #if DEBUG_CONNECTION
   IF_GELOG (ectx,
             GE_DEBUG | GE_REQUEST | GE_USER,
-            hash2enc (&be->session.sender.hashPubKey, &enc));
+            GNUNET_hash_to_enc (&be->session.sender.hashPubKey, &enc));
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Shutting down connection with `%s'\n", &enc);
@@ -2128,10 +2142,10 @@
     {
       SendEntry *se;
 #if DEBUG_CONNECTION
-      EncName enc;
+      GNUNET_EncName enc;
       IF_GELOG (ectx,
                 GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
-                hash2enc (&be->session.sender.hashPubKey, &enc));
+                GNUNET_hash_to_enc (&be->session.sender.hashPubKey, &enc));
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
               "Session DOWN for `%s' due to HANGUP received\n", &enc);
@@ -2140,14 +2154,14 @@
       hangup.header.size = htons (sizeof (P2P_hangup_MESSAGE));
       identity->getPeerIdentity (identity->getPublicPrivateKey (),
                                  &hangup.sender);
-      se = MALLOC (sizeof (SendEntry));
+      se = GNUNET_malloc (sizeof (SendEntry));
       se->len = sizeof (P2P_hangup_MESSAGE);
       se->flags = SE_FLAG_PLACE_TAIL;
       se->pri = EXTREME_PRIORITY;
-      se->transmissionTime = get_time ();       /* now */
+      se->transmissionTime = GNUNET_get_time ();        /* now */
       se->callback = NULL;
-      se->closure = MALLOC (sizeof (P2P_hangup_MESSAGE));
-      se->knapsackSolution = NO;
+      se->closure = GNUNET_malloc (sizeof (P2P_hangup_MESSAGE));
+      se->knapsackSolution = GNUNET_NO;
       memcpy (se->closure, &hangup, sizeof (P2P_hangup_MESSAGE));
       appendToBuffer (be, se);
       if (stats != NULL)
@@ -2171,10 +2185,10 @@
     }
   for (i = 0; i < be->sendBufferSize; i++)
     {
-      FREENONNULL (be->sendBuffer[i]->closure);
-      FREE (be->sendBuffer[i]);
+      GNUNET_free_non_null (be->sendBuffer[i]->closure);
+      GNUNET_free (be->sendBuffer[i]);
     }
-  GROW (be->sendBuffer, be->sendBufferSize, 0);
+  GNUNET_array_grow (be->sendBuffer, be->sendBufferSize, 0);
 }
 
 /* ******** inbound bandwidth scheduling ************* */
@@ -2228,10 +2242,10 @@
 scheduleInboundTraffic ()
 {
   unsigned int activePeerCount;
-  static cron_t lastRoundStart = 0;
+  static GNUNET_CronTime lastRoundStart = 0;
   UTL_Closure utl;
-  static cron_t timeDifference;
-  cron_t now;
+  static GNUNET_CronTime timeDifference;
+  GNUNET_CronTime now;
   BufferEntry **entries;
   double *shares;
   double shareSum;
@@ -2245,15 +2259,15 @@
   int firstRound;
   int earlyRun;
   int load;
-  int *perm;
-  cron_t min_uptime;
+  unsigned int *perm;
+  GNUNET_CronTime min_uptime;
   unsigned int min_uptime_slot;
 #if DEBUG_CONNECTION
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
-  MUTEX_LOCK (lock);
-  now = get_time ();
+  GNUNET_mutex_lock (lock);
+  now = GNUNET_get_time ();
 
   /* if this is the first round, don't bother... */
   if (lastRoundStart == 0)
@@ -2261,13 +2275,13 @@
       /* no allocation the first time this function is called! */
       lastRoundStart = now;
       forAllConnectedHosts (&resetRecentlyReceived, NULL);
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       return;
     }
   activePeerCount = forAllConnectedHosts (NULL, NULL);
   if (activePeerCount == 0)
     {
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       return;                   /* nothing to be done here. */
     }
 
@@ -2283,7 +2297,7 @@
       earlyRun = 1;
       if (activePeerCount > CONNECTION_MAX_HOSTS_ / 8)
         {
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           return;               /* don't update too frequently, we need at 
least some
                                    semi-representative sampling! */
         }
@@ -2292,13 +2306,13 @@
     timeDifference = 1;
 
   /* build an array containing all BEs */
-  entries = MALLOC (sizeof (BufferEntry *) * activePeerCount);
+  entries = GNUNET_malloc (sizeof (BufferEntry *) * activePeerCount);
   utl.pos = 0;
   utl.e = entries;
   forAllConnectedHosts (&gatherEntries, &utl);
 
   /* compute latest shares based on traffic preferences */
-  shares = MALLOC (sizeof (double) * activePeerCount);
+  shares = GNUNET_malloc (sizeof (double) * activePeerCount);
   shareSum = 0.0;
   for (u = 0; u < activePeerCount; u++)
     {
@@ -2334,25 +2348,27 @@
       schedulableBandwidth = 0;
       minCon = max_bpm / MIN_BPM_PER_PEER;
     }
-  load = os_network_monitor_get_load (load_monitor, Download);
+  load = GNUNET_network_monitor_get_load (load_monitor, GNUNET_ND_DOWNLOAD);
   if (load > 100)               /* take counter measure */
     schedulableBandwidth = schedulableBandwidth * 100 / load;
   /* compute recent activity profile of the peer */
-  adjustedRR = MALLOC (sizeof (long long) * activePeerCount);
+  adjustedRR = GNUNET_malloc (sizeof (long long) * activePeerCount);
   GE_ASSERT (ectx, timeDifference != 0);
   for (u = 0; u < activePeerCount; u++)
     {
       adjustedRR[u]
-        = entries[u]->recently_received * cronMINUTES / timeDifference / 2;
+        =
+        entries[u]->recently_received * GNUNET_CRON_MINUTES / timeDifference /
+        2;
 
 #if DEBUG_CONNECTION
       if (adjustedRR[u] > entries[u]->idealized_limit)
         {
           IF_GELOG (ectx,
                     GE_INFO | GE_BULK | GE_USER,
-                    hash2enc (&entries[u]->session.sender.hashPubKey, &enc));
-          GE_LOG (ectx,
-                  GE_INFO | GE_BULK | GE_USER,
+                    GNUNET_hash_to_enc (&entries[u]->session.sender.
+                                        hashPubKey, &enc));
+          GE_LOG (ectx, GE_INFO | GE_BULK | GE_USER,
                   "peer `%s' transmitted above limit: %llu bpm > %u bpm\n",
                   &enc, adjustedRR[u], entries[u]->idealized_limit);
         }
@@ -2373,19 +2389,16 @@
 #if DEBUG_CONNECTION
               IF_GELOG (ectx,
                         GE_INFO | GE_BULK | GE_DEVELOPER,
-                        hash2enc (&entries[u]->session.sender.hashPubKey,
-                                  &enc));
-              GE_LOG (ectx,
-                      GE_INFO | GE_BULK | GE_DEVELOPER,
+                        GNUNET_hash_to_enc (&entries[u]->session.sender.
+                                            hashPubKey, &enc));
+              GE_LOG (ectx, GE_INFO | GE_BULK | GE_DEVELOPER,
                       "blacklisting `%s': sent repeatedly %llu bpm "
-                      "(limit %u bpm, target %u bpm)\n",
-                      &enc,
-                      adjustedRR[u],
+                      "(limit %u bpm, target %u bpm)\n", &enc, adjustedRR[u],
                       entries[u]->max_transmitted_limit,
                       entries[u]->idealized_limit);
 #endif
               identity->blacklistHost (&entries[u]->session.sender, 24 * 60 * 
60,       /* 1 day */
-                                       YES);
+                                       GNUNET_YES);
               shutdownConnection (entries[u]);
               activePeerCount--;
               entries[u] = entries[activePeerCount];
@@ -2407,7 +2420,7 @@
               entries[u]->violations--;
             }
         }
-      /* even if we received NO traffic, allow
+      /* even if we received GNUNET_NO traffic, allow
          at least MIN_BPM_PER_PEER */
       if (adjustedRR[u] < MIN_BPM_PER_PEER)
         adjustedRR[u] = MIN_BPM_PER_PEER;
@@ -2428,19 +2441,19 @@
      (unencrypted) traffic that we're not quite accounting for anyway,
      that's probably not so bad. */
 
-  didAssign = YES;
+  didAssign = GNUNET_YES;
   /* in the first round we cap by 2* previous utilization */
-  firstRound = YES;
+  firstRound = GNUNET_YES;
   for (u = 0; u < activePeerCount; u++)
     entries[u]->idealized_limit = 0;
   while ((schedulableBandwidth > activePeerCount * 100) &&
-         (activePeerCount > 0) && (didAssign == YES))
+         (activePeerCount > 0) && (didAssign == GNUNET_YES))
     {
-      didAssign = NO;
+      didAssign = GNUNET_NO;
       decrementSB = 0;
       for (u = 0; u < activePeerCount; u++)
         {
-          if ((firstRound == NO) ||
+          if ((firstRound == GNUNET_NO) ||
               (entries[u]->idealized_limit < adjustedRR[u] * 2))
             {
               unsigned int share;
@@ -2450,7 +2463,7 @@
                 (unsigned int) (shares[u] * schedulableBandwidth);
               if (share < entries[u]->idealized_limit)
                 share = 0xFFFFFFFF;     /* int overflow */
-              if ((share > adjustedRR[u] * 2) && (firstRound == YES))
+              if ((share > adjustedRR[u] * 2) && (firstRound == GNUNET_YES))
                 share = adjustedRR[u] * 2;
               /* always allow allocating MIN_BPM_PER_PEER */
               if ((share < MIN_BPM_PER_PEER) && (minCon > 0))
@@ -2463,7 +2476,7 @@
               if (share > entries[u]->idealized_limit)
                 {
                   decrementSB += share - entries[u]->idealized_limit;
-                  didAssign = YES;
+                  didAssign = GNUNET_YES;
                   entries[u]->idealized_limit = share;
                 }
             }
@@ -2478,14 +2491,14 @@
           schedulableBandwidth = 0;
           break;
         }
-      if ((activePeerCount > 0) && (didAssign == NO))
+      if ((activePeerCount > 0) && (didAssign == GNUNET_NO))
         {
-          perm = permute (WEAK, activePeerCount);
+          perm = GNUNET_permute (GNUNET_RANDOM_QUALITY_WEAK, activePeerCount);
           /* assign also to random "worthless" (zero-share) peers */
           for (u = 0; u < activePeerCount; u++)
             {
               unsigned int v = perm[u]; /* use perm to avoid preference to 
low-numbered slots */
-              if ((firstRound == NO) ||
+              if ((firstRound == GNUNET_NO) ||
                   (entries[v]->idealized_limit < adjustedRR[v] * 2))
                 {
                   unsigned int share;
@@ -2495,7 +2508,8 @@
                     (unsigned int) (schedulableBandwidth);
                   if (share < entries[v]->idealized_limit)
                     share = 0xFFFFFFFF; /* int overflow */
-                  if ((firstRound == YES) && (share > adjustedRR[v] * 2))
+                  if ((firstRound == GNUNET_YES)
+                      && (share > adjustedRR[v] * 2))
                     share = adjustedRR[v] * 2;
                   if (share > entries[v]->idealized_limit)
                     {
@@ -2505,22 +2519,22 @@
                     }
                 }
             }
-          FREE (perm);
+          GNUNET_free (perm);
           perm = NULL;
-        }                       /* didAssign == NO? */
-      if (firstRound == YES)
+        }                       /* didAssign == GNUNET_NO? */
+      if (firstRound == GNUNET_YES)
         {
           /* keep some bandwidth off the market
              for new connections */
           schedulableBandwidth = (schedulableBandwidth * 7) / 8;
         }
-      firstRound = NO;
+      firstRound = GNUNET_NO;
     }                           /* while bandwidth to distribute */
 
   if ((schedulableBandwidth > 0) && (activePeerCount > 0))
     {
       /* assign rest disregarding traffic limits */
-      perm = permute (WEAK, activePeerCount);
+      perm = GNUNET_permute (GNUNET_RANDOM_QUALITY_WEAK, activePeerCount);
       for (u = 0; u < activePeerCount; u++)
         {
           unsigned int share;
@@ -2539,7 +2553,7 @@
             }
         }
       schedulableBandwidth = 0;
-      FREE (perm);
+      GNUNET_free (perm);
       perm = NULL;
     }
 
@@ -2559,17 +2573,17 @@
         }
       else
         {                       /* minCon < activePeerCount */
-          min_uptime = get_time ();
+          min_uptime = GNUNET_get_time ();
           min_uptime_slot = -1;
           for (v = 0; v < activePeerCount; v++)
-            entries[v]->tes_selected = NO;
+            entries[v]->tes_selected = GNUNET_NO;
           for (u = 0; u < minCon; u++)
             {
               for (v = 0; v < activePeerCount; v++)
                 {
                   if ((entries[v]->time_established != 0) &&
                       (entries[v]->time_established < min_uptime) &&
-                      (entries[v]->tes_selected == NO))
+                      (entries[v]->tes_selected == GNUNET_NO))
                     {
                       min_uptime_slot = v;
                       min_uptime = entries[v]->time_established;
@@ -2577,7 +2591,7 @@
                 }
               if (min_uptime_slot != -1)
                 {
-                  entries[min_uptime_slot]->tes_selected = YES;
+                  entries[min_uptime_slot]->tes_selected = GNUNET_YES;
                   entries[min_uptime_slot]->idealized_limit
                     += MIN_BPM_PER_PEER;
                 }
@@ -2592,20 +2606,27 @@
 #if DEBUG_CONNECTION
       IF_GELOG (ectx,
                 GE_DEBUG | GE_BULK | GE_USER,
-                hash2enc (&entries[u]->session.sender.hashPubKey, &enc));
-      GE_LOG (ectx,
-              GE_DEBUG | GE_BULK | GE_USER,
+                GNUNET_hash_to_enc (&entries[u]->session.sender.hashPubKey,
+                                    &enc));
+      GE_LOG (ectx, GE_DEBUG | GE_BULK | GE_USER,
               "inbound limit for peer %u: %4s set to %u bpm (ARR: %lld, 
uptime: %llus, value: %lf)\n",
-              u, &enc, entries[u]->idealized_limit,
-              adjustedRR[u],
-              (get_time () - entries[u]->time_established) / cronSECONDS,
+              u, &enc, entries[u]->idealized_limit, adjustedRR[u],
+              (GNUNET_get_time () -
+               entries[u]->time_established) / GNUNET_CRON_SECONDS,
               entries[u]->current_connection_value);
 #endif
-      if ((timeDifference > 50) && (weak_randomi (timeDifference + 1) > 50))
+      if ((timeDifference > 50)
+          &&
+          (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, timeDifference + 1)
+           > 50))
         entries[u]->current_connection_value *= 0.9;    /* age */
       decrementSB =
-        entries[u]->idealized_limit * timeDifference / cronMINUTES / 2;
-      if ((decrementSB == 0) && (weak_randomi (timeDifference + 1) != 0))
+        entries[u]->idealized_limit * timeDifference / GNUNET_CRON_MINUTES /
+        2;
+      if ((decrementSB == 0)
+          &&
+          (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, timeDifference + 1)
+           != 0))
         decrementSB = 1;
       if (entries[u]->recently_received >= decrementSB)
         entries[u]->recently_received -= decrementSB;
@@ -2614,8 +2635,8 @@
     }
 
   /* free memory */
-  FREE (adjustedRR);
-  FREE (shares);
+  GNUNET_free (adjustedRR);
+  GNUNET_free (shares);
 
   for (u = 0; u < activePeerCount; u++)
     {
@@ -2626,9 +2647,9 @@
 #if DEBUG_CONNECTION
           IF_GELOG (ectx,
                     GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
-                    hash2enc (&be->session.sender.hashPubKey, &enc));
-          GE_LOG (ectx,
-                  GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+                    GNUNET_hash_to_enc (&be->session.sender.hashPubKey,
+                                        &enc));
+          GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
                   "Number of connections too high, shutting down low-traffic 
connection to `%s' (had only %u bpm)\n",
                   &enc, be->idealized_limit);
 #endif
@@ -2638,7 +2659,8 @@
           be->idealized_limit = MIN_BPM_PER_PEER;
           /* do not try to reconnect any time soon! */
           identity->blacklistHost (&be->session.sender,
-                                   SECONDS_BLACKLIST_AFTER_DISCONNECT, YES);
+                                   SECONDS_BLACKLIST_AFTER_DISCONNECT,
+                                   GNUNET_YES);
           shutdownConnection (be);
         }
       else
@@ -2649,8 +2671,8 @@
         }
     }
 
-  FREE (entries);
-  MUTEX_UNLOCK (lock);
+  GNUNET_free (entries);
+  GNUNET_mutex_unlock (lock);
 }
 
 /* ******** end of inbound bandwidth scheduling ************* */
@@ -2663,7 +2685,7 @@
  * messages -- and 10ms does not cause any noticeable CPU load during
  * testing.
  */
-#define CDL_FREQUENCY (10 * cronMILLIS)
+#define CDL_FREQUENCY (10 * GNUNET_CRON_MILLISECONDS)
 
 /**
  * Call this method periodically to drop dead connections.
@@ -2676,7 +2698,7 @@
   BufferEntry *root;
   BufferEntry *prev;
   BufferEntry *tmp;
-  cron_t now;
+  GNUNET_CronTime now;
   int i;
   unsigned long long total_allowed_sent;
   unsigned long long total_allowed_now;
@@ -2687,15 +2709,15 @@
   TSession *tsession;
 
   ENTRY ();
-  load_cpu = os_cpu_get_load (ectx, cfg);
-  load_nup = os_network_monitor_get_load (load_monitor, Upload);
+  load_cpu = GNUNET_cpu_get_load (ectx, cfg);
+  load_nup = GNUNET_network_monitor_get_load (load_monitor, GNUNET_ND_UPLOAD);
   scheduleInboundTraffic ();
-  now = get_time ();
+  now = GNUNET_get_time ();
   total_allowed_sent = 0;
   total_allowed_recv = 0;
   total_allowed_now = 0;
   total_send_buffer_size = 0;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < CONNECTION_MAX_HOSTS_; i++)
     {
       root = CONNECTION_buffer_[i];
@@ -2713,7 +2735,7 @@
                 prev->overflowChain = root->overflowChain;
               tmp = root;
               root = root->overflowChain;
-              FREE (tmp);
+              GNUNET_free (tmp);
               continue;         /* no need to call 'send buffer' */
             case STAT_UP:
               updateCurBPS (root);
@@ -2721,37 +2743,37 @@
               total_allowed_recv += root->idealized_limit;
               total_allowed_now += root->available_send_window;
               if ((now > root->isAlive) &&      /* concurrency might make this 
false... */
-                  (now - root->isAlive > SECONDS_INACTIVE_DROP * cronSECONDS))
+                  (now - root->isAlive >
+                   SECONDS_INACTIVE_DROP * GNUNET_CRON_SECONDS))
                 {
 #if DEBUG_CONNECTION
-                  EncName enc;
+                  GNUNET_EncName enc;
 
                   /* switch state form UP to DOWN: too much inactivity */
                   IF_GELOG (ectx,
                             GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
-                            hash2enc (&root->session.sender.hashPubKey,
-                                      &enc));
-                  GE_LOG (ectx,
-                          GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+                            GNUNET_hash_to_enc (&root->session.sender.
+                                                hashPubKey, &enc));
+                  GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
                           "Closing connection with `%s': "
-                          "too much inactivity (%llu ms)\n",
-                          &enc, now - root->isAlive);
+                          "too much inactivity (%llu ms)\n", &enc,
+                          now - root->isAlive);
 #endif
                   /* peer timed out -- shutdown connection */
                   identity->blacklistHost (&root->session.sender,
                                            SECONDS_BLACKLIST_AFTER_DISCONNECT,
-                                           YES);
+                                           GNUNET_YES);
                   shutdownConnection (root);
                 }
-              if ((root->consider_transport_switch == YES)
-                  && (load_cpu < IDLE_LOAD_THRESHOLD))
+              if ((root->consider_transport_switch == GNUNET_YES)
+                  && (load_cpu < GNUNET_IDLE_LOAD_THRESHOLD))
                 {
                   TSession *alternative;
 
                   GE_BREAK (NULL, root->session.mtu != 0);
                   alternative =
-                    transport->connectFreely (&root->session.sender, NO,
-                                              __FILE__);
+                    transport->connectFreely (&root->session.sender,
+                                              GNUNET_NO, __FILE__);
                   if ((alternative != NULL)
                       && (transport->getMTU (alternative->ttype) == 0))
                     {
@@ -2759,7 +2781,7 @@
                       root->session.mtu = 0;
                       root->session.tsession = alternative;
                       alternative = NULL;
-                      root->consider_transport_switch = NO;
+                      root->consider_transport_switch = GNUNET_NO;
                       if (tsession != NULL)
                         transport->disconnect (tsession, __FILE__);
                       if (stats != NULL)
@@ -2771,8 +2793,8 @@
               if ((root->available_send_window > 35 * 1024) &&
                   (root->sendBufferSize < 4) &&
                   (scl_nextHead != NULL) &&
-                  (load_nup < IDLE_LOAD_THRESHOLD) &&
-                  (load_cpu < IDLE_LOAD_THRESHOLD))
+                  (load_nup < GNUNET_IDLE_LOAD_THRESHOLD) &&
+                  (load_cpu < GNUNET_IDLE_LOAD_THRESHOLD))
                 {
                   /* create some traffic by force! */
                   char *msgBuf;
@@ -2783,7 +2805,7 @@
                   hSize = root->available_send_window;
                   if (hSize > 63 * 1024)
                     hSize = 63 * 1024;
-                  msgBuf = MALLOC (hSize);
+                  msgBuf = GNUNET_malloc (hSize);
                   pos = scl_nextHead;
                   while ((pos != NULL) && (hSize > 0))
                     {
@@ -2794,8 +2816,8 @@
                           if (mSize > 0)
                             {
                               unicast (&root->session.sender,
-                                       (MESSAGE_HEADER *) msgBuf,
-                                       0, 5 * cronMINUTES);
+                                       (GNUNET_MessageHeader *) msgBuf,
+                                       0, 5 * GNUNET_CRON_MINUTES);
                               if (mSize > hSize)
                                 {
                                   GE_BREAK (ectx, 0);
@@ -2809,23 +2831,22 @@
                         }
                       pos = pos->next;
                     }
-                  FREE (msgBuf);
+                  GNUNET_free (msgBuf);
                 }
               break;
             default:           /* not up, not down - partial SETKEY exchange */
               if ((now > root->isAlive) &&
                   (now - root->isAlive >
-                   SECONDS_NOPINGPONG_DROP * cronSECONDS))
+                   SECONDS_NOPINGPONG_DROP * GNUNET_CRON_SECONDS))
                 {
 #if DEBUG_CONNECTION
-                  EncName enc;
+                  GNUNET_EncName enc;
 
                   IF_GELOG (ectx,
                             GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
-                            hash2enc (&root->session.sender.hashPubKey,
-                                      &enc));
-                  GE_LOG (ectx,
-                          GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+                            GNUNET_hash_to_enc (&root->session.sender.
+                                                hashPubKey, &enc));
+                  GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
                           "closing connection to %s: %s not answered.\n",
                           &enc,
                           (root->status ==
@@ -2837,7 +2858,7 @@
                      establish a session in the first place! */
                   identity->blacklistHost (&root->session.sender,
                                            
SECONDS_BLACKLIST_AFTER_FAILED_CONNECT,
-                                           NO);
+                                           GNUNET_NO);
                   shutdownConnection (root);
                 }
               break;
@@ -2847,7 +2868,7 @@
           root = root->overflowChain;
         }                       /* end of while */
     }                           /* for all buckets */
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   if (stats != NULL)
     {
       if (total_allowed_sent > max_bpm_up)
@@ -2868,21 +2889,21 @@
  * @param sender from which peer did we receive the SEQ message
  * @param msg the p2p message (the decrypted message is stored here, too!)
  * @param size the size of the message
- * @return YES if the message was encrypted,
- *         NO if it was in plaintext,
- *         SYSERR if it was malformed
+ * @return GNUNET_YES if the message was encrypted,
+ *         GNUNET_NO if it was in plaintext,
+ *         GNUNET_SYSERR if it was malformed
  */
 int
-checkHeader (const PeerIdentity * sender,
+checkHeader (const GNUNET_PeerIdentity * sender,
              P2P_PACKET_HEADER * msg, unsigned short size)
 {
   BufferEntry *be;
   int res;
   unsigned int sequenceNumber;
-  TIME_T stamp;
+  GNUNET_Int32Time stamp;
   char *tmp;
-  HashCode512 hc;
-  EncName enc;
+  GNUNET_HashCode hc;
+  GNUNET_EncName enc;
 
   ENTRY ();
   GE_ASSERT (ectx, msg != NULL);
@@ -2891,27 +2912,27 @@
     {
       IF_GELOG (ectx,
                 GE_WARNING | GE_BULK | GE_DEVELOPER,
-                hash2enc (&sender->hashPubKey, &enc));
+                GNUNET_hash_to_enc (&sender->hashPubKey, &enc));
       GE_LOG (ectx,
               GE_WARNING | GE_BULK | GE_DEVELOPER,
               _("Message from `%s' discarded: invalid format.\n"), &enc);
       EXIT ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (stats != NULL)
     stats->change (stat_received, size);
-  hash2enc (&sender->hashPubKey, &enc);
-  hash (&msg->sequenceNumber, size - sizeof (HashCode512), &hc);
-  if (equalsHashCode512 (&hc,
-                         &msg->hash) &&
+  GNUNET_hash_to_enc (&sender->hashPubKey, &enc);
+  GNUNET_hash (&msg->sequenceNumber, size - sizeof (GNUNET_HashCode), &hc);
+  if (0 == memcmp (&hc,
+                   &msg->hash, sizeof (GNUNET_HashCode)) &&
       (msg->sequenceNumber == 0) &&
       (msg->bandwidth == 0) && (msg->timeStamp == 0))
     {
       EXIT ();
-      return NO;                /* plaintext */
+      return GNUNET_NO;         /* plaintext */
     }
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   be = lookForHost (sender);
   if ((be == NULL) ||
       (be->status == STAT_DOWN) || (be->status == STAT_SETKEY_SENT))
@@ -2919,7 +2940,7 @@
 #if DEBUG_CONNECTION
       IF_GELOG (ectx,
                 GE_INFO | GE_BULK | GE_DEVELOPER,
-                hash2enc (&sender->hashPubKey, &enc));
+                GNUNET_hash_to_enc (&sender->hashPubKey, &enc));
       GE_LOG (ectx,
               GE_INFO | GE_BULK | GE_DEVELOPER,
               "Decrypting message from host `%s' failed, no sessionkey 
(yet)!\n",
@@ -2928,41 +2949,43 @@
       /* try to establish a connection, that way, we don't keep
          getting bogus messages until the other one times out. */
       if ((be == NULL) || (be->status == STAT_DOWN))
-        addHost (sender, YES);
-      MUTEX_UNLOCK (lock);
+        addHost (sender, GNUNET_YES);
+      GNUNET_mutex_unlock (lock);
       EXIT ();
-      return SYSERR;            /* could not decrypt */
+      return GNUNET_SYSERR;     /* could not decrypt */
     }
-  tmp = MALLOC (size - sizeof (HashCode512));
-  res = decryptBlock (&be->skey_remote, &msg->sequenceNumber, size - sizeof 
(HashCode512), (const INITVECTOR *) &msg->hash,     /* IV */
-                      tmp);
-  hash (tmp, size - sizeof (HashCode512), &hc);
-  if (!((res != OK) && equalsHashCode512 (&hc, &msg->hash)))
+  tmp = GNUNET_malloc (size - sizeof (GNUNET_HashCode));
+  res = GNUNET_AES_decrypt (&be->skey_remote, &msg->sequenceNumber, size - 
sizeof (GNUNET_HashCode), (const GNUNET_AES_InitializationVector *) &msg->hash, 
     /* IV */
+                            tmp);
+  GNUNET_hash (tmp, size - sizeof (GNUNET_HashCode), &hc);
+  if (!
+      ((res != GNUNET_OK)
+       && (0 == memcmp (&hc, &msg->hash, sizeof (GNUNET_HashCode)))))
     {
 #if DEBUG_CONNECTION
       IF_GELOG (ectx,
                 GE_INFO | GE_BULK | GE_DEVELOPER,
-                hash2enc (&sender->hashPubKey, &enc));
+                GNUNET_hash_to_enc (&sender->hashPubKey, &enc));
       GE_LOG (ectx,
               GE_INFO | GE_BULK | GE_DEVELOPER,
               "Decrypting message from host `%s' failed, wrong sessionkey!\n",
               &enc);
 #endif
-      addHost (sender, YES);
-      MUTEX_UNLOCK (lock);
-      FREE (tmp);
+      addHost (sender, GNUNET_YES);
+      GNUNET_mutex_unlock (lock);
+      GNUNET_free (tmp);
       EXIT ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (stats != NULL)
-    stats->change (stat_decrypted, size - sizeof (HashCode512));
-  memcpy (&msg->sequenceNumber, tmp, size - sizeof (HashCode512));
-  FREE (tmp);
-  res = YES;
+    stats->change (stat_decrypted, size - sizeof (GNUNET_HashCode));
+  memcpy (&msg->sequenceNumber, tmp, size - sizeof (GNUNET_HashCode));
+  GNUNET_free (tmp);
+  res = GNUNET_YES;
   sequenceNumber = ntohl (msg->sequenceNumber);
   if (be->lastSequenceNumberReceived >= sequenceNumber)
     {
-      res = SYSERR;
+      res = GNUNET_SYSERR;
       if ((be->lastSequenceNumberReceived - sequenceNumber <= 32) &&
           (be->lastSequenceNumberReceived != sequenceNumber))
         {
@@ -2971,10 +2994,10 @@
           if ((be->lastPacketsBitmap & rotbit) == 0)
             {
               be->lastPacketsBitmap |= rotbit;
-              res = OK;
+              res = GNUNET_OK;
             }
         }
-      if (res == SYSERR)
+      if (res == GNUNET_SYSERR)
         {
 #if DEBUG_CONNECTION
           GE_LOG (ectx,
@@ -2983,9 +3006,9 @@
                     " %u <= %u, dropping message.\n"),
                   sequenceNumber, be->lastSequenceNumberReceived);
 #endif
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           EXIT ();
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
     }
   else
@@ -2996,16 +3019,16 @@
       be->lastSequenceNumberReceived = sequenceNumber;
     }
   stamp = ntohl (msg->timeStamp);
-  if (stamp + 1 * cronDAYS < TIME (NULL))
+  if (stamp + 1 * GNUNET_CRON_DAYS < GNUNET_get_time_int32 (NULL))
     {
 #if DEBUG_CONNECTION
       GE_LOG (ectx,
               GE_INFO | GE_BULK | GE_USER,
               _("Message received more than one day old. Dropped.\n"));
 #endif
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       EXIT ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
   be->max_bpm = ntohl (msg->bandwidth);
@@ -3016,12 +3039,12 @@
                        be->available_send_window
                        - (long long) be->max_bpm * MAX_BUF_FACT);
       be->available_send_window = (long long) be->max_bpm * MAX_BUF_FACT;
-      be->last_bps_update = get_time ();
+      be->last_bps_update = GNUNET_get_time ();
     }
   be->recently_received += size;
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
-  return YES;
+  return GNUNET_YES;
 }
 
 /**
@@ -3030,44 +3053,45 @@
  *
  * @param sender the peer sending the HANGUP message
  * @param msg the HANGUP message
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
-handleHANGUP (const PeerIdentity * sender, const MESSAGE_HEADER * msg)
+handleHANGUP (const GNUNET_PeerIdentity * sender,
+              const GNUNET_MessageHeader * msg)
 {
   BufferEntry *be;
 #if DEBUG_CONNECTION
-  EncName enc;
+  GNUNET_EncName enc;
 #endif
 
   ENTRY ();
   if (ntohs (msg->size) != sizeof (P2P_hangup_MESSAGE))
-    return SYSERR;
+    return GNUNET_SYSERR;
   if (0 != memcmp (sender,
                    &((P2P_hangup_MESSAGE *) msg)->sender,
-                   sizeof (PeerIdentity)))
-    return SYSERR;
+                   sizeof (GNUNET_PeerIdentity)))
+    return GNUNET_SYSERR;
 #if DEBUG_CONNECTION
   IF_GELOG (ectx,
             GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
-            hash2enc (&sender->hashPubKey, &enc));
+            GNUNET_hash_to_enc (&sender->hashPubKey, &enc));
   GE_LOG (ectx,
           GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
           "received HANGUP from `%s'\n", &enc);
 #endif
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   be = lookForHost (sender);
   if (be == NULL)
     {
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   /* do not try to reconnect any time soon! */
   identity->blacklistHost (&be->session.sender,
-                           SECONDS_BLACKLIST_AFTER_DISCONNECT, YES);
+                           SECONDS_BLACKLIST_AFTER_DISCONNECT, GNUNET_YES);
   shutdownConnection (be);
-  MUTEX_UNLOCK (lock);
-  return OK;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 
@@ -3078,24 +3102,25 @@
  *
  * @param key the sessionkey,
  * @param peer the other peer,
- * @param forSending NO if it is the key for receiving,
- *                   YES if it is the key for sending
+ * @param forSending GNUNET_NO if it is the key for receiving,
+ *                   GNUNET_YES if it is the key for sending
  */
 void
-assignSessionKey (const SESSIONKEY * key,
-                  const PeerIdentity * peer, TIME_T age, int forSending)
+assignSessionKey (const GNUNET_AES_SessionKey * key,
+                  const GNUNET_PeerIdentity * peer, GNUNET_Int32Time age,
+                  int forSending)
 {
   BufferEntry *be;
 
   ENTRY ();
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   be = lookForHost (peer);
   if (be == NULL)
-    be = addHost (peer, NO);
+    be = addHost (peer, GNUNET_NO);
   if (be != NULL)
     {
-      be->isAlive = get_time ();
-      if (forSending == YES)
+      be->isAlive = GNUNET_get_time ();
+      if (forSending == GNUNET_YES)
         {
           be->skey_local = *key;
           be->skey_local_created = age;
@@ -3106,7 +3131,9 @@
           if (((be->status & STAT_SETKEY_RECEIVED) == 0) ||
               (be->skey_remote_created < age))
             {
-              if (0 != memcmp (key, &be->skey_remote, sizeof (SESSIONKEY)))
+              if (0 !=
+                  memcmp (key, &be->skey_remote,
+                          sizeof (GNUNET_AES_SessionKey)))
                 {
                   be->skey_remote = *key;
                   be->lastSequenceNumberReceived = 0;
@@ -3116,7 +3143,7 @@
             }
         }
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
 }
 
@@ -3126,38 +3153,39 @@
  * @param peer the other peer,
  */
 void
-confirmSessionUp (const PeerIdentity * peer)
+confirmSessionUp (const GNUNET_PeerIdentity * peer)
 {
   BufferEntry *be;
 
   ENTRY ();
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   be = lookForHost (peer);
   if (be != NULL)
     {
-      be->isAlive = get_time ();
+      be->isAlive = GNUNET_get_time ();
       identity->whitelistHost (peer);
       if (((be->status & STAT_SETKEY_SENT) > 0) &&
           ((be->status & STAT_SETKEY_RECEIVED) > 0) &&
-          (OK == ensureTransportConnected (be)) && (be->status != STAT_UP))
+          (GNUNET_OK == ensureTransportConnected (be))
+          && (be->status != STAT_UP))
         {
 #if DEBUG_CONNECTION
-          EncName enc;
+          GNUNET_EncName enc;
           IF_GELOG (ectx,
                     GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
-                    hash2enc (&peer->hashPubKey, &enc));
+                    GNUNET_hash_to_enc (&peer->hashPubKey, &enc));
           GE_LOG (ectx,
                   GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
                   "Received confirmation that session is UP for `%s'\n",
                   &enc);
 #endif
-          be->time_established = get_time ();
+          be->time_established = GNUNET_get_time ();
           be->status = STAT_UP;
           be->lastSequenceNumberReceived = 0;
           be->lastSequenceNumberSend = 1;
         }
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
 }
 
@@ -3185,7 +3213,7 @@
 
   ENTRY ();
   ret = 0;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   if ((slot >= 0) && (slot < CONNECTION_MAX_HOSTS_))
     {
       be = CONNECTION_buffer_[slot];
@@ -3196,7 +3224,7 @@
           be = be->overflowChain;
         }
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
   return ret;
 }
@@ -3205,29 +3233,29 @@
  * Get the time of the last encrypted message that was received
  * from the given peer.
  * @param time updated with the time
- * @return SYSERR if we are not connected to the peer at the moment
+ * @return GNUNET_SYSERR if we are not connected to the peer at the moment
  */
 int
-getLastActivityOf (const PeerIdentity * peer, cron_t * time)
+getLastActivityOf (const GNUNET_PeerIdentity * peer, GNUNET_CronTime * time)
 {
   int ret;
   BufferEntry *be;
 
   ENTRY ();
   ret = 0;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   be = lookForHost (peer);
   if ((be != NULL) && (be->status == STAT_UP))
     {
       *time = be->isAlive;
-      ret = OK;
+      ret = GNUNET_OK;
     }
   else
     {
       *time = 0;
-      ret = SYSERR;
+      ret = GNUNET_SYSERR;
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
   return ret;
 }
@@ -3238,25 +3266,26 @@
  * @param key the sessionkey (set)
  * @param age the age of the key (set)
  * @param peer the other peer,
- * @param forSending NO if it is the key for receiving,
- *                   YES if it is the key for sending
- * @return SYSERR if no sessionkey is known to the core,
- *         OK if the sessionkey was set.
+ * @param forSending GNUNET_NO if it is the key for receiving,
+ *                   GNUNET_YES if it is the key for sending
+ * @return GNUNET_SYSERR if no sessionkey is known to the core,
+ *         GNUNET_OK if the sessionkey was set.
  */
 int
-getCurrentSessionKey (const PeerIdentity * peer,
-                      SESSIONKEY * key, TIME_T * age, int forSending)
+getCurrentSessionKey (const GNUNET_PeerIdentity * peer,
+                      GNUNET_AES_SessionKey * key, GNUNET_Int32Time * age,
+                      int forSending)
 {
   int ret;
   BufferEntry *be;
 
   ENTRY ();
-  ret = SYSERR;
-  MUTEX_LOCK (lock);
+  ret = GNUNET_SYSERR;
+  GNUNET_mutex_lock (lock);
   be = lookForHost (peer);
   if (be != NULL)
     {
-      if (forSending == YES)
+      if (forSending == GNUNET_YES)
         {
           if ((be->status & STAT_SETKEY_SENT) > 0)
             {
@@ -3264,7 +3293,7 @@
                 *key = be->skey_local;
               if (age != NULL)
                 *age = be->skey_local_created;
-              ret = OK;
+              ret = GNUNET_OK;
             }
         }
       else
@@ -3275,11 +3304,11 @@
                 *key = be->skey_remote;
               if (age != NULL)
                 *age = be->skey_remote_created;
-              ret = OK;
+              ret = GNUNET_OK;
             }
         }
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
   return ret;
 }
@@ -3293,13 +3322,13 @@
  * on that TCP connection instead of keeping SMTP going.<p>
  *
  * Taking the transport over only makes sense if the cost is lower.
- * This method checks this. 
+ * This method checks this.
  *
  * @param tsession the transport session that is for grabs
  * @param sender the identity of the other node
  */
 void
-considerTakeover (const PeerIdentity * sender, TSession * tsession)
+considerTakeover (const GNUNET_PeerIdentity * sender, TSession * tsession)
 {
   BufferEntry *be;
   unsigned int cost;
@@ -3308,16 +3337,16 @@
   ENTRY ();
   if (tsession == NULL)
     return;
-  if (0 != memcmp (sender, &tsession->peer, sizeof (PeerIdentity)))
+  if (0 != memcmp (sender, &tsession->peer, sizeof (GNUNET_PeerIdentity)))
     {
       GE_BREAK (NULL, 0);
       return;
     }
-  MUTEX_LOCK (lock);
-  be = addHost (sender, NO);
+  GNUNET_mutex_lock (lock);
+  be = addHost (sender, GNUNET_NO);
   if (be == NULL)
     {
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       EXIT ();
       return;
     }
@@ -3329,19 +3358,20 @@
 
      Answer: this will always switch to TCP in the long run (if
      that is possible) since udpAssociate always
-     returns SYSERR. This is intended since for long-running
+     returns GNUNET_SYSERR. This is intended since for long-running
      sessions, TCP is the better choice. UDP is only better for
      sending very few messages (e.g. attempting an initial exchange
      to get to know each other). See also transport paper and the
      data on throughput. - CG
    */
   if (((transport->getCost (tsession->ttype) < cost) ||
-       ((be->consider_transport_switch == YES) &&
+       ((be->consider_transport_switch == GNUNET_YES) &&
         (transport->getMTU (tsession->ttype) == 0))) &&
-      (OK == transport->associate (tsession, __FILE__)))
+      (GNUNET_OK == transport->associate (tsession, __FILE__)))
     {
       GE_ASSERT (NULL,
-                 OK == transport->assertAssociated (tsession, __FILE__));
+                 GNUNET_OK == transport->assertAssociated (tsession,
+                                                           __FILE__));
       ts = be->session.tsession;
       if (ts != NULL)
         {
@@ -3350,14 +3380,14 @@
         }
       be->session.tsession = tsession;
       be->session.mtu = transport->getMTU (tsession->ttype);
-      if ((be->consider_transport_switch == YES) &&
+      if ((be->consider_transport_switch == GNUNET_YES) &&
           (transport->getMTU (tsession->ttype) == 0))
-        be->consider_transport_switch = NO;
+        be->consider_transport_switch = GNUNET_NO;
       check_invariants ();
       fragmentIfNecessary (be);
     }
   EXIT ();
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
 }
 
@@ -3380,11 +3410,11 @@
     return 0;                   /* fast path */
   if (-1 == GC_get_configuration_value_number (cfg, "LOAD", 
"MAXNETDOWNBPSTOTAL", 0, ((unsigned long long) -1) / 60, 50000,     /* default: 
50 kbps */
                                                &new_max_bpm))
-    return SYSERR;
+    return GNUNET_SYSERR;
   GC_get_configuration_value_number (cfg, "LOAD", "MAXNETUPBPSTOTAL", 0, 
((unsigned long long) -1) / 60, 50000, /* default: 50 kbps */
                                      &max_bpm_up);
   max_bpm_up *= 60;             /* bps -> bpm */
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   new_max_bpm = 60 * new_max_bpm;
   if (max_bpm != new_max_bpm)
     {
@@ -3393,8 +3423,8 @@
       max_bpm = new_max_bpm;
       newMAXHOSTS = max_bpm / (MIN_BPM_PER_PEER * 4);
       /* => for 1000 bps, we get 12 (rounded DOWN to 8) connections! */
-      if (newMAXHOSTS < MIN_CONNECTION_TARGET * 2)
-        newMAXHOSTS = MIN_CONNECTION_TARGET * 2;
+      if (newMAXHOSTS < GNUNET_MIN_CONNECTION_TARGET * 2)
+        newMAXHOSTS = GNUNET_MIN_CONNECTION_TARGET * 2;
       if (newMAXHOSTS > 256)
         newMAXHOSTS = 256;      /* limit, otherwise we run out of sockets! */
 
@@ -3413,7 +3443,8 @@
                                                             
"connection-max-hosts",
                                                             
CONNECTION_MAX_HOSTS_));
           newBuffer =
-            (BufferEntry **) MALLOC (sizeof (BufferEntry *) * newMAXHOSTS);
+            (BufferEntry **) GNUNET_malloc (sizeof (BufferEntry *) *
+                                            newMAXHOSTS);
           for (i = 0; i < CONNECTION_MAX_HOSTS_; i++)
             newBuffer[i] = NULL;
 
@@ -3435,7 +3466,7 @@
                   be = next;
                 }
             }
-          FREENONNULL (CONNECTION_buffer_);
+          GNUNET_free_non_null (CONNECTION_buffer_);
           CONNECTION_buffer_ = newBuffer;
 
           GE_LOG (ectx,
@@ -3447,8 +3478,9 @@
     }
   disable_random_padding = GC_get_configuration_value_yesno (cfg,
                                                              
"GNUNETD-EXPERIMENTAL",
-                                                             "PADDING", NO);
-  MUTEX_UNLOCK (lock);
+                                                             "PADDING",
+                                                             GNUNET_NO);
+  GNUNET_mutex_unlock (lock);
   return 0;
 }
 
@@ -3458,7 +3490,7 @@
 void
 initConnection (struct GE_Context *e,
                 struct GC_Configuration *c,
-                struct LoadMonitor *m, struct CronManager *cm)
+                struct GNUNET_LoadMonitor *m, struct GNUNET_CronManager *cm)
 {
   ectx = e;
   cfg = c;
@@ -3476,8 +3508,9 @@
                                              NULL));
   GE_ASSERT (ectx, CONNECTION_MAX_HOSTS_ != 0);
   registerp2pHandler (P2P_PROTO_hangup, &handleHANGUP);
-  cron_add_job (cron,
-                &cronDecreaseLiveness, CDL_FREQUENCY, CDL_FREQUENCY, NULL);
+  GNUNET_cron_add_job (cron,
+                       &cronDecreaseLiveness, CDL_FREQUENCY, CDL_FREQUENCY,
+                       NULL);
 #if DEBUG_COLLECT_PRIO
   prioFile = FOPEN ("/tmp/knapsack_prio.txt", "w");
 #endif
@@ -3563,7 +3596,7 @@
 
   ENTRY ();
   GC_detach_change_listener (cfg, &connectionConfigChangeCallback, NULL);
-  cron_del_job (cron, &cronDecreaseLiveness, CDL_FREQUENCY, NULL);
+  GNUNET_cron_del_job (cron, &cronDecreaseLiveness, CDL_FREQUENCY, NULL);
   for (i = 0; i < CONNECTION_MAX_HOSTS_; i++)
     {
       BufferEntry *prev;
@@ -3581,17 +3614,17 @@
           prev = be;
           be = be->overflowChain;
           CONNECTION_buffer_[i] = be;
-          FREE (prev);
+          GNUNET_free (prev);
         }
     }
-  FREENONNULL (CONNECTION_buffer_);
+  GNUNET_free_non_null (CONNECTION_buffer_);
   CONNECTION_buffer_ = NULL;
   CONNECTION_MAX_HOSTS_ = 0;
   while (scl_nextHead != NULL)
     {
       scl = scl_nextHead;
       scl_nextHead = scl_nextHead->next;
-      FREE (scl);
+      GNUNET_free (scl);
     }
   scl_nextTail = NULL;
   transport->stop ();
@@ -3638,9 +3671,9 @@
   ENTRY ();
   wrap.method = method;
   wrap.arg = arg;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   ret = forAllConnectedHosts (&fENHCallback, &wrap);
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
   return ret;
 }
@@ -3653,12 +3686,12 @@
 {
   unsigned int i;
   BufferEntry *tmp;
-  EncName hostName;
-  EncName skey_local;
-  EncName skey_remote;
+  GNUNET_EncName hostName;
+  GNUNET_EncName skey_local;
+  GNUNET_EncName skey_remote;
   unsigned int ttype;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   ENTRY ();
   for (i = 0; i < CONNECTION_MAX_HOSTS_; i++)
     {
@@ -3667,9 +3700,11 @@
         {
           if (tmp->status != STAT_DOWN)
             {
-              hash2enc (&tmp->session.sender.hashPubKey, &hostName);
-              hash2enc ((HashCode512 *) & tmp->skey_local, &skey_local);
-              hash2enc ((HashCode512 *) & tmp->skey_remote, &skey_remote);
+              GNUNET_hash_to_enc (&tmp->session.sender.hashPubKey, &hostName);
+              GNUNET_hash_to_enc ((GNUNET_HashCode *) & tmp->skey_local,
+                                  &skey_local);
+              GNUNET_hash_to_enc ((GNUNET_HashCode *) & tmp->skey_remote,
+                                  &skey_remote);
               hostName.encoding[4] = '\0';
               skey_local.encoding[4] = '\0';
               skey_remote.encoding[4] = '\0';
@@ -3683,17 +3718,16 @@
                       i,
                       tmp->status,
                       ttype,
-                      (int) ((get_time () - tmp->isAlive) / cronSECONDS),
-                      SECONDS_INACTIVE_DROP,
-                      tmp->recently_received,
-                      tmp->idealized_limit,
-                      tmp->sendBufferSize,
-                      &hostName, &skey_local, &skey_remote);
+                      (int) ((GNUNET_get_time () -
+                              tmp->isAlive) / GNUNET_CRON_SECONDS),
+                      SECONDS_INACTIVE_DROP, tmp->recently_received,
+                      tmp->idealized_limit, tmp->sendBufferSize, &hostName,
+                      &skey_local, &skey_remote);
             }
           tmp = tmp->overflowChain;
         }
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 }
 
 /**
@@ -3714,7 +3748,7 @@
  *   the message, padding is the number of bytes left in that buffer.
  *   The callback method must return the number of bytes written to
  *   that buffer (must be a positive number).
- * @return OK if the handler was registered, SYSERR on error
+ * @return GNUNET_OK if the handler was registered, GNUNET_SYSERR on error
  */
 int
 registerSendCallback (const unsigned int minimumPadding,
@@ -3723,11 +3757,11 @@
   SendCallbackList *scl;
 
   ENTRY ();
-  scl = MALLOC (sizeof (SendCallbackList));
+  scl = GNUNET_malloc (sizeof (SendCallbackList));
   scl->minimumPadding = minimumPadding;
   scl->callback = callback;
   scl->next = NULL;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   if (scl_nextTail == NULL)
     {
       scl_nextHead = scl;
@@ -3738,9 +3772,9 @@
       scl_nextTail->next = scl;
       scl_nextTail = scl;
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -3754,7 +3788,7 @@
  *   the message, padding is the number of bytes left in that buffer.
  *   The callback method must return the number of bytes written to
  *   that buffer (must be a positive number).
- * @return OK if the handler was removed, SYSERR on error
+ * @return GNUNET_OK if the handler was removed, GNUNET_SYSERR on error
  */
 int
 unregisterSendCallback (const unsigned int minimumPadding,
@@ -3765,7 +3799,7 @@
 
   ENTRY ();
   prev = NULL;
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   pos = scl_nextHead;
   while (pos != NULL)
     {
@@ -3778,17 +3812,17 @@
             prev->next = pos->next;
           if (scl_nextTail == pos)
             scl_nextTail = prev;
-          FREE (pos);
-          MUTEX_UNLOCK (lock);
+          GNUNET_free (pos);
+          GNUNET_mutex_unlock (lock);
           EXIT ();
-          return OK;
+          return GNUNET_OK;
         }
       prev = pos;
       pos = pos->next;
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -3801,7 +3835,7 @@
  *
  * @param session the transport session
  * @param msg the message to transmit, should contain MESSAGE_HEADERs
- * @return OK on success, SYSERR on failure, NO on temporary failure
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure, GNUNET_NO on 
temporary failure
  */
 int
 sendPlaintext (TSession * tsession, const char *msg, unsigned int size)
@@ -3817,19 +3851,21 @@
        size + sizeof (P2P_PACKET_HEADER)))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  buf = MALLOC (size + sizeof (P2P_PACKET_HEADER));
+  buf = GNUNET_malloc (size + sizeof (P2P_PACKET_HEADER));
   hdr = (P2P_PACKET_HEADER *) buf;
   hdr->sequenceNumber = 0;
   hdr->timeStamp = 0;
   hdr->bandwidth = 0;
   memcpy (&buf[sizeof (P2P_PACKET_HEADER)], msg, size);
-  hash (&hdr->sequenceNumber,
-        size + sizeof (P2P_PACKET_HEADER) - sizeof (HashCode512), &hdr->hash);
-  ret = transport->send (tsession,
-                         buf, size + sizeof (P2P_PACKET_HEADER), YES);
-  FREE (buf);
+  GNUNET_hash (&hdr->sequenceNumber,
+               size + sizeof (P2P_PACKET_HEADER) - sizeof (GNUNET_HashCode),
+               &hdr->hash);
+  ret =
+    transport->send (tsession, buf, size + sizeof (P2P_PACKET_HEADER),
+                     GNUNET_YES);
+  GNUNET_free (buf);
   EXIT ();
   return ret;
 }
@@ -3846,7 +3882,7 @@
  * @param maxdelay how long can the message wait?
  */
 void
-unicastCallback (const PeerIdentity * hostId,
+unicastCallback (const GNUNET_PeerIdentity * hostId,
                  BuildMessageCallback callback,
                  void *closure,
                  unsigned short len,
@@ -3855,27 +3891,27 @@
   BufferEntry *be;
 
   ENTRY ();
-  MUTEX_LOCK (lock);
-  be = addHost (hostId, YES);
+  GNUNET_mutex_lock (lock);
+  be = addHost (hostId, GNUNET_YES);
   if ((be != NULL) && (be->status != STAT_DOWN))
     {
       SendEntry *entry;
 
-      entry = MALLOC (sizeof (SendEntry));
+      entry = GNUNET_malloc (sizeof (SendEntry));
       entry->len = len;
       entry->flags = SE_FLAG_NONE;
       entry->pri = importance;
-      entry->transmissionTime = get_time () + maxdelay;
+      entry->transmissionTime = GNUNET_get_time () + maxdelay;
       entry->callback = callback;
       entry->closure = closure;
-      entry->knapsackSolution = NO;
+      entry->knapsackSolution = GNUNET_NO;
       appendToBuffer (be, entry);
     }
   else
     {
-      FREENONNULL (closure);
+      GNUNET_free_non_null (closure);
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
 }
 
@@ -3889,15 +3925,15 @@
  * @param maxdelay how long can the message be delayed?
  */
 void
-unicast (const PeerIdentity * receiver,
-         const MESSAGE_HEADER * msg,
+unicast (const GNUNET_PeerIdentity * receiver,
+         const GNUNET_MessageHeader * msg,
          unsigned int importance, unsigned int maxdelay)
 {
   char *closure;
   unsigned short len;
 
   ENTRY ();
-  if (getBandwidthAssignedTo (receiver, NULL, NULL) != OK)
+  if (getBandwidthAssignedTo (receiver, NULL, NULL) != GNUNET_OK)
     session->tryConnect (receiver);
   if (msg == NULL)
     {
@@ -3913,7 +3949,7 @@
       EXIT ();
       return;
     }
-  closure = MALLOC (len);
+  closure = GNUNET_malloc (len);
   memcpy (closure, msg, len);
   unicastCallback (receiver, NULL, closure, len, importance, maxdelay);
   EXIT ();
@@ -3926,7 +3962,7 @@
  * @return the index for this peer in the connection table
  */
 unsigned int
-computeIndex (const PeerIdentity * hostId)
+computeIndex (const GNUNET_PeerIdentity * hostId)
 {
   unsigned int res;
 
@@ -3942,7 +3978,7 @@
  *
  * @return the lock
  */
-struct MUTEX *
+struct GNUNET_Mutex *
 getConnectionModuleLock ()
 {
   GE_ASSERT (NULL, lock != NULL);
@@ -3950,14 +3986,14 @@
 }
 
 int
-getBandwidthAssignedTo (const PeerIdentity * node,
-                        unsigned int *bpm, cron_t * last_seen)
+getBandwidthAssignedTo (const GNUNET_PeerIdentity * node,
+                        unsigned int *bpm, GNUNET_CronTime * last_seen)
 {
   BufferEntry *be;
   unsigned int ret;
 
   ENTRY ();
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   be = lookForHost (node);
   if ((be != NULL) && (be->status == STAT_UP))
     {
@@ -3965,13 +4001,13 @@
         *bpm = be->idealized_limit;
       if (last_seen != NULL)
         *last_seen = be->isAlive;
-      ret = OK;
+      ret = GNUNET_OK;
     }
   else
     {
-      ret = SYSERR;
+      ret = GNUNET_SYSERR;
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
   return ret;
 }
@@ -3982,16 +4018,16 @@
  * @param preference how much should the traffic preference be increased?
  */
 void
-updateTrafficPreference (const PeerIdentity * node, double preference)
+updateTrafficPreference (const GNUNET_PeerIdentity * node, double preference)
 {
   BufferEntry *be;
 
   ENTRY ();
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   be = lookForHost (node);
   if (be != NULL)
     be->current_connection_value += preference;
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
 }
 
@@ -4002,21 +4038,21 @@
  * @param peer the peer to disconnect
  */
 void
-disconnectFromPeer (const PeerIdentity * node)
+disconnectFromPeer (const GNUNET_PeerIdentity * node)
 {
   BufferEntry *be;
 
   ENTRY ();
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   be = lookForHost (node);
   if (be != NULL)
     {
 #if DEBUG_CONNECTION
-      EncName enc;
+      GNUNET_EncName enc;
 
       IF_GELOG (ectx,
                 GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
-                hash2enc (&node->hashPubKey, &enc));
+                GNUNET_hash_to_enc (&node->hashPubKey, &enc));
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
               "Closing connection to `%s' as requested by application.\n",
@@ -4024,10 +4060,11 @@
 #endif
       /* do not try to reconnect any time soon! */
       identity->blacklistHost (&be->session.sender,
-                               SECONDS_BLACKLIST_AFTER_DISCONNECT, YES);
+                               SECONDS_BLACKLIST_AFTER_DISCONNECT,
+                               GNUNET_YES);
       shutdownConnection (be);
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
 }
 
@@ -4037,20 +4074,20 @@
  *
  * @param callback the method to call for each
  *        P2P message part that is transmitted
- * @return OK on success, SYSERR if there is a problem
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there is a problem
  */
 int
 registerSendNotify (MessagePartHandler callback)
 {
   if (callback == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   ENTRY ();
-  MUTEX_LOCK (lock);
-  GROW (rsns, rsnSize, rsnSize + 1);
+  GNUNET_mutex_lock (lock);
+  GNUNET_array_grow (rsns, rsnSize, rsnSize + 1);
   rsns[rsnSize - 1] = callback;
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -4059,7 +4096,7 @@
  *
  * @param callback the method to call for each
  *        P2P message part that is transmitted
- * @return OK on success, SYSERR if there is a problem
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there is a problem
  */
 int
 unregisterSendNotify (MessagePartHandler callback)
@@ -4067,29 +4104,29 @@
   int i;
 
   if (callback == NULL)
-    return OK;
+    return GNUNET_OK;
   ENTRY ();
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < rsnSize; i++)
     {
       if (rsns[i] == callback)
         {
           rsns[i] = rsns[rsnSize - 1];
-          GROW (rsns, rsnSize, rsnSize - 1);
-          MUTEX_UNLOCK (lock);
-          return OK;
+          GNUNET_array_grow (rsns, rsnSize, rsnSize - 1);
+          GNUNET_mutex_unlock (lock);
+          return GNUNET_OK;
         }
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 
 
 /**
  * Verify that the given session handle is not in use.
- * @return OK if that is true, SYSERR if not.
+ * @return GNUNET_OK if that is true, GNUNET_SYSERR if not.
  */
 int
 assertUnused (TSession * tsession)
@@ -4098,7 +4135,7 @@
   BufferEntry *root;
 
   ENTRY ();
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < CONNECTION_MAX_HOSTS_; i++)
     {
       root = CONNECTION_buffer_[i];
@@ -4107,27 +4144,27 @@
           if (root->session.tsession == tsession)
             {
               GE_BREAK (ectx, 0);
-              MUTEX_UNLOCK (lock);
+              GNUNET_mutex_unlock (lock);
               EXIT ();
-              return SYSERR;
+              return GNUNET_SYSERR;
             }
           root = root->overflowChain;
         }
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   EXIT ();
-  return OK;
+  return GNUNET_OK;
 }
 
 
 void __attribute__ ((constructor)) gnunet_connection_ltdl_init ()
 {
-  lock = MUTEX_CREATE (YES);
+  lock = GNUNET_mutex_create (GNUNET_YES);
 }
 
 void __attribute__ ((destructor)) gnunet_connection_ltdl_fini ()
 {
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
 }
 
 

Modified: GNUnet/src/server/connection.h
===================================================================
--- GNUnet/src/server/connection.h      2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/server/connection.h      2007-11-23 11:51:54 UTC (rev 5742)
@@ -37,17 +37,17 @@
  * decrypting the packet.  It provides a timestamp and sequence
  * number (to guard against replay attacks).  The header is followed
  * by the 'data' which contains a sequence of GNUnet p2p messages,
- * each with its own MESSAGE_HEADER.
+ * each with its own GNUNET_MessageHeader.
  */
 typedef struct
 {
-  /* hash of the plaintext, used to verify message integrity;
+  /* GNUNET_hash of the plaintext, used to verify message integrity;
      ALSO used as the IV for the symmetric cipher! */
-  HashCode512 hash;
+  GNUNET_HashCode hash;
   /* sequence number, in network byte order, 0 for plaintext messages! */
   unsigned int sequenceNumber;
   /* timestamp  (network byte order), 0 for plaintext messages! */
-  TIME_T timeStamp;
+  GNUNET_Int32Time timeStamp;
   /* desired bandwidth, 0 for plaintext messages! */
   unsigned int bandwidth;
 } P2P_PACKET_HEADER;            /* 76 bytes */
@@ -59,7 +59,8 @@
  */
 void initConnection (struct GE_Context *ectx,
                      struct GC_Configuration *cfg,
-                     struct LoadMonitor *mon, struct CronManager *cron);
+                     struct GNUNET_LoadMonitor *mon,
+                     struct GNUNET_CronManager *cron);
 
 /**
  * Shutdown the connection module.
@@ -79,11 +80,11 @@
  * @param sender from which peer did we receive the SEQ message
  * @param msg the p2p message (the decrypted message is stored here, too!)
  * @param size the size of the message
- * @return YES if the message was encrypted,
- *         NO if it was in plaintext,
- *         SYSERR if it was malformed
+ * @return GNUNET_YES if the message was encrypted,
+ *         GNUNET_NO if it was in plaintext,
+ *         GNUNET_SYSERR if it was malformed
  */
-int checkHeader (const PeerIdentity * sender,
+int checkHeader (const GNUNET_PeerIdentity * sender,
                  P2P_PACKET_HEADER * msg, unsigned short size);
 
 /**
@@ -97,7 +98,8 @@
  * @param tsession the transport session that is for grabs
  * @param sender the identity of the other node
  */
-void considerTakeover (const PeerIdentity * sender, TSession * tsession);
+void considerTakeover (const GNUNET_PeerIdentity * sender,
+                       TSession * tsession);
 
 /* ***************** CORE API methods ************* */
 
@@ -117,14 +119,14 @@
  *
  * @param session the transport session
  * @param msg the message to transmit, should contain MESSAGE_HEADERs
- * @return OK on success, SYSERR on failure
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
 int sendPlaintext (TSession * tsession, const char *msg, unsigned int size);
 
 /**
  * Compute the hashtable index of a host id.
  */
-unsigned int computeIndex (const PeerIdentity * hostId);
+unsigned int computeIndex (const GNUNET_PeerIdentity * hostId);
 
 /**
  * Register a callback method that should be invoked whenever a
@@ -144,14 +146,14 @@
  *   the message, padding is the number of bytes left in that buffer.
  *   The callback method must return the number of bytes written to
  *   that buffer (must be a positive number).
- * @return OK if the handler was registered, SYSERR on error
+ * @return GNUNET_OK if the handler was registered, GNUNET_SYSERR on error
  */
 int registerSendCallback (const unsigned int minimumPadding,
                           BufferFillCallback callback);
 
 /**
  * Unregister a handler that was registered with registerSendCallback.
- * @return OK if the handler was removed, SYSERR on error
+ * @return GNUNET_OK if the handler was removed, GNUNET_SYSERR on error
  */
 int unregisterSendCallback (const unsigned int minimumPadding,
                             BufferFillCallback callback);
@@ -166,7 +168,7 @@
  * @param importance how important is the message?
  * @param maxdelay how long can the message wait?
  */
-void unicastCallback (const PeerIdentity * hostId,
+void unicastCallback (const GNUNET_PeerIdentity * hostId,
                       BuildMessageCallback callback,
                       void *closure,
                       unsigned short len,
@@ -180,14 +182,14 @@
  * @param importance how important is the message?
  * @param maxdelay how long can the message be delayed?
  */
-void unicast (const PeerIdentity * receiver,
-              const MESSAGE_HEADER * msg,
+void unicast (const GNUNET_PeerIdentity * receiver,
+              const GNUNET_MessageHeader * msg,
               unsigned int importance, unsigned int maxdelay);
 
 /**
  * Return a pointer to the lock of the connection module.
  */
-struct MUTEX *getConnectionModuleLock (void);
+struct GNUNET_Mutex *getConnectionModuleLock (void);
 
 
 /* ******************** traffic management ********** */
@@ -196,15 +198,16 @@
  * How many bpm did we assign this peer (how much traffic
  * may the given peer send to us per minute?)
  */
-int getBandwidthAssignedTo (const PeerIdentity * hostId,
-                            unsigned int *bpm, cron_t * last_seen);
+int getBandwidthAssignedTo (const GNUNET_PeerIdentity * hostId,
+                            unsigned int *bpm, GNUNET_CronTime * last_seen);
 
 /**
  * Increase the preference for traffic from some other peer.
  * @param node the identity of the other peer
  * @param preference how much should the traffic preference be increased?
  */
-void updateTrafficPreference (const PeerIdentity * node, double preference);
+void updateTrafficPreference (const GNUNET_PeerIdentity * node,
+                              double preference);
 
 
 /**
@@ -213,7 +216,7 @@
  *
  * @param peer  the peer to disconnect
  */
-void disconnectFromPeer (const PeerIdentity * node);
+void disconnectFromPeer (const GNUNET_PeerIdentity * node);
 
 
 /**
@@ -223,11 +226,12 @@
  *
  * @param key the sessionkey,
  * @param peer the other peer,
- * @param forSending NO if it is the key for receiving,
- *                   YES if it is the key for sending
+ * @param forSending GNUNET_NO if it is the key for receiving,
+ *                   GNUNET_YES if it is the key for sending
  */
-void assignSessionKey (const SESSIONKEY * key,
-                       const PeerIdentity * peer, TIME_T age, int forSending);
+void assignSessionKey (const GNUNET_AES_SessionKey * key,
+                       const GNUNET_PeerIdentity * peer, GNUNET_Int32Time age,
+                       int forSending);
 
 /**
  * Obtain the session key used for traffic from or to a given peer.
@@ -235,13 +239,14 @@
  * @param key the sessionkey (set)
  * @param age the age of the key (set)
  * @param peer the other peer,
- * @param forSending NO if it is the key for receiving,
- *                   YES if it is the key for sending
- * @return SYSERR if no sessionkey is known to the core,
- *         OK if the sessionkey was set.
+ * @param forSending GNUNET_NO if it is the key for receiving,
+ *                   GNUNET_YES if it is the key for sending
+ * @return GNUNET_SYSERR if no sessionkey is known to the core,
+ *         GNUNET_OK if the sessionkey was set.
  */
-int getCurrentSessionKey (const PeerIdentity * peer,
-                          SESSIONKEY * key, TIME_T * age, int forSending);
+int getCurrentSessionKey (const GNUNET_PeerIdentity * peer,
+                          GNUNET_AES_SessionKey * key, GNUNET_Int32Time * age,
+                          int forSending);
 
 
 /**
@@ -261,9 +266,10 @@
  * Get the time of the last encrypted message that was received
  * from the given peer.
  * @param time updated with the time
- * @return SYSERR if we are not connected to the peer at the moment
+ * @return GNUNET_SYSERR if we are not connected to the peer at the moment
  */
-int getLastActivityOf (const PeerIdentity * peer, cron_t * time);
+int getLastActivityOf (const GNUNET_PeerIdentity * peer,
+                       GNUNET_CronTime * time);
 
 
 /**
@@ -271,7 +277,7 @@
  *
  * @param peer the other peer,
  */
-void confirmSessionUp (const PeerIdentity * peer);
+void confirmSessionUp (const GNUNET_PeerIdentity * peer);
 
 
 /**
@@ -280,7 +286,7 @@
  *
  * @param callback the method to call for each
  *        P2P message part that is transmitted
- * @return OK on success, SYSERR if there is a problem
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there is a problem
  */
 int registerSendNotify (MessagePartHandler callback);
 
@@ -290,13 +296,13 @@
  *
  * @param callback the method to call for each
  *        P2P message part that is transmitted
- * @return OK on success, SYSERR if there is a problem
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there is a problem
  */
 int unregisterSendNotify (MessagePartHandler callback);
 
 /**
  * Verify that the given session handle is not in use.
- * @return OK if that is true, SYSERR if not.
+ * @return GNUNET_OK if that is true, GNUNET_SYSERR if not.
  */
 int assertUnused (TSession * tsession);
 

Modified: GNUnet/src/server/core.c
===================================================================
--- GNUnet/src/server/core.c    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/server/core.c    2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,7 +32,7 @@
 #include "tcpserver.h"
 #include "core.h"
 
-#define DEBUG_CORE NO
+#define DEBUG_CORE GNUNET_NO
 
 /**
  * Linked list of loaded protocols (for clean shutdown).
@@ -42,7 +42,7 @@
   /**
    * Pointer to the library (as returned by dlopen).
    */
-  struct PluginHandle *library;
+  struct GNUNET_PluginHandle *library;
 
   /**
    * Textual name of the library ("libgnunet_afs_protocol").
@@ -50,7 +50,7 @@
   char *dsoName;
 
   /**
-   * YES or NO: is the application initialized at this point?
+   * GNUNET_YES or GNUNET_NO: is the application initialized at this point?
    */
   int applicationInitialized;
 
@@ -85,13 +85,13 @@
 /**
  * The identity of THIS node.
  */
-static PeerIdentity myIdentity;
+static GNUNET_PeerIdentity myIdentity;
 
 static Identity_ServiceAPI *identity;
 
 /**
  * Load the application module named "pos".
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
 loadApplicationModule (const char *rpos)
@@ -100,76 +100,77 @@
   ShutdownList *nxt;
   ShutdownList *spos;
   ApplicationInitMethod mptr;
-  struct PluginHandle *library;
+  struct GNUNET_PluginHandle *library;
   char *name;
   char *pos;
 
   pos = NULL;
   if (-1 == GC_get_configuration_value_string (applicationCore.cfg,
                                                "MODULES", rpos, rpos, &pos))
-    return SYSERR;
+    return GNUNET_SYSERR;
   GE_ASSERT (applicationCore.ectx, pos != NULL);
-  name = MALLOC (strlen (pos) + strlen ("module_") + 1);
+  name = GNUNET_malloc (strlen (pos) + strlen ("module_") + 1);
   strcpy (name, "module_");
   strcat (name, pos);
-  FREE (pos);
+  GNUNET_free (pos);
 
   nxt = shutdownList;
   while (nxt != NULL)
     {
       if (0 == strcmp (name, nxt->dsoName))
         {
-          if (nxt->applicationInitialized == YES)
+          if (nxt->applicationInitialized == GNUNET_YES)
             {
               GE_LOG (applicationCore.ectx,
                       GE_WARNING | GE_DEVELOPER | GE_BULK,
                       _("Application module `%s' already initialized!\n"),
                       name);
-              FREE (name);
-              return SYSERR;
+              GNUNET_free (name);
+              return GNUNET_SYSERR;
             }
           else
             {
-              mptr = os_plugin_resolve_function (nxt->library,
-                                                 "initialize_", YES);
+              mptr = GNUNET_plugin_resolve_function (nxt->library,
+                                                     "initialize_",
+                                                     GNUNET_YES);
               if (mptr == NULL)
                 {
-                  FREE (name);
-                  return SYSERR;
+                  GNUNET_free (name);
+                  return GNUNET_SYSERR;
                 }
               ok = mptr (&applicationCore);
-              if (ok == OK)
-                nxt->applicationInitialized = YES;
-              FREE (name);
+              if (ok == GNUNET_OK)
+                nxt->applicationInitialized = GNUNET_YES;
+              GNUNET_free (name);
               return ok;
             }
         }
       nxt = nxt->next;
     }
 
-  library = os_plugin_load (applicationCore.ectx, DSO_PREFIX, name);
+  library = GNUNET_plugin_load (applicationCore.ectx, DSO_PREFIX, name);
   if (library == NULL)
     {
-      FREE (name);
-      return SYSERR;
+      GNUNET_free (name);
+      return GNUNET_SYSERR;
     }
-  mptr = os_plugin_resolve_function (library, "initialize_", YES);
+  mptr = GNUNET_plugin_resolve_function (library, "initialize_", GNUNET_YES);
   if (mptr == NULL)
     {
-      os_plugin_unload (library);
-      FREE (name);
-      return SYSERR;
+      GNUNET_plugin_unload (library);
+      GNUNET_free (name);
+      return GNUNET_SYSERR;
     }
-  nxt = MALLOC (sizeof (ShutdownList));
+  nxt = GNUNET_malloc (sizeof (ShutdownList));
   nxt->next = shutdownList;
   nxt->dsoName = name;
   nxt->library = library;
-  nxt->applicationInitialized = YES;
+  nxt->applicationInitialized = GNUNET_YES;
   nxt->serviceCount = 0;
   nxt->servicePTR = NULL;
   shutdownList = nxt;
   ok = mptr (&applicationCore);
-  if (OK != ok)
+  if (GNUNET_OK != ok)
     {
       /* undo loading */
       GE_LOG (applicationCore.ectx,
@@ -178,7 +179,7 @@
               name, __FILE__, __LINE__);
       /* Note: we cannot assert that shutdownList == nxt here,
          so we have to traverse the list again! */
-      nxt->applicationInitialized = NO;
+      nxt->applicationInitialized = GNUNET_NO;
       if (shutdownList == nxt)
         {
           spos = NULL;
@@ -200,9 +201,9 @@
         shutdownList = nxt->next;
       else
         spos->next = nxt->next;
-      os_plugin_unload (library);
-      FREE (name);
-      FREE (nxt);
+      GNUNET_plugin_unload (library);
+      GNUNET_free (name);
+      GNUNET_free (nxt);
     }
   return ok;
 }
@@ -224,30 +225,30 @@
       GE_LOG (applicationCore.ectx,
               GE_ERROR | GE_USER | GE_BULK | GE_DEVELOPER,
               _("Could not shutdown `%s': application not loaded\n"), name);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
-  if (pos->applicationInitialized != YES)
+  if (pos->applicationInitialized != GNUNET_YES)
     {
       GE_LOG (applicationCore.ectx,
               GE_WARNING | GE_USER | GE_BULK | GE_DEVELOPER,
               _("Could not shutdown application `%s': not initialized\n"),
               name);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  mptr = os_plugin_resolve_function (pos->library, "done_", YES);
+  mptr = GNUNET_plugin_resolve_function (pos->library, "done_", GNUNET_YES);
   if (mptr == NULL)
     {
       GE_LOG (applicationCore.ectx,
               GE_ERROR | GE_USER | GE_DEVELOPER | GE_BULK,
               _("Could not find '%s%s' method in library `%s'.\n"),
               "done_", pos->dsoName, pos->dsoName);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   mptr ();
-  pos->applicationInitialized = NO;
+  pos->applicationInitialized = GNUNET_NO;
   if (pos->serviceCount > 0)
-    return OK;
+    return GNUNET_OK;
 
   /* compute prev! */
   if (pos == shutdownList)
@@ -260,14 +261,14 @@
       while (prev->next != pos)
         prev = prev->next;
     }
-  os_plugin_unload (pos->library);
+  GNUNET_plugin_unload (pos->library);
   if (prev == NULL)
     shutdownList = pos->next;
   else
     prev->next = pos->next;
-  FREE (pos->dsoName);
-  FREE (pos);
-  return OK;
+  GNUNET_free (pos->dsoName);
+  GNUNET_free (pos);
+  return GNUNET_OK;
 }
 
 void *
@@ -286,7 +287,7 @@
                                                "MODULES", rpos, rpos, &pos))
     return NULL;
   GE_ASSERT (applicationCore.ectx, pos != NULL);
-  name = MALLOC (strlen (pos) + strlen ("module_") + 1);
+  name = GNUNET_malloc (strlen (pos) + strlen ("module_") + 1);
   strcpy (name, "module_");
   strcat (name, pos);
 
@@ -299,51 +300,51 @@
             {
               if (nxt->servicePTR != NULL)
                 nxt->serviceCount++;
-              FREE (name);
-              FREE (pos);
+              GNUNET_free (name);
+              GNUNET_free (pos);
               return nxt->servicePTR;
             }
           else
             {
-              mptr = os_plugin_resolve_function (nxt->library,
-                                                 "provide_", YES);
+              mptr = GNUNET_plugin_resolve_function (nxt->library,
+                                                     "provide_", GNUNET_YES);
               if (mptr == NULL)
                 {
-                  FREE (name);
-                  FREE (pos);
+                  GNUNET_free (name);
+                  GNUNET_free (pos);
                   return NULL;
                 }
               nxt->servicePTR = mptr (&applicationCore);
               if (nxt->servicePTR != NULL)
                 nxt->serviceCount++;
-              FREE (name);
-              FREE (pos);
+              GNUNET_free (name);
+              GNUNET_free (pos);
               return nxt->servicePTR;
             }
         }
       nxt = nxt->next;
     }
 
-  library = os_plugin_load (applicationCore.ectx, DSO_PREFIX, name);
+  library = GNUNET_plugin_load (applicationCore.ectx, DSO_PREFIX, name);
   if (library == NULL)
     {
-      FREE (name);
-      FREE (pos);
+      GNUNET_free (name);
+      GNUNET_free (pos);
       return NULL;
     }
-  mptr = os_plugin_resolve_function (library, "provide_", YES);
+  mptr = GNUNET_plugin_resolve_function (library, "provide_", GNUNET_YES);
   if (mptr == NULL)
     {
-      os_plugin_unload (library);
-      FREE (name);
-      FREE (pos);
+      GNUNET_plugin_unload (library);
+      GNUNET_free (name);
+      GNUNET_free (pos);
       return NULL;
     }
-  nxt = MALLOC (sizeof (ShutdownList));
+  nxt = GNUNET_malloc (sizeof (ShutdownList));
   nxt->next = shutdownList;
   nxt->dsoName = name;
   nxt->library = library;
-  nxt->applicationInitialized = NO;
+  nxt->applicationInitialized = GNUNET_NO;
   nxt->serviceCount = 1;
   nxt->servicePTR = NULL;
   shutdownList = nxt;
@@ -361,7 +362,7 @@
               "Failed to load service `%s'\n", pos);
       nxt->serviceCount = 0;
     }
-  FREE (pos);
+  GNUNET_free (pos);
   return api;
 }
 
@@ -373,7 +374,7 @@
   ApplicationDoneMethod mptr;
 
   if (service == NULL)
-    return OK;
+    return GNUNET_OK;
   prev = NULL;
   pos = shutdownList;
   while ((pos != NULL) && (pos->servicePTR != service))
@@ -384,25 +385,26 @@
       GE_LOG (applicationCore.ectx,
               GE_BULK | GE_DEVELOPER | GE_ERROR,
               _("Could not release %p: service not loaded\n"), service);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (pos->serviceCount > 1)
     {
       pos->serviceCount--;
-      return OK;                /* service still in use elsewhere! */
+      return GNUNET_OK;         /* service still in use elsewhere! */
     }
   GE_LOG (applicationCore.ectx,
           GE_INFO | GE_USER | GE_REQUEST,
           "Unloading service `%s'.\n", pos->dsoName);
-  mptr = os_plugin_resolve_function (pos->library, "release_", YES);
+  mptr =
+    GNUNET_plugin_resolve_function (pos->library, "release_", GNUNET_YES);
   if (mptr == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   mptr ();
   pos->serviceCount--;
   pos->servicePTR = NULL;
 
-  if (pos->applicationInitialized == YES)
-    return OK;                  /* protocol still in use! */
+  if (pos->applicationInitialized == GNUNET_YES)
+    return GNUNET_OK;           /* protocol still in use! */
   /* compute prev */
   if (pos == shutdownList)
     {
@@ -418,10 +420,10 @@
     shutdownList = pos->next;
   else
     prev->next = pos->next;
-  os_plugin_unload (pos->library);
-  FREE (pos->dsoName);
-  FREE (pos);
-  return OK;
+  GNUNET_plugin_unload (pos->library);
+  GNUNET_free (pos->dsoName);
+  GNUNET_free (pos);
+  return GNUNET_OK;
 }
 
 int
@@ -432,14 +434,14 @@
   char *pos;
   int ok;
 
-  ok = OK;
+  ok = GNUNET_OK;
   dso = NULL;
   if (-1 == GC_get_configuration_value_string (applicationCore.cfg,
                                                "GNUNETD",
                                                "APPLICATIONS",
                                                "advertising fs getoption stats 
traffic",
                                                &dso))
-    return SYSERR;
+    return GNUNET_SYSERR;
   GE_ASSERT (applicationCore.ectx, dso != NULL);
   next = dso;
   do
@@ -463,12 +465,12 @@
           GE_LOG (applicationCore.ectx,
                   GE_INFO | GE_USER | GE_BULK,
                   "Loading application `%s'\n", pos);
-          if (OK != loadApplicationModule (pos))
-            ok = SYSERR;
+          if (GNUNET_OK != loadApplicationModule (pos))
+            ok = GNUNET_SYSERR;
         }
     }
   while (next != NULL);
-  FREE (dso);
+  GNUNET_free (dso);
   return ok;
 }
 
@@ -479,23 +481,23 @@
   ShutdownList *nxt;
   int ok;
 
-  ok = OK;
+  ok = GNUNET_OK;
   pos = shutdownList;
   while (pos != NULL)
     {
       nxt = pos->next;
-      if ((pos->applicationInitialized == YES) &&
-          (OK != unloadApplicationModule (pos->dsoName)))
+      if ((pos->applicationInitialized == GNUNET_YES) &&
+          (GNUNET_OK != unloadApplicationModule (pos->dsoName)))
         {
           GE_LOG (applicationCore.ectx,
                   GE_ERROR | GE_DEVELOPER | GE_BULK,
                   _("Could not properly shutdown application `%s'.\n"),
                   pos->dsoName);
-          ok = SYSERR;
+          ok = GNUNET_SYSERR;
         }
       pos = nxt;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -504,7 +506,7 @@
 int
 initCore (struct GE_Context *ectx,
           struct GC_Configuration *cfg,
-          struct CronManager *cron, struct LoadMonitor *monitor)
+          struct GNUNET_CronManager *cron, struct GNUNET_LoadMonitor *monitor)
 {
   applicationCore.ectx = ectx;
   applicationCore.cfg = cfg;
@@ -561,16 +563,16 @@
 
   identity = requestService ("identity");
   if (identity == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   identity->getPeerIdentity (identity->getPublicPrivateKey (), &myIdentity);
   applicationCore.myIdentity = &myIdentity;     /* core.c */
-  if (initTCPServer (ectx, cfg) != OK)
+  if (initTCPServer (ectx, cfg) != GNUNET_OK)
     {
       releaseService (identity);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   initHandler (ectx);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -600,17 +602,18 @@
       change = 0;
       while (pos != NULL)
         {
-          if ((pos->applicationInitialized == NO) && (pos->serviceCount == 0))
+          if ((pos->applicationInitialized == GNUNET_NO)
+              && (pos->serviceCount == 0))
             {
               change = 1;
-              os_plugin_unload (pos->library);
+              GNUNET_plugin_unload (pos->library);
               nxt = pos->next;
               if (prev == NULL)
                 shutdownList = nxt;
               else
                 prev->next = nxt;
-              FREE (pos->dsoName);
-              FREE (pos);
+              GNUNET_free (pos->dsoName);
+              GNUNET_free (pos);
               pos = nxt;
             }
           else

Modified: GNUnet/src/server/gnunet-peer-info.c
===================================================================
--- GNUnet/src/server/gnunet-peer-info.c        2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/server/gnunet-peer-info.c        2007-11-23 11:51:54 UTC (rev 
5742)
@@ -31,8 +31,6 @@
 #include "gnunet_transport_service.h"
 #include "gnunet_identity_service.h"
 #include "gnunet_core.h"
-#include "gnunet_util_boot.h"
-#include "gnunet_util_cron.h"
 #include "core.h"
 
 static Transport_ServiceAPI *transport;
@@ -43,21 +41,21 @@
 
 static char *cfgFilename = DEFAULT_DAEMON_CONFIG_FILE;
 
-static int no_resolve = NO;
+static int no_resolve = GNUNET_NO;
 
 /**
  * All gnunet-peer-info command line options
  */
-static struct CommandLineOption gnunetpeerinfoOptions[] = {
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Print information about GNUnet 
peers.")),    /* -h */
-  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+static struct GNUNET_CommandLineOption gnunetpeerinfoOptions[] = {
+  GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),   /* -c */
+  GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Print information about 
GNUnet peers.")),     /* -h */
+  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'n', "numeric", NULL,
    gettext_noop ("don't resolve host names"),
-   0, &gnunet_getopt_configure_set_one, &no_resolve},
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_END,
+   0, &GNUNET_getopt_configure_set_one, &no_resolve},
+  GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION), /* -v */
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 #if HAVE_ADNS
@@ -65,68 +63,70 @@
  * Prepass just to resolve DNS entries.
  */
 static int
-resolveHostInfo (const PeerIdentity * id,
+resolveHostInfo (const GNUNET_PeerIdentity * id,
                  const unsigned short proto, int verified, void *data)
 {
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
   void *addr;
   unsigned int addr_len;
   char *info;
   int have_addr;
 
-  if (GNUNET_SHUTDOWN_TEST () == YES)
-    return SYSERR;
-  hello = identity->identity2Hello (id, proto, NO);
+  if (GNUNET_shutdown_test () == GNUNET_YES)
+    return GNUNET_SYSERR;
+  hello = identity->identity2Hello (id, proto, GNUNET_NO);
   if (NULL == hello)
-    return OK;
+    return GNUNET_OK;
   addr = NULL;
   addr_len = 0;
   have_addr = transport->helloToAddress (hello, &addr, &addr_len);
-  FREE (hello);
-  if (have_addr == OK)
+  GNUNET_free (hello);
+  if (have_addr == GNUNET_OK)
     {
-      info = network_get_ip_as_string (addr, addr_len, !no_resolve);
-      FREE (addr);
+      info = GNUNET_get_ip_as_string (addr, addr_len, !no_resolve);
+      GNUNET_free (addr);
       addr = NULL;
-      FREENONNULL (info);
+      GNUNET_free_non_null (info);
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 #endif
 
 /**
  * Print information about the peer.
- * Currently prints the PeerIdentity, trust and the IP.
+ * Currently prints the GNUNET_PeerIdentity, trust and the IP.
  * Could of course do more (e.g. resolve via DNS).
  */
 static int
-printHostInfo (const PeerIdentity * id,
+printHostInfo (const GNUNET_PeerIdentity * id,
                const unsigned short proto, int verified, void *data)
 {
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
   void *addr;
   unsigned int addr_len;
   char *info;
   int have_addr;
-  EncName enc;
+  GNUNET_EncName enc;
 
-  if (GNUNET_SHUTDOWN_TEST () == YES)
-    return SYSERR;
-  hash2enc (&id->hashPubKey, &enc);
-  hello = identity->identity2Hello (id, proto, NO);
+  if (GNUNET_shutdown_test () == GNUNET_YES)
+    return GNUNET_SYSERR;
+  GNUNET_hash_to_enc (&id->hashPubKey, &enc);
+  hello = identity->identity2Hello (id, proto, GNUNET_NO);
   if (NULL == hello)
     {
       GE_LOG (ectx,
               GE_WARNING | GE_BULK | GE_USER,
               _("Could not get address of peer `%s'.\n"), &enc);
-      return OK;
+      return GNUNET_OK;
     }
-  if (SYSERR == verifySig (&hello->senderIdentity,
-                           P2P_hello_MESSAGE_size (hello) -
-                           sizeof (Signature) - sizeof (PublicKey) -
-                           sizeof (MESSAGE_HEADER), &hello->signature,
-                           &hello->publicKey))
+  if (GNUNET_SYSERR == GNUNET_RSA_verify (&hello->senderIdentity,
+                                          GNUNET_sizeof_hello (hello) -
+                                          sizeof (GNUNET_RSA_Signature) -
+                                          sizeof (GNUNET_RSA_PublicKey) -
+                                          sizeof (GNUNET_MessageHeader),
+                                          &hello->signature,
+                                          &hello->publicKey))
     {
       GE_LOG (ectx,
               GE_WARNING | GE_BULK | GE_USER,
@@ -135,15 +135,15 @@
   addr = NULL;
   addr_len = 0;
   have_addr = transport->helloToAddress (hello, &addr, &addr_len);
-  FREE (hello);
-  if (have_addr != OK)
+  GNUNET_free (hello);
+  if (have_addr != GNUNET_OK)
     {
-      info = STRDUP ("NAT");    /* most likely */
+      info = GNUNET_strdup ("NAT");     /* most likely */
     }
   else
     {
-      info = network_get_ip_as_string (addr, addr_len, !no_resolve);
-      FREE (addr);
+      info = GNUNET_get_ip_as_string (addr, addr_len, !no_resolve);
+      GNUNET_free (addr);
       addr = NULL;
     }
   if (info == NULL)
@@ -153,19 +153,19 @@
               _("Could not get address of peer `%s'.\n"), &enc);
       printf (_("Peer `%s' with trust %8u\n"),
               (char *) &enc, identity->getHostTrust (id));
-      return OK;
+      return GNUNET_OK;
     }
   printf (_("Peer `%s' with trust %8u and address `%s'\n"),
           (char *) &enc, identity->getHostTrust (id), info);
-  FREE (info);
-  return OK;
+  GNUNET_free (info);
+  return GNUNET_OK;
 }
 
 int
 main (int argc, char *const *argv)
 {
   struct GC_Configuration *cfg;
-  struct CronManager *cron;
+  struct GNUNET_CronManager *cron;
   int ret;
 
   ret = GNUNET_init (argc,
@@ -186,13 +186,13 @@
   initCore (ectx, cfg, cron, NULL);
   identity = requestService ("identity");
   transport = requestService ("transport");
-  if (no_resolve != YES)
+  if (no_resolve != GNUNET_YES)
     {
 #if HAVE_ADNS
       identity->forEachHost (0, /* no timeout */
                              &resolveHostInfo, NULL);
       /* give GNU ADNS time to resolve... */
-      PTHREAD_SLEEP (2 * cronSECONDS);
+      GNUNET_thread_sleep (2 * GNUNET_CRON_SECONDS);
 #endif
     }
   identity->forEachHost (0,     /* no timeout */
@@ -200,7 +200,7 @@
   releaseService (identity);
   releaseService (transport);
   doneCore ();
-  cron_destroy (cron);
+  GNUNET_cron_destroy (cron);
   GNUNET_fini (ectx, cfg);
   return 0;
 }

Modified: GNUnet/src/server/gnunet-transport-check.c
===================================================================
--- GNUnet/src/server/gnunet-transport-check.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/server/gnunet-transport-check.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -29,7 +29,6 @@
 
 #include "platform.h"
 #include "gnunet_util.h"
-#include "gnunet_util_boot.h"
 #include "gnunet_directories.h"
 #include "gnunet_protocols.h"
 #include "gnunet_transport_service.h"
@@ -41,9 +40,9 @@
 #include "handler.h"
 #include "startup.h"
 
-#define DEBUG_TRANSPORT_CHECK NO
+#define DEBUG_TRANSPORT_CHECK GNUNET_NO
 
-static struct SEMAPHORE *sem;
+static struct GNUNET_Semaphore *sem;
 
 static int terminate;
 
@@ -69,29 +68,29 @@
 
 static struct GE_Context *ectx;
 
-static struct CronManager *cron;
+static struct GNUNET_CronManager *cron;
 
 static char *cfgFilename = DEFAULT_DAEMON_CONFIG_FILE;
 
 static void
 semUp (void *arg)
 {
-  struct SEMAPHORE *sem = arg;
+  struct GNUNET_Semaphore *sem = arg;
 
-  terminate = YES;
-  SEMAPHORE_UP (sem);
+  terminate = GNUNET_YES;
+  GNUNET_semaphore_up (sem);
 }
 
 static int
-noiseHandler (const PeerIdentity * peer,
-              const MESSAGE_HEADER * msg, TSession * s)
+noiseHandler (const GNUNET_PeerIdentity * peer,
+              const GNUNET_MessageHeader * msg, TSession * s)
 {
   if ((ntohs (msg->size) ==
-       sizeof (MESSAGE_HEADER) + expectedSize) &&
+       sizeof (GNUNET_MessageHeader) + expectedSize) &&
       (0 == memcmp (expectedValue, &msg[1], expectedSize)))
-    ok = YES;
-  SEMAPHORE_UP (sem);
-  return OK;
+    ok = GNUNET_YES;
+  GNUNET_semaphore_up (sem);
+  return GNUNET_OK;
 }
 
 /**
@@ -101,37 +100,37 @@
 testTAPI (TransportAPI * tapi, void *ctx)
 {
   int *res = ctx;
-  P2P_hello_MESSAGE *helo;
+  GNUNET_MessageHello *helo;
   TSession *tsession;
   unsigned long long repeat;
   unsigned long long total;
-  cron_t start;
-  cron_t end;
-  MESSAGE_HEADER *noise;
+  GNUNET_CronTime start;
+  GNUNET_CronTime end;
+  GNUNET_MessageHeader *noise;
   int ret;
 
   GE_ASSERT (ectx, tapi != NULL);
   if (tapi->protocolNumber == NAT_PROTOCOL_NUMBER)
     {
-      *res = OK;
+      *res = GNUNET_OK;
       return;                   /* NAT cannot be tested */
     }
   helo = tapi->createhello ();
   if (helo == NULL)
     {
       fprintf (stderr, _("`%s': Could not create hello.\n"), tapi->transName);
-      *res = SYSERR;
+      *res = GNUNET_SYSERR;
       return;
     }
   tsession = NULL;
-  if (OK != tapi->connect (helo, &tsession, NO))
+  if (GNUNET_OK != tapi->connect (helo, &tsession, GNUNET_NO))
     {
       fprintf (stderr, _("`%s': Could not connect.\n"), tapi->transName);
-      *res = SYSERR;
-      FREE (helo);
+      *res = GNUNET_SYSERR;
+      GNUNET_free (helo);
       return;
     }
-  FREE (helo);
+  GNUNET_free (helo);
   if (-1 == GC_get_configuration_value_number (cfg,
                                                "TRANSPORT-CHECK",
                                                "REPEAT",
@@ -139,87 +138,88 @@
                                                (unsigned long) -1,
                                                1, &repeat))
     {
-      *res = SYSERR;
+      *res = GNUNET_SYSERR;
       return;
     }
   total = repeat;
-  sem = SEMAPHORE_CREATE (0);
-  start = get_time ();
-  noise = MALLOC (expectedSize + sizeof (MESSAGE_HEADER));
+  sem = GNUNET_semaphore_create (0);
+  start = GNUNET_get_time ();
+  noise = GNUNET_malloc (expectedSize + sizeof (GNUNET_MessageHeader));
   noise->type = htons (P2P_PROTO_noise);
-  noise->size = htons (expectedSize + sizeof (MESSAGE_HEADER));
+  noise->size = htons (expectedSize + sizeof (GNUNET_MessageHeader));
   memcpy (&noise[1], expectedValue, expectedSize);
-  while ((repeat > 0) && (GNUNET_SHUTDOWN_TEST () == NO))
+  while ((repeat > 0) && (GNUNET_shutdown_test () == GNUNET_NO))
     {
       repeat--;
-      ok = NO;
-      ret = NO;
-      while (ret == NO)
+      ok = GNUNET_NO;
+      ret = GNUNET_NO;
+      while (ret == GNUNET_NO)
         ret = sendPlaintext (tsession, (char *) noise, ntohs (noise->size));
-      if (ret != OK)
+      if (ret != GNUNET_OK)
         {
           fprintf (stderr, _("`%s': Could not send.\n"), tapi->transName);
-          *res = SYSERR;
+          *res = GNUNET_SYSERR;
           tapi->disconnect (tsession);
-          SEMAPHORE_DESTROY (sem);
-          FREE (noise);
+          GNUNET_semaphore_destroy (sem);
+          GNUNET_free (noise);
           return;
         }
-      cron_add_job (cron, &semUp, timeout, 0, sem);
-      SEMAPHORE_DOWN (sem, YES);
-      cron_suspend (cron, NO);
-      cron_del_job (cron, &semUp, 0, sem);
-      cron_resume_jobs (cron, NO);
-      if (ok != YES)
+      GNUNET_cron_add_job (cron, &semUp, timeout, 0, sem);
+      GNUNET_semaphore_down (sem, GNUNET_YES);
+      GNUNET_cron_suspend_jobs (cron, GNUNET_NO);
+      GNUNET_cron_del_job (cron, &semUp, 0, sem);
+      GNUNET_cron_resume_jobs (cron, GNUNET_NO);
+      if (ok != GNUNET_YES)
         {
           FPRINTF (stderr,
                    _("`%s': Did not receive message within %llu ms.\n"),
                    tapi->transName, timeout);
-          *res = SYSERR;
+          *res = GNUNET_SYSERR;
           tapi->disconnect (tsession);
-          SEMAPHORE_DESTROY (sem);
-          FREE (noise);
+          GNUNET_semaphore_destroy (sem);
+          GNUNET_free (noise);
           return;
         }
     }
-  FREE (noise);
-  end = get_time ();
-  if (OK != tapi->disconnect (tsession))
+  GNUNET_free (noise);
+  end = GNUNET_get_time ();
+  if (GNUNET_OK != tapi->disconnect (tsession))
     {
       fprintf (stderr, _("`%s': Could not disconnect.\n"), tapi->transName);
-      *res = SYSERR;
-      SEMAPHORE_DESTROY (sem);
+      *res = GNUNET_SYSERR;
+      GNUNET_semaphore_destroy (sem);
       return;
     }
-  SEMAPHORE_DESTROY (sem);
+  GNUNET_semaphore_destroy (sem);
   printf (_
           ("`%s' transport OK.  It took %ums to transmit %llu messages of %llu 
bytes each.\n"),
-          tapi->transName, (unsigned int) ((end - start) / cronMILLIS), total,
+          tapi->transName,
+          (unsigned int) ((end - start) / GNUNET_CRON_MILLISECONDS), total,
           expectedSize);
 }
 
 static void
 pingCallback (void *unused)
 {
-  ok = YES;
-  SEMAPHORE_UP (sem);
+  ok = GNUNET_YES;
+  GNUNET_semaphore_up (sem);
 }
 
 static void
-testPING (const P2P_hello_MESSAGE * xhello, void *arg)
+testPING (const GNUNET_MessageHello * xhello, void *arg)
 {
   int *stats = arg;
   TSession *tsession;
-  P2P_hello_MESSAGE *hello;
-  P2P_hello_MESSAGE *myHello;
-  MESSAGE_HEADER *ping;
+  GNUNET_MessageHello *hello;
+  GNUNET_MessageHello *myHello;
+  GNUNET_MessageHeader *ping;
   char *msg;
   int len;
-  PeerIdentity peer;
+  GNUNET_PeerIdentity peer;
   unsigned long long verbose;
 
   stats[0]++;                   /* one more seen */
-  if (NO == transport->isAvailable (ntohs (xhello->protocol)))
+  if (GNUNET_NO == transport->isAvailable (ntohs (xhello->protocol)))
     {
       GE_LOG (ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
@@ -243,21 +243,21 @@
       int have_addr;
 
       have_addr = transport->helloToAddress (xhello, &addr, &addr_len);
-      if (have_addr == NO)
+      if (have_addr == GNUNET_NO)
         {
-          str = STRDUP ("NAT"); /* most likely */
+          str = GNUNET_strdup ("NAT");  /* most likely */
         }
       else
         {
-          str = network_get_ip_as_string (addr, addr_len, YES);
-          FREE (addr);
+          str = GNUNET_get_ip_as_string (addr, addr_len, GNUNET_YES);
+          GNUNET_free (addr);
         }
       fprintf (stderr, _("\nContacting `%s'."), str);
-      FREE (str);
+      GNUNET_free (str);
     }
   else
     fprintf (stderr, ".");
-  hello = MALLOC (ntohs (xhello->header.size));
+  hello = GNUNET_malloc (ntohs (xhello->header.size));
   memcpy (hello, xhello, ntohs (xhello->header.size));
 
   myHello = transport->createhello (ntohs (xhello->protocol));
@@ -266,15 +266,15 @@
     myHello = transport->createhello (NAT_PROTOCOL_NUMBER);
   if (myHello == NULL)
     {
-      FREE (hello);
+      GNUNET_free (hello);
       return;
     }
   if (verbose > 0)
     fprintf (stderr, ".");
   tsession = NULL;
   peer = hello->senderIdentity;
-  tsession = transport->connect (hello, __FILE__, NO);
-  FREE (hello);
+  tsession = transport->connect (hello, __FILE__, GNUNET_NO);
+  GNUNET_free (hello);
   if (tsession == NULL)
     {
       fprintf (stderr, _(" Connection failed\n"));
@@ -289,91 +289,91 @@
   if (verbose > 0)
     fprintf (stderr, ".");
 
-  sem = SEMAPHORE_CREATE (0);
-  ping = pingpong->pingUser (&peer, &pingCallback, NULL, YES, rand ());
+  sem = GNUNET_semaphore_create (0);
+  ping = pingpong->pingUser (&peer, &pingCallback, NULL, GNUNET_YES, rand ());
   len = ntohs (ping->size) + ntohs (myHello->header.size);
-  msg = MALLOC (len);
+  msg = GNUNET_malloc (len);
   memcpy (msg, myHello, ntohs (myHello->header.size));
   memcpy (&msg[ntohs (myHello->header.size)], ping, ntohs (ping->size));
-  FREE (myHello);
-  FREE (ping);
+  GNUNET_free (myHello);
+  GNUNET_free (ping);
   /* send ping */
-  ok = NO;
-  if (OK != sendPlaintext (tsession, msg, len))
+  ok = GNUNET_NO;
+  if (GNUNET_OK != sendPlaintext (tsession, msg, len))
     {
       fprintf (stderr, "Send failed.\n");
-      FREE (msg);
+      GNUNET_free (msg);
       transport->disconnect (tsession, __FILE__);
       return;
     }
-  FREE (msg);
+  GNUNET_free (msg);
   if (verbose > 0)
     fprintf (stderr, ".");
   /* check: received pong? */
 #if DEBUG_TRANSPORT_CHECK
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER, "Waiting for PONG\n");
 #endif
-  terminate = NO;
-  cron_add_job (cron, &semUp, timeout, 5 * cronSECONDS, sem);
-  SEMAPHORE_DOWN (sem, YES);
+  terminate = GNUNET_NO;
+  GNUNET_cron_add_job (cron, &semUp, timeout, 5 * GNUNET_CRON_SECONDS, sem);
+  GNUNET_semaphore_down (sem, GNUNET_YES);
 
   if (verbose > 0)
     {
-      if (ok != YES)
+      if (ok != GNUNET_YES)
         FPRINTF (stderr, _("Timeout after %llums.\n"), timeout);
       else
         fprintf (stderr, _("OK!\n"));
     }
-  cron_suspend (cron, NO);
-  cron_del_job (cron, &semUp, 5 * cronSECONDS, sem);
-  cron_resume_jobs (cron, NO);
-  SEMAPHORE_DESTROY (sem);
+  GNUNET_cron_suspend_jobs (cron, GNUNET_NO);
+  GNUNET_cron_del_job (cron, &semUp, 5 * GNUNET_CRON_SECONDS, sem);
+  GNUNET_cron_resume_jobs (cron, GNUNET_NO);
+  GNUNET_semaphore_destroy (sem);
   sem = NULL;
   transport->disconnect (tsession, __FILE__);
-  if (ok == YES)
+  if (ok == GNUNET_YES)
     stats[2]++;
 }
 
 static int
 testTerminate (void *arg)
 {
-  if (GNUNET_SHUTDOWN_TEST () == NO)
-    return YES;
-  return NO;
+  if (GNUNET_shutdown_test () == GNUNET_NO)
+    return GNUNET_YES;
+  return GNUNET_NO;
 }
 
 /**
  * All gnunet-transport-check command line options
  */
-static struct CommandLineOption gnunettransportcheckOptions[] = {
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Tool to test if GNUnet transport 
services are operational.")),       /* -h */
-  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+static struct GNUNET_CommandLineOption gnunettransportcheckOptions[] = {
+  GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),   /* -c */
+  GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Tool to test if GNUnet 
transport services are operational.")),        /* -h */
+  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'p', "ping", NULL,
    gettext_noop ("ping peers from HOSTLISTURL that match transports"),
-   0, &gnunet_getopt_configure_set_one, &ping},
+   0, &GNUNET_getopt_configure_set_one, &ping},
   {'r', "repeat", "COUNT",
    gettext_noop ("send COUNT messages"),
-   1, &gnunet_getopt_configure_set_option, "TRANSPORT-CHECK:REPEAT"},
+   1, &GNUNET_getopt_configure_set_option, "TRANSPORT-CHECK:REPEAT"},
   {'s', "size", "SIZE",
    gettext_noop ("send messages with SIZE bytes payload"),
-   1, &gnunet_getopt_configure_set_option, "TRANSPORT-CHECK:SIZE"},
+   1, &GNUNET_getopt_configure_set_option, "TRANSPORT-CHECK:SIZE"},
   {'t', "transport", "TRANSPORT",
    gettext_noop ("specifies which TRANSPORT should be tested"),
-   1, &gnunet_getopt_configure_set_option, "GNUNETD:TRANSPORTS"},
+   1, &GNUNET_getopt_configure_set_option, "GNUNETD:TRANSPORTS"},
   {'T', "timeout", "MS",
    gettext_noop ("specifies after how many MS to time-out"),
-   1, &gnunet_getopt_configure_set_option, "TRANSPORT-CHECK:TIMEOUT"},
+   1, &GNUNET_getopt_configure_set_option, "TRANSPORT-CHECK:TIMEOUT"},
   {'u', "user", "LOGIN",
    gettext_noop ("run as user LOGIN"),
-   1, &gnunet_getopt_configure_set_option, "GNUNETD:USER"},
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_VERBOSE,
+   1, &GNUNET_getopt_configure_set_option, "GNUNETD:USER"},
+  GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION), /* -v */
+  GNUNET_COMMAND_LINE_OPTION_VERBOSE,
   {'X', "Xrepeat", "X",
    gettext_noop ("repeat each test X times"),
-   1, &gnunet_getopt_configure_set_option, "TRANSPORT-CHECK:X-REPEAT"},
-  COMMAND_LINE_OPTION_END,
+   1, &GNUNET_getopt_configure_set_option, "TRANSPORT-CHECK:X-REPEAT"},
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 int
@@ -389,7 +389,7 @@
                      argv,
                      "gnunet-transport-check",
                      &cfgFilename, gnunettransportcheckOptions, &ectx, &cfg);
-  if ((res == -1) || (OK != changeUser (ectx, cfg)))
+  if ((res == -1) || (GNUNET_OK != changeUser (ectx, cfg)))
     {
       GNUNET_fini (ectx, cfg);
       return -1;
@@ -407,14 +407,15 @@
                                                "TRANSPORT-CHECK",
                                                "TIMEOUT",
                                                1,
-                                               60 * cronSECONDS,
-                                               3 * cronSECONDS, &timeout))
+                                               60 * GNUNET_CRON_SECONDS,
+                                               3 * GNUNET_CRON_SECONDS,
+                                               &timeout))
     {
       GNUNET_fini (ectx, cfg);
       return 1;
     }
 
-  expectedValue = MALLOC (expectedSize);
+  expectedValue = GNUNET_malloc (expectedSize);
   pos = expectedSize;
   expectedValue[--pos] = '\0';
   while (pos-- > 0)
@@ -426,7 +427,7 @@
                                                "TRANSPORTS",
                                                "udp tcp http", &trans))
     {
-      FREE (expectedValue);
+      GNUNET_free (expectedValue);
       GNUNET_fini (ectx, cfg);
       return 1;
     }
@@ -435,7 +436,7 @@
     printf (_("Testing transport(s) %s\n"), trans);
   else
     printf (_("Available transport(s): %s\n"), trans);
-  FREE (trans);
+  GNUNET_free (trans);
   if (!ping)
     {
       /* disable blacklists (loopback is often blacklisted)... */
@@ -446,10 +447,10 @@
       GC_set_configuration_value_string (cfg, ectx, "HTTP", "BLACKLIST", "");
     }
   cron = cron_create (ectx);
-  if (OK != initCore (ectx, cfg, cron, NULL))
+  if (GNUNET_OK != initCore (ectx, cfg, cron, NULL))
     {
-      FREE (expectedValue);
-      cron_destroy (cron);
+      GNUNET_free (expectedValue);
+      GNUNET_cron_destroy (cron);
       GNUNET_fini (ectx, cfg);
       return 1;
     }
@@ -459,13 +460,13 @@
   identity = requestService ("identity");
   transport = requestService ("transport");
   pingpong = requestService ("pingpong");
-  cron_start (cron);
+  GNUNET_cron_start (cron);
 
   GC_get_configuration_value_number (cfg,
                                      "TRANSPORT-CHECK",
                                      "X-REPEAT",
                                      1, (unsigned long long) -1, 1, &Xrepeat);
-  res = OK;
+  res = GNUNET_OK;
   if (ping)
     {
       bootstrap = requestService ("bootstrap");
@@ -481,10 +482,10 @@
     }
   else
     {
-      while ((Xrepeat-- > 0) && (GNUNET_SHUTDOWN_TEST () == NO))
+      while ((Xrepeat-- > 0) && (GNUNET_shutdown_test () == GNUNET_NO))
         transport->forEach (&testTAPI, &res);
     }
-  cron_stop (cron);
+  GNUNET_cron_stop (cron);
   releaseService (identity);
   releaseService (transport);
   releaseService (pingpong);
@@ -492,11 +493,11 @@
   unregisterPlaintextHandler (P2P_PROTO_noise, &noiseHandler);
   doneConnection ();
   doneCore ();
-  FREE (expectedValue);
-  cron_destroy (cron);
+  GNUNET_free (expectedValue);
+  GNUNET_cron_destroy (cron);
   GNUNET_fini (ectx, cfg);
 
-  if (res != OK)
+  if (res != GNUNET_OK)
     return -1;
   return 0;
 }

Modified: GNUnet/src/server/gnunet-update.c
===================================================================
--- GNUnet/src/server/gnunet-update.c   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/server/gnunet-update.c   2007-11-23 11:51:54 UTC (rev 5742)
@@ -26,8 +26,6 @@
 
 #include "platform.h"
 #include "gnunet_util.h"
-#include "gnunet_util_boot.h"
-#include "gnunet_util_cron.h"
 #include "gnunet_directories.h"
 #include "gnunet_core.h"
 #include "core.h"
@@ -58,13 +56,13 @@
 
 /**
  * Allow the module named "pos" to update.
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
 updateModule (const char *rpos)
 {
   UpdateMethod mptr;
-  struct PluginHandle *library;
+  struct GNUNET_PluginHandle *library;
   char *name;
   int i;
   char *pos;
@@ -72,38 +70,38 @@
   for (i = 0; i < processedCount; i++)
     if (0 == strcmp (rpos, processed[i]))
       {
-        return OK;              /* already done */
+        return GNUNET_OK;       /* already done */
       }
-  GROW (processed, processedCount, processedCount + 1);
-  processed[processedCount - 1] = STRDUP (rpos);
+  GNUNET_array_grow (processed, processedCount, processedCount + 1);
+  processed[processedCount - 1] = GNUNET_strdup (rpos);
 
   pos = NULL;
   if (-1 == GC_get_configuration_value_string (cfg,
                                                "MODULES", rpos, rpos, &pos))
-    return SYSERR;
+    return GNUNET_SYSERR;
   GE_ASSERT (ectx, pos != NULL);
 
-  name = MALLOC (strlen (pos) + strlen ("module_") + 1);
+  name = GNUNET_malloc (strlen (pos) + strlen ("module_") + 1);
   strcpy (name, "module_");
   strcat (name, pos);
-  FREE (pos);
-  library = os_plugin_load (ectx, DSO_PREFIX, name);
+  GNUNET_free (pos);
+  library = GNUNET_plugin_load (ectx, DSO_PREFIX, name);
   if (library == NULL)
     {
-      FREE (name);
-      return SYSERR;
+      GNUNET_free (name);
+      return GNUNET_SYSERR;
     }
-  mptr = os_plugin_resolve_function (library, "update_", NO);
+  mptr = GNUNET_plugin_resolve_function (library, "update_", GNUNET_NO);
   if (mptr == NULL)
     {
-      os_plugin_unload (library);
-      FREE (name);
-      return OK;                /* module needs no updates! */
+      GNUNET_plugin_unload (library);
+      GNUNET_free (name);
+      return GNUNET_OK;         /* module needs no updates! */
     }
   mptr (&uapi);
-  os_plugin_unload (library);
-  FREE (name);
-  return OK;
+  GNUNET_plugin_unload (library);
+  GNUNET_free (name);
+  return GNUNET_OK;
 }
 
 /**
@@ -145,14 +143,14 @@
           GE_LOG (ectx,
                   GE_INFO | GE_USER | GE_BULK,
                   _("Updating data for module `%s'\n"), pos);
-          if (OK != updateModule (pos))
+          if (GNUNET_OK != updateModule (pos))
             GE_LOG (ectx,
                     GE_ERROR | GE_DEVELOPER | GE_BULK | GE_USER,
                     _("Failed to update data for module `%s'\n"), pos);
         }
     }
   while (next != NULL);
-  FREE (dso);
+  GNUNET_free (dso);
 }
 
 static void
@@ -171,11 +169,11 @@
       *ent = '\0';
       ent++;
     }
-  if (YES == GC_have_configuration_value (cfg, sec, ent))
+  if (GNUNET_YES == GC_have_configuration_value (cfg, sec, ent))
     {
       GC_get_configuration_value_string (cfg, sec, ent, NULL, &val);
       printf ("%s\n", val);
-      FREE (val);
+      GNUNET_free (val);
     }
 }
 
@@ -183,7 +181,7 @@
 work ()
 {
   int i;
-  struct CronManager *cron;
+  struct GNUNET_CronManager *cron;
 
   uapi.updateModule = &updateModule;
   uapi.requestService = &requestService;
@@ -192,7 +190,7 @@
   uapi.cfg = cfg;
 
   cron = cron_create (ectx);
-  if (initCore (ectx, cfg, cron, NULL) != OK)
+  if (initCore (ectx, cfg, cron, NULL) != GNUNET_OK)
     {
       GE_LOG (ectx, GE_FATAL | GE_USER | GE_IMMEDIATE,
               _("Core initialization failed.\n"));
@@ -215,42 +213,42 @@
   upToDate (ectx, cfg);
 
   for (i = 0; i < processedCount; i++)
-    FREE (processed[i]);
-  GROW (processed, processedCount, 0);
+    GNUNET_free (processed[i]);
+  GNUNET_array_grow (processed, processedCount, 0);
   doneCore ();
-  cron_destroy (cron);
+  GNUNET_cron_destroy (cron);
 }
 
 static int
-set_client_config (CommandLineProcessorContext * ctx,
+set_client_config (GNUNET_CommandLineProcessorContext * ctx,
                    void *scls, const char *option, const char *value)
 {
   cfgFilename = DEFAULT_CLIENT_CONFIG_FILE;
-  return OK;
+  return GNUNET_OK;
 }
 
 
 /**
  * All gnunet-update command line options
  */
-static struct CommandLineOption gnunetupdateOptions[] = {
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
+static struct GNUNET_CommandLineOption gnunetupdateOptions[] = {
+  GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),   /* -c */
   {'g', "get", "SECTION:ENTRY",
    gettext_noop ("print a value from the configuration file to stdout"),
-   1, &gnunet_getopt_configure_set_option, "GNUNET-UPDATE:GET"},
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Updates GNUnet datastructures after 
version change.")),      /* -h */
-  COMMAND_LINE_OPTION_HOSTNAME, /* -H */
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+   1, &GNUNET_getopt_configure_set_option, "GNUNET-UPDATE:GET"},
+  GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Updates GNUnet 
datastructures after version change.")),       /* -h */
+  GNUNET_COMMAND_LINE_OPTION_HOSTNAME,  /* -H */
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'u', "user", "LOGIN",
    gettext_noop ("run as user LOGIN"),
-   1, &gnunet_getopt_configure_set_option, "GNUNETD:USER"},
+   1, &GNUNET_getopt_configure_set_option, "GNUNETD:USER"},
   {'U', "client", NULL,
    gettext_noop
    ("run in client mode (for getting client configuration values)"),
    0, &set_client_config, NULL},
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_VERBOSE,
-  COMMAND_LINE_OPTION_END,
+  GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION), /* -v */
+  GNUNET_COMMAND_LINE_OPTION_VERBOSE,
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 
@@ -264,7 +262,7 @@
                      argv,
                      "gnunet-update",
                      &cfgFilename, gnunetupdateOptions, &ectx, &cfg);
-  if ((ret == -1) || (OK != changeUser (ectx, cfg)))
+  if ((ret == -1) || (GNUNET_OK != changeUser (ectx, cfg)))
     {
       GNUNET_fini (ectx, cfg);
       return -1;
@@ -275,7 +273,7 @@
     doGet (get);
   else
     work ();
-  FREE (get);
+  GNUNET_free (get);
   GNUNET_fini (ectx, cfg);
   return 0;
 }

Modified: GNUnet/src/server/gnunetd.c
===================================================================
--- GNUnet/src/server/gnunetd.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/server/gnunetd.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -28,9 +28,6 @@
  */
 
 #include "gnunet_util.h"
-#include "gnunet_util_boot.h"
-#include "gnunet_util_cron.h"
-#include "gnunet_util_error_loggers.h"
 #include "gnunet_core.h"
 #include "gnunet_directories.h"
 #include "core.h"
@@ -43,8 +40,8 @@
 static struct GC_Configuration *cfg;
 static struct GE_Context *ectx = NULL;
 
-static struct CronManager *cron;
-static struct LoadMonitor *mon;
+static struct GNUNET_CronManager *cron;
+static struct GNUNET_LoadMonitor *mon;
 
 static char *cfgFilename = DEFAULT_DAEMON_CONFIG_FILE;
 
@@ -70,7 +67,8 @@
 static void
 reread_config ()
 {
-  cron_add_job (cron, &reread_config_helper, 1 * cronSECONDS, 0, NULL);
+  GNUNET_cron_add_job (cron, &reread_config_helper, 1 * GNUNET_CRON_SECONDS,
+                       0, NULL);
 }
 #endif
 
@@ -83,7 +81,7 @@
   GE_LOG (ectx,
           GE_INFO | GE_USER | GE_REQUEST,
           _("`%s' startup complete.\n"), "gnunetd");
-  GNUNET_SHUTDOWN_WAITFOR ();
+  GNUNET_shutdown_wait_for ();
   GE_LOG (ectx,
           GE_INFO | GE_USER | GE_REQUEST,
           _("`%s' is shutting down.\n"), "gnunetd");
@@ -93,14 +91,14 @@
 static int
 post_detach ()
 {
-  if (OK != changeUser (ectx, cfg))
-    return SYSERR;
-  if (OK != checkPermissions (ectx, cfg))
-    return SYSERR;
-  mon = os_network_monitor_create (ectx, cfg);
+  if (GNUNET_OK != changeUser (ectx, cfg))
+    return GNUNET_SYSERR;
+  if (GNUNET_OK != checkPermissions (ectx, cfg))
+    return GNUNET_SYSERR;
+  mon = GNUNET_network_monitor_create (ectx, cfg);
   if (mon == NULL)
-    return SYSERR;
-  return OK;
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 /**
@@ -109,40 +107,41 @@
 int
 gnunet_main ()
 {
-  struct SignalHandlerContext *shc_hup;
+  struct GNUNET_SignalHandlerContext *shc_hup;
   int filedes[2];               /* pipe between client and parent */
 
-  if ((NO == debug_flag) && (OK != os_terminal_detach (ectx, cfg, filedes)))
-    return SYSERR;
-  if (NO != debug_flag)
-    os_write_pid_file (ectx, cfg, (unsigned int) getpid ());
-  if (OK != post_detach ())
+  if ((GNUNET_NO == debug_flag)
+      && (GNUNET_OK != GNUNET_terminal_detach (ectx, cfg, filedes)))
+    return GNUNET_SYSERR;
+  if (GNUNET_NO != debug_flag)
+    GNUNET_pid_file_write (ectx, cfg, (unsigned int) getpid ());
+  if (GNUNET_OK != post_detach ())
     {
-      if (NO == debug_flag)
-        os_terminal_detach_complete (ectx, filedes, NO);
+      if (GNUNET_NO == debug_flag)
+        GNUNET_terminal_detach_complete (ectx, filedes, GNUNET_NO);
       else
-        os_delete_pid_file (ectx, cfg);
-      return SYSERR;
+        GNUNET_pid_file_delete (ectx, cfg);
+      return GNUNET_SYSERR;
     }
   cron = cron_create (ectx);
   GE_ASSERT (ectx, cron != NULL);
 #ifndef WINDOWS
-  shc_hup = signal_handler_install (SIGHUP, &reread_config);
+  shc_hup = GNUNET_signal_handler_install (SIGHUP, &reread_config);
 #endif
-  if (OK != initCore (ectx, cfg, cron, mon))
+  if (GNUNET_OK != initCore (ectx, cfg, cron, mon))
     {
       GE_LOG (ectx,
               GE_FATAL | GE_USER | GE_IMMEDIATE,
               _("Core initialization failed.\n"));
 
-      cron_destroy (cron);
-      os_network_monitor_destroy (mon);
+      GNUNET_cron_destroy (cron);
+      GNUNET_network_monitor_destroy (mon);
 #ifndef WINDOWS
-      signal_handler_uninstall (SIGHUP, &reread_config, shc_hup);
+      GNUNET_signal_handler_uninstall (SIGHUP, &reread_config, shc_hup);
 #endif
-      if (NO == debug_flag)
-        os_terminal_detach_complete (ectx, filedes, NO);
-      return SYSERR;
+      if (GNUNET_NO == debug_flag)
+        GNUNET_terminal_detach_complete (ectx, filedes, GNUNET_NO);
+      return GNUNET_SYSERR;
     }
 
   /* enforce filesystem limits */
@@ -150,24 +149,24 @@
 
   initConnection (ectx, cfg, mon, cron);
   loadApplicationModules ();
-  if (NO == debug_flag)
-    os_terminal_detach_complete (ectx, filedes, YES);
-  cron_start (cron);
+  if (GNUNET_NO == debug_flag)
+    GNUNET_terminal_detach_complete (ectx, filedes, GNUNET_YES);
+  GNUNET_cron_start (cron);
   enableCoreProcessing ();
   waitForSignalHandler (ectx);
   disableCoreProcessing ();
-  cron_stop (cron);
-  os_delete_pid_file (ectx, cfg);
+  GNUNET_cron_stop (cron);
+  GNUNET_pid_file_delete (ectx, cfg);
   stopTCPServer ();
   unloadApplicationModules ();
   doneConnection ();
   doneCore ();
-  os_network_monitor_destroy (mon);
+  GNUNET_network_monitor_destroy (mon);
 #ifndef WINDOWS
-  signal_handler_uninstall (SIGHUP, &reread_config, shc_hup);
+  GNUNET_signal_handler_uninstall (SIGHUP, &reread_config, shc_hup);
 #endif
-  cron_destroy (cron);
-  return OK;
+  GNUNET_cron_destroy (cron);
+  return GNUNET_OK;
 }
 
 #ifdef MINGW
@@ -184,31 +183,31 @@
 /**
  * All gnunetd command line options
  */
-static struct CommandLineOption gnunetdOptions[] = {
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
+static struct GNUNET_CommandLineOption gnunetdOptions[] = {
+  GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),   /* -c */
   {'@', "win-service", NULL, "", 0,
-   &gnunet_getopt_configure_set_option, "GNUNETD:WINSERVICE"},
+   &GNUNET_getopt_configure_set_option, "GNUNETD:WINSERVICE"},
   {'d', "debug", NULL,
    gettext_noop ("run in debug mode; gnunetd will "
                  "not daemonize and error messages will "
                  "be written to stderr instead of a logfile"),
-   0, &gnunet_getopt_configure_set_one, &debug_flag},
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Starts the gnunetd daemon.")),      
 /* -h */
-  COMMAND_LINE_OPTION_LOGGING,  /* -L */
+   0, &GNUNET_getopt_configure_set_one, &debug_flag},
+  GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Starts the gnunetd 
daemon.")),        /* -h */
+  GNUNET_COMMAND_LINE_OPTION_LOGGING,   /* -L */
   {'p', "padding-disable", "YES/NO",
    gettext_noop ("disable padding with random data (experimental)"), 0,
-   &gnunet_getopt_configure_set_option, "GNUNETD-EXPERIMENTAL:PADDING"},
+   &GNUNET_getopt_configure_set_option, "GNUNETD-EXPERIMENTAL:PADDING"},
   {'l', "loud", NULL,
    gettext_noop
    ("print all log messages to the console (only works together with -d)"),
-   0, &gnunet_getopt_configure_set_one, &loud_flag},
+   0, &GNUNET_getopt_configure_set_one, &loud_flag},
 #ifndef MINGW
   {'u', "user", "USERNAME",
    gettext_noop ("specify username as which gnunetd should run"), 1,
-   &gnunet_getopt_configure_set_option, "GNUNETD:USERNAME"},
+   &GNUNET_getopt_configure_set_option, "GNUNETD:USERNAME"},
 #endif
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_END,
+  GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION), /* -v */
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 /**
@@ -220,7 +219,8 @@
 {
   int ret;
 
-  if ((4 != sizeof (MESSAGE_HEADER)) || (600 != sizeof (P2P_hello_MESSAGE)))
+  if ((4 != sizeof (GNUNET_MessageHeader))
+      || (600 != sizeof (GNUNET_MessageHello)))
     {
       fprintf (stderr,
                "Sorry, your C compiler did not properly align the C structs. 
Aborting.\n");
@@ -235,7 +235,7 @@
       GNUNET_fini (ectx, cfg);
       return 1;
     }
-  if (YES == debug_flag)
+  if (GNUNET_YES == debug_flag)
     {
       int dev;
       char *user_log_level;
@@ -248,22 +248,23 @@
                                          "USER-LEVEL",
                                          "WARNING", &user_log_level);
       dev = GC_get_configuration_value_yesno (cfg,
-                                              "LOGGING", "DEVELOPER", NO);
+                                              "LOGGING", "DEVELOPER",
+                                              GNUNET_NO);
       ull = GE_getKIND (user_log_level);
       ull |= (ull - 1);         /* set bits for all lower log-levels */
-      if (dev == YES)
+      if (dev == GNUNET_YES)
         ull |= GE_DEVELOPER | GE_REQUEST;
       if (loud_flag == 1)
-        ectx = GE_create_context_stderr (YES, GE_ALL);
+        ectx = GE_create_context_stderr (GNUNET_YES, GE_ALL);
       else
-        ectx = GE_create_context_stderr (YES,
+        ectx = GE_create_context_stderr (GNUNET_YES,
                                          GE_USER | GE_ADMIN
                                          | ull | GE_BULK | GE_IMMEDIATE);
       GE_setDefaultContext (ectx);
-      FREE (user_log_level);
+      GNUNET_free (user_log_level);
     }
   setFdLimit (ectx, cfg);
-  if (OK != checkUpToDate (ectx, cfg))
+  if (GNUNET_OK != checkUpToDate (ectx, cfg))
     {
       GE_LOG (ectx,
               GE_USER | GE_FATAL | GE_IMMEDIATE,
@@ -276,7 +277,8 @@
 
 #ifdef MINGW
   if (GC_get_configuration_value_yesno (cfg,
-                                        "GNUNETD", "WINSERVICE", NO) == YES)
+                                        "GNUNETD", "WINSERVICE",
+                                        GNUNET_NO) == GNUNET_YES)
     {
       SERVICE_TABLE_ENTRY DispatchTable[] = { {"GNUnet", ServiceMain}
       , {NULL, NULL}
@@ -287,7 +289,7 @@
 #endif
     ret = gnunet_main ();
   GNUNET_fini (ectx, cfg);
-  if (ret != OK)
+  if (ret != GNUNET_OK)
     return 1;
   return 0;
 }

Modified: GNUnet/src/server/handler.c
===================================================================
--- GNUnet/src/server/handler.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/server/handler.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -34,25 +34,25 @@
 #include "connection.h"
 #include "tcpserver.h"
 
-#define DEBUG_HANDLER NO
+#define DEBUG_HANDLER GNUNET_NO
 
 /**
  * Track how many messages we are discarding?
  */
-#define TRACK_DISCARD NO
+#define TRACK_DISCARD GNUNET_NO
 
 /**
  * Track how much time was spent on each
  * type of message?
  */
-#define MEASURE_TIME NO
+#define MEASURE_TIME GNUNET_NO
 
 /**
  * Should we validate that handlers do not
  * modify the messages that they are given?
  * (expensive!)
  */
-#define VALIDATE_CLIENT NO
+#define VALIDATE_CLIENT GNUNET_NO
 
 /**
  * How many incoming packages do we have in the buffer
@@ -82,17 +82,17 @@
 
 static int bq_firstFull_;
 
-static int threads_running = NO;
+static int threads_running = GNUNET_NO;
 
-static struct SEMAPHORE *bufferQueueRead_;
+static struct GNUNET_Semaphore *bufferQueueRead_;
 
-static struct SEMAPHORE *bufferQueueWrite_;
+static struct GNUNET_Semaphore *bufferQueueWrite_;
 
-static struct MUTEX *globalLock_;
+static struct GNUNET_Mutex *globalLock_;
 
-static struct SEMAPHORE *mainShutdownSignal;
+static struct GNUNET_Semaphore *mainShutdownSignal;
 
-static struct PTHREAD *threads_[THREAD_COUNT];
+static struct GNUNET_ThreadHandle *threads_[THREAD_COUNT];
 
 #if TRACK_DISCARD
 static unsigned int discarded;
@@ -125,12 +125,12 @@
 /**
  * Mutex to guard access to the handler array.
  */
-static struct MUTEX *handlerLock;
+static struct GNUNET_Mutex *handlerLock;
 
 static struct GE_Context *ectx;
 
 #if MEASURE_TIME
-static cron_t time_by_type[P2P_PROTO_MAX_USED];
+static GNUNET_CronTime time_by_type[P2P_PROTO_MAX_USED];
 static unsigned int count_by_type[P2P_PROTO_MAX_USED];
 #endif
 
@@ -139,13 +139,13 @@
  * Register a method as a handler for specific message types.  Note
  * that it IS possible to register multiple handlers for the same
  * message.  In that case, they will ALL be executed in the order of
- * registration, unless one of them returns SYSERR in which case the
+ * registration, unless one of them returns GNUNET_SYSERR in which case the
  * remaining handlers and the rest of the message are ignored.
  *
  * @param type the message type
  * @param callback the method to call if a message of
  *        that type is received
- * @return OK on success, SYSERR if core threads are running
+ * @return GNUNET_OK on success, GNUNET_SYSERR if core threads are running
  *        and updates to the handler list are illegal!
  */
 int
@@ -153,20 +153,20 @@
 {
   unsigned int last;
 
-  if (threads_running == YES)
+  if (threads_running == GNUNET_YES)
     {
       GE_BREAK (ectx, NULL);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  MUTEX_LOCK (handlerLock);
+  GNUNET_mutex_lock (handlerLock);
   if (type >= max_registeredType)
     {
       unsigned int ort = max_registeredType;
-      GROW (handlers, max_registeredType, type + 32);
+      GNUNET_array_grow (handlers, max_registeredType, type + 32);
       while (ort < max_registeredType)
         {
           unsigned int zero = 0;
-          GROW (handlers[ort], zero, 1);
+          GNUNET_array_grow (handlers[ort], zero, 1);
           ort++;
         }
     }
@@ -174,10 +174,10 @@
   while (handlers[type][last] != NULL)
     last++;
   last++;
-  GROW (handlers[type], last, last + 1);
+  GNUNET_array_grow (handlers[type], last, last + 1);
   handlers[type][last - 2] = callback;
-  MUTEX_UNLOCK (handlerLock);
-  return OK;
+  GNUNET_mutex_unlock (handlerLock);
+  return GNUNET_OK;
 }
 
 /**
@@ -187,7 +187,7 @@
  * @param type the message type
  * @param callback the method to call if a message of
  *        that type is received
- * @return OK on success, SYSERR if there is a different
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there is a different
  *        handler for that type or if core threads are running
  *        and updates to the handler list are illegal!
  */
@@ -197,12 +197,12 @@
   unsigned int pos;
   unsigned int last;
 
-  if (threads_running == YES)
+  if (threads_running == GNUNET_YES)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  MUTEX_LOCK (handlerLock);
+  GNUNET_mutex_lock (handlerLock);
   if (type < max_registeredType)
     {
       pos = 0;
@@ -214,34 +214,34 @@
         last++;
       if (last == pos)
         {
-          MUTEX_UNLOCK (handlerLock);
-          return SYSERR;
+          GNUNET_mutex_unlock (handlerLock);
+          return GNUNET_SYSERR;
         }
       else
         {
           handlers[type][pos] = handlers[type][last - 1];
           handlers[type][last - 1] = NULL;
           last++;
-          GROW (handlers[type], last, last - 1);
-          MUTEX_UNLOCK (handlerLock);
-          return OK;
+          GNUNET_array_grow (handlers[type], last, last - 1);
+          GNUNET_mutex_unlock (handlerLock);
+          return GNUNET_OK;
         }
     }
-  MUTEX_UNLOCK (handlerLock);
-  return SYSERR;
+  GNUNET_mutex_unlock (handlerLock);
+  return GNUNET_SYSERR;
 }
 
 /**
  * Register a method as a handler for specific message types.  Note
  * that it IS possible to register multiple handlers for the same
  * message.  In that case, they will ALL be executed in the order of
- * registration, unless one of them returns SYSERR in which case the
+ * registration, unless one of them returns GNUNET_SYSERR in which case the
  * remaining handlers and the rest of the message are ignored.
  *
  * @param type the message type
  * @param callback the method to call if a message of
  *        that type is received
- * @return OK on success, SYSERR if core threads are running
+ * @return GNUNET_OK on success, GNUNET_SYSERR if core threads are running
  *        and updates to the handler list are illegal!
  */
 int
@@ -250,20 +250,21 @@
 {
   unsigned int last;
 
-  if (threads_running == YES)
+  if (threads_running == GNUNET_YES)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  MUTEX_LOCK (handlerLock);
+  GNUNET_mutex_lock (handlerLock);
   if (type >= plaintextmax_registeredType)
     {
       unsigned int ort = plaintextmax_registeredType;
-      GROW (plaintextHandlers, plaintextmax_registeredType, type + 32);
+      GNUNET_array_grow (plaintextHandlers, plaintextmax_registeredType,
+                         type + 32);
       while (ort < plaintextmax_registeredType)
         {
           unsigned int zero = 0;
-          GROW (plaintextHandlers[ort], zero, 1);
+          GNUNET_array_grow (plaintextHandlers[ort], zero, 1);
           ort++;
         }
     }
@@ -271,10 +272,10 @@
   while (plaintextHandlers[type][last] != NULL)
     last++;
   last++;
-  GROW (plaintextHandlers[type], last, last + 1);
+  GNUNET_array_grow (plaintextHandlers[type], last, last + 1);
   plaintextHandlers[type][last - 2] = callback;
-  MUTEX_UNLOCK (handlerLock);
-  return OK;
+  GNUNET_mutex_unlock (handlerLock);
+  return GNUNET_OK;
 }
 
 /**
@@ -284,7 +285,7 @@
  * @param type the message type
  * @param callback the method to call if a message of
  *        that type is received
- * @return OK on success, SYSERR if there is a different
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there is a different
  *        handler for that type or if core threads are running
  *        and updates to the handler list are illegal!
  */
@@ -295,12 +296,12 @@
   unsigned int pos;
   unsigned int last;
 
-  if (threads_running == YES)
+  if (threads_running == GNUNET_YES)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  MUTEX_LOCK (handlerLock);
+  GNUNET_mutex_lock (handlerLock);
   if (type < plaintextmax_registeredType)
     {
       pos = 0;
@@ -312,21 +313,21 @@
         last++;
       if (last == pos)
         {
-          MUTEX_UNLOCK (handlerLock);
-          return SYSERR;
+          GNUNET_mutex_unlock (handlerLock);
+          return GNUNET_SYSERR;
         }
       else
         {
           plaintextHandlers[type][pos] = plaintextHandlers[type][last - 1];
           plaintextHandlers[type][last - 1] = NULL;
           last++;
-          GROW (plaintextHandlers[type], last, last - 1);
-          MUTEX_UNLOCK (handlerLock);
-          return OK;
+          GNUNET_array_grow (plaintextHandlers[type], last, last - 1);
+          GNUNET_mutex_unlock (handlerLock);
+          return GNUNET_OK;
         }
     }
-  MUTEX_UNLOCK (handlerLock);
-  return SYSERR;
+  GNUNET_mutex_unlock (handlerLock);
+  return GNUNET_SYSERR;
 }
 
 
@@ -338,7 +339,7 @@
  * @param type the message type
  * @param callback the method to call if a message of
  *        that type is received
- * @return OK on success, SYSERR if there is a different
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there is a different
  *        handler for that type or if core threads are running
  *        and updates to the handler list are illegal!
  */
@@ -353,10 +354,10 @@
   if (handlerType > 3)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   ret = 0;
-  MUTEX_LOCK (handlerLock);
+  GNUNET_mutex_lock (handlerLock);
   if (type < plaintextmax_registeredType)
     {
       pos = 0;
@@ -373,7 +374,7 @@
       if ((handlerType == 1) || (handlerType == 2))
         ret += pos;
     }
-  MUTEX_UNLOCK (handlerLock);
+  GNUNET_mutex_unlock (handlerLock);
   return ret;
 }
 
@@ -383,23 +384,23 @@
  * Processes the message by calling the registered
  * handler for each message part.
  *
- * @param encrypted YES if it was encrypted,
- *    NO if plaintext,
+ * @param encrypted GNUNET_YES if it was encrypted,
+ *    GNUNET_NO if plaintext,
  * @param session NULL if not available
  */
 void
-injectMessage (const PeerIdentity * sender,
+injectMessage (const GNUNET_PeerIdentity * sender,
                const char *msg,
                unsigned int size, int wasEncrypted, TSession * session)
 {
   unsigned int pos;
-  const MESSAGE_HEADER *part;
-  MESSAGE_HEADER cpart;
-  MESSAGE_HEADER *copy;
+  const GNUNET_MessageHeader *part;
+  GNUNET_MessageHeader cpart;
+  GNUNET_MessageHeader *copy;
   int last;
-  EncName enc;
+  GNUNET_EncName enc;
 #if MEASURE_TIME
-  cron_t now;
+  GNUNET_CronTime now;
 #endif
 #if VALIDATE_CLIENT
   void *old_value;
@@ -412,9 +413,9 @@
       unsigned short plen;
       unsigned short ptyp;
 
-      FREENONNULL (copy);
+      GNUNET_free_non_null (copy);
       copy = NULL;
-      memcpy (&cpart, &msg[pos], sizeof (MESSAGE_HEADER));
+      memcpy (&cpart, &msg[pos], sizeof (GNUNET_MessageHeader));
       plen = htons (cpart.size);
       if (pos + plen > size)
         {
@@ -422,7 +423,7 @@
             {
               IF_GELOG (ectx,
                         GE_WARNING | GE_USER | GE_BULK,
-                        hash2enc (&sender->hashPubKey, &enc));
+                        GNUNET_hash_to_enc (&sender->hashPubKey, &enc));
               GE_LOG (ectx,
                       GE_WARNING | GE_USER | GE_BULK,
                       _("Received corrupt message from peer `%s'in %s:%d.\n"),
@@ -442,13 +443,13 @@
              however we also (need to) guaranteed word-alignment for the
              handlers; so we must re-align the message if it is
              misaligned. */
-          copy = MALLOC (plen);
+          copy = GNUNET_malloc (plen);
           memcpy (copy, &msg[pos], plen);
           part = copy;
         }
       else
         {
-          part = (const MESSAGE_HEADER *) &msg[pos];
+          part = (const GNUNET_MessageHeader *) &msg[pos];
         }
       pos += plen;
 
@@ -456,14 +457,14 @@
 #if DEBUG_HANDLER
       if (sender != NULL)
         {
-          IF_GELOG (ectx, GE_DEBUG, hash2enc (&sender->hashPubKey, &enc));
-          GE_LOG (ectx,
-                  GE_DEBUG,
+          IF_GELOG (ectx, GE_DEBUG,
+                    GNUNET_hash_to_enc (&sender->hashPubKey, &enc));
+          GE_LOG (ectx, GE_DEBUG,
                   "Received %s message of type %u from peer `%s'\n",
                   wasEncrypted ? "encrypted" : "plaintext", ptyp, &enc);
         }
 #endif
-      if (YES == wasEncrypted)
+      if (GNUNET_YES == wasEncrypted)
         {
           MessagePartHandler callback;
 
@@ -476,16 +477,16 @@
               continue;         /* no handler registered, go to next part */
             }
 #if MEASURE_TIME
-          now = get_time ();
+          now = GNUNET_get_time ();
 #endif
           last = 0;
           while (NULL != (callback = handlers[ptyp][last]))
             {
 #if VALIDATE_CLIENT
-              old_value = MALLOC (plen);
+              old_value = GNUNET_malloc (plen);
               memcpy (old_value, part, plen);
 #endif
-              if (SYSERR == callback (sender, part))
+              if (GNUNET_SYSERR == callback (sender, part))
                 {
 #if DEBUG_HANDLER
                   GE_LOG (ectx,
@@ -493,10 +494,10 @@
                           "Handler aborted message processing after receiving 
message of type '%d'.\n",
                           ptyp);
 #endif
-                  FREENONNULL (copy);
+                  GNUNET_free_non_null (copy);
                   copy = NULL;
 #if VALIDATE_CLIENT
-                  FREE (old_value);
+                  GNUNET_free (old_value);
 #endif
                   return;       /* handler says: do not process the rest of 
the message */
                 }
@@ -505,7 +506,7 @@
                 GE_LOG (ectx,
                         GE_ERROR | GE_DEVELOPER | GE_IMMEDIATE,
                         "Handler %d at %p violated const!\n", ptyp, callback);
-              FREE (old_value);
+              GNUNET_free (old_value);
 #endif
 
               last++;
@@ -513,13 +514,13 @@
 #if MEASURE_TIME
           if (ptyp < P2P_PROTO_MAX_USED)
             {
-              time_by_type[ptyp] += get_time () - now;
+              time_by_type[ptyp] += GNUNET_get_time () - now;
               count_by_type[ptyp]++;
             }
 #endif
         }
       else
-        {                       /* isEncrypted == NO */
+        {                       /* isEncrypted == GNUNET_NO */
           PlaintextMessagePartHandler callback;
 
           if ((ptyp >= plaintextmax_registeredType) ||
@@ -532,12 +533,12 @@
               continue;         /* no handler registered, go to next part */
             }
 #if MEASURE_TIME
-          now = get_time ();
+          now = GNUNET_get_time ();
 #endif
           last = 0;
           while (NULL != (callback = plaintextHandlers[ptyp][last]))
             {
-              if (SYSERR == callback (sender, part, session))
+              if (GNUNET_SYSERR == callback (sender, part, session))
                 {
 #if DEBUG_HANDLER
                   GE_LOG (ectx,
@@ -545,7 +546,7 @@
                           "Handler aborted message processing after receiving 
message of type '%d'.\n",
                           ptyp);
 #endif
-                  FREENONNULL (copy);
+                  GNUNET_free_non_null (copy);
                   copy = NULL;
                   return;       /* handler says: do not process the rest of 
the message */
                 }
@@ -554,14 +555,14 @@
 #if MEASURE_TIME
           if (ptyp < P2P_PROTO_MAX_USED)
             {
-              time_by_type[ptyp] += get_time () - now;
+              time_by_type[ptyp] += GNUNET_get_time () - now;
               count_by_type[ptyp]++;
             }
 #endif
 
         }                       /* if plaintext */
     }                           /* while loop */
-  FREENONNULL (copy);
+  GNUNET_free_non_null (copy);
   copy = NULL;
 }
 
@@ -575,22 +576,22 @@
  */
 static void
 handleMessage (TSession * tsession,
-               const PeerIdentity * sender,
+               const GNUNET_PeerIdentity * sender,
                const char *msg, unsigned int size)
 {
   int ret;
 
   if ((tsession != NULL) &&
       (sender != NULL) &&
-      (0 != memcmp (sender, &tsession->peer, sizeof (PeerIdentity))))
+      (0 != memcmp (sender, &tsession->peer, sizeof (GNUNET_PeerIdentity))))
     {
       GE_BREAK (NULL, 0);
       return;
     }
   ret = checkHeader (sender, (P2P_PACKET_HEADER *) msg, size);
-  if (ret == SYSERR) 
-    return;   /* message malformed or failed to decrypt*/
-  if ((ret == YES) && (tsession != NULL) && (sender != NULL))
+  if (ret == GNUNET_SYSERR)
+    return;                     /* message malformed or failed to decrypt */
+  if ((ret == GNUNET_YES) && (tsession != NULL) && (sender != NULL))
     considerTakeover (sender, tsession);
   injectMessage (sender,
                  &msg[sizeof (P2P_PACKET_HEADER)],
@@ -609,27 +610,27 @@
 
   while (mainShutdownSignal == NULL)
     {
-      SEMAPHORE_DOWN (bufferQueueRead_, YES);
+      GNUNET_semaphore_down (bufferQueueRead_, GNUNET_YES);
       /* handle buffer entry */
       /* sync with other handlers to get buffer */
       if (mainShutdownSignal != NULL)
         break;
-      MUTEX_LOCK (globalLock_);
+      GNUNET_mutex_lock (globalLock_);
       mp = bufferQueue_[bq_firstFull_];
       bufferQueue_[bq_firstFull_++] = NULL;
       if (bq_firstFull_ == QUEUE_LENGTH)
         bq_firstFull_ = 0;
-      MUTEX_UNLOCK (globalLock_);
+      GNUNET_mutex_unlock (globalLock_);
       /* end of sync */
-      SEMAPHORE_UP (bufferQueueWrite_);
+      GNUNET_semaphore_up (bufferQueueWrite_);
       /* handle buffer - now out of sync */
       handleMessage (mp->tsession, &mp->sender, mp->msg, mp->size);
       if (mp->tsession != NULL)
         transport->disconnect (mp->tsession, __FILE__);
-      FREE (mp->msg);
-      FREE (mp);
+      GNUNET_free (mp->msg);
+      GNUNET_free (mp);
     }
-  SEMAPHORE_UP (mainShutdownSignal);
+  GNUNET_semaphore_up (mainShutdownSignal);
   return NULL;
 }                               /* end of threadMain */
 
@@ -641,18 +642,20 @@
 core_receive (P2P_PACKET * mp)
 {
   if ((mp->tsession != NULL) &&
-      (0 != memcmp (&mp->sender, &mp->tsession->peer, sizeof (PeerIdentity))))
+      (0 !=
+       memcmp (&mp->sender, &mp->tsession->peer,
+               sizeof (GNUNET_PeerIdentity))))
     {
       GE_BREAK (NULL, 0);
-      FREE (mp->msg);
-      FREE (mp);
+      GNUNET_free (mp->msg);
+      GNUNET_free (mp);
       return;
     }
-  if ((threads_running == NO) || (mainShutdownSignal != NULL))
+  if ((threads_running == GNUNET_NO) || (mainShutdownSignal != NULL))
     {
 #if TRACK_DISCARD
       if (globalLock_ != NULL)
-        MUTEX_LOCK (globalLock_);
+        GNUNET_mutex_lock (globalLock_);
       discarded++;
       if (0 == discarded % 64)
         GE_LOG (ectx,
@@ -662,24 +665,24 @@
                 discarded,
                 blacklisted, 1.0 * accepted / (blacklisted + discarded + 1));
       if (globalLock_ != NULL)
-        MUTEX_UNLOCK (globalLock_);
+        GNUNET_mutex_unlock (globalLock_);
 #endif
     }
   /* check for blacklisting */
-  if (YES == identity->isBlacklisted (&mp->sender, YES))
+  if (GNUNET_YES == identity->isBlacklisted (&mp->sender, GNUNET_YES))
     {
 #if DEBUG_HANDLER
-      EncName enc;
+      GNUNET_EncName enc;
       IF_GELOG (ectx,
                 GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
-                hash2enc (&mp->sender.hashPubKey, &enc));
+                GNUNET_hash_to_enc (&mp->sender.hashPubKey, &enc));
       GE_LOG (ectx,
               GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
               "Strictly blacklisted peer `%s' sent message, dropping for 
now.\n",
               (char *) &enc);
 #endif
 #if TRACK_DISCARD
-      MUTEX_LOCK (globalLock_);
+      GNUNET_mutex_lock (globalLock_);
       blacklisted++;
       if (0 == blacklisted % 64)
         GE_LOG (ectx,
@@ -688,15 +691,15 @@
                 accepted,
                 discarded,
                 blacklisted, 1.0 * accepted / (blacklisted + discarded + 1));
-      MUTEX_UNLOCK (globalLock_);
+      GNUNET_mutex_unlock (globalLock_);
 #endif
-      FREE (mp->msg);
-      FREE (mp);
+      GNUNET_free (mp->msg);
+      GNUNET_free (mp);
       return;
     }
-  if ((threads_running == NO) ||
+  if ((threads_running == GNUNET_NO) ||
       (mainShutdownSignal != NULL) ||
-      (SYSERR == SEMAPHORE_DOWN (bufferQueueWrite_, NO)))
+      (GNUNET_SYSERR == GNUNET_semaphore_down (bufferQueueWrite_, GNUNET_NO)))
     {
       /* discard message, buffer is full or
          we're shut down! */
@@ -705,11 +708,11 @@
               GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
               "Discarding message of size %u -- buffer full!\n", mp->size);
 #endif
-      FREE (mp->msg);
-      FREE (mp);
+      GNUNET_free (mp->msg);
+      GNUNET_free (mp);
 #if TRACK_DISCARD
       if (globalLock_ != NULL)
-        MUTEX_LOCK (globalLock_);
+        GNUNET_mutex_lock (globalLock_);
       discarded++;
       if (0 == discarded % 64)
         GE_LOG (ectx,
@@ -719,16 +722,16 @@
                 discarded,
                 blacklisted, 1.0 * accepted / (blacklisted + discarded + 1));
       if (globalLock_ != NULL)
-        MUTEX_UNLOCK (globalLock_);
+        GNUNET_mutex_unlock (globalLock_);
 #endif
       return;
     }
   /* try to increment session reference count */
   if ((mp->tsession != NULL) &&
-      (SYSERR == transport->associate (mp->tsession, __FILE__)))
+      (GNUNET_SYSERR == transport->associate (mp->tsession, __FILE__)))
     mp->tsession = NULL;
 
-  MUTEX_LOCK (globalLock_);
+  GNUNET_mutex_lock (globalLock_);
   if (bq_firstFree_ == QUEUE_LENGTH)
     bq_firstFree_ = 0;
   bufferQueue_[bq_firstFree_++] = mp;
@@ -742,8 +745,8 @@
             discarded,
             blacklisted, 1.0 * accepted / (blacklisted + discarded + 1));
 #endif
-  MUTEX_UNLOCK (globalLock_);
-  SEMAPHORE_UP (bufferQueueRead_);
+  GNUNET_mutex_unlock (globalLock_);
+  GNUNET_semaphore_up (bufferQueueRead_);
 }
 
 /**
@@ -754,17 +757,17 @@
 {
   int i;
 
-  globalLock_ = MUTEX_CREATE (NO);
+  globalLock_ = GNUNET_mutex_create (GNUNET_NO);
   for (i = 0; i < QUEUE_LENGTH; i++)
     bufferQueue_[i] = NULL;
   bq_firstFree_ = 0;
   bq_firstFull_ = 0;
 
   /* create message handling threads */
-  threads_running = YES;
+  threads_running = GNUNET_YES;
   for (i = 0; i < THREAD_COUNT; i++)
     {
-      threads_[i] = PTHREAD_CREATE (&threadMain, &i, 128 * 1024);
+      threads_[i] = GNUNET_thread_create (&threadMain, &i, 128 * 1024);
       if (threads_[i] == NULL)
         GE_LOG_STRERROR (ectx, GE_ERROR, "pthread_create");
     }
@@ -780,21 +783,21 @@
   void *unused;
 
   /* shutdown processing of inbound messages... */
-  threads_running = NO;
-  mainShutdownSignal = SEMAPHORE_CREATE (0);
+  threads_running = GNUNET_NO;
+  mainShutdownSignal = GNUNET_semaphore_create (0);
   for (i = 0; i < THREAD_COUNT; i++)
     {
-      SEMAPHORE_UP (bufferQueueRead_);
-      SEMAPHORE_DOWN (mainShutdownSignal, YES);
+      GNUNET_semaphore_up (bufferQueueRead_);
+      GNUNET_semaphore_down (mainShutdownSignal, GNUNET_YES);
     }
   for (i = 0; i < THREAD_COUNT; i++)
     {
-      PTHREAD_JOIN (threads_[i], &unused);
+      GNUNET_thread_join (threads_[i], &unused);
       threads_[i] = NULL;
     }
-  SEMAPHORE_DESTROY (mainShutdownSignal);
+  GNUNET_semaphore_destroy (mainShutdownSignal);
   mainShutdownSignal = NULL;
-  MUTEX_DESTROY (globalLock_);
+  GNUNET_mutex_destroy (globalLock_);
   globalLock_ = NULL;
 }
 
@@ -805,14 +808,14 @@
 initHandler (struct GE_Context *e)
 {
   ectx = e;
-  handlerLock = MUTEX_CREATE (NO);
+  handlerLock = GNUNET_mutex_create (GNUNET_NO);
   transport = requestService ("transport");
   GE_ASSERT (ectx, transport != NULL);
   identity = requestService ("identity");
   GE_ASSERT (ectx, identity != NULL);
   /* initialize sync mechanisms for message handling threads */
-  bufferQueueRead_ = SEMAPHORE_CREATE (0);
-  bufferQueueWrite_ = SEMAPHORE_CREATE (QUEUE_LENGTH);
+  bufferQueueRead_ = GNUNET_semaphore_create (0);
+  bufferQueueWrite_ = GNUNET_semaphore_create (QUEUE_LENGTH);
 }
 
 /**
@@ -824,18 +827,18 @@
   unsigned int i;
 
   /* free datastructures */
-  SEMAPHORE_DESTROY (bufferQueueRead_);
+  GNUNET_semaphore_destroy (bufferQueueRead_);
   bufferQueueRead_ = NULL;
-  SEMAPHORE_DESTROY (bufferQueueWrite_);
+  GNUNET_semaphore_destroy (bufferQueueWrite_);
   bufferQueueWrite_ = NULL;
   for (i = 0; i < QUEUE_LENGTH; i++)
     {
       if (bufferQueue_[i] != NULL)
-        FREENONNULL (bufferQueue_[i]->msg);
-      FREENONNULL (bufferQueue_[i]);
+        GNUNET_free_non_null (bufferQueue_[i]->msg);
+      GNUNET_free_non_null (bufferQueue_[i]);
     }
 
-  MUTEX_DESTROY (handlerLock);
+  GNUNET_mutex_destroy (handlerLock);
   handlerLock = NULL;
   for (i = 0; i < max_registeredType; i++)
     {
@@ -843,17 +846,17 @@
       while (handlers[i][last] != NULL)
         last++;
       last++;
-      GROW (handlers[i], last, 0);
+      GNUNET_array_grow (handlers[i], last, 0);
     }
-  GROW (handlers, max_registeredType, 0);
+  GNUNET_array_grow (handlers, max_registeredType, 0);
   for (i = 0; i < plaintextmax_registeredType; i++)
     {
       unsigned int last = 0;
       while (plaintextHandlers[i][last] != NULL)
         last++;
-      GROW (plaintextHandlers[i], last, 0);
+      GNUNET_array_grow (plaintextHandlers[i], last, 0);
     }
-  GROW (plaintextHandlers, plaintextmax_registeredType, 0);
+  GNUNET_array_grow (plaintextHandlers, plaintextmax_registeredType, 0);
   releaseService (transport);
   transport = NULL;
   releaseService (identity);

Modified: GNUnet/src/server/handler.h
===================================================================
--- GNUnet/src/server/handler.h 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/server/handler.h 2007-11-23 11:51:54 UTC (rev 5742)
@@ -54,10 +54,10 @@
  * Handle a message (that was decrypted if needed).  Processes the
  * message by calling the registered handler for each message part.
  *
- * @param wasEncrypted YES if it was encrypted,
- *                     NO if plaintext,
+ * @param wasEncrypted GNUNET_YES if it was encrypted,
+ *                     GNUNET_NO if plaintext,
  */
-void injectMessage (const PeerIdentity * sender,
+void injectMessage (const GNUNET_PeerIdentity * sender,
                     const char *msg,
                     unsigned int size, int wasEncrypted, TSession * session);
 
@@ -74,9 +74,9 @@
  * @param type the message type
  * @param callback the method to call if a message of
  *        that type is received, if the callback returns
- *        SYSERR, processing of the message is discontinued
+ *        GNUNET_SYSERR, processing of the message is discontinued
  *        afterwards (all other parts are ignored)
- * @return OK on success, SYSERR if there is already a
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there is already a
  *         handler for that type
  */
 int registerp2pHandler (const unsigned short type,
@@ -89,7 +89,7 @@
  * @param type the message type
  * @param callback the method to call if a message of
  *        that type is received
- * @return OK on success, SYSERR if there is a different
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there is a different
  *         handler for that type
  */
 int unregisterp2pHandler (const unsigned short type,
@@ -100,13 +100,13 @@
  * Register a method as a handler for specific message types.  Note
  * that it IS possible to register multiple handlers for the same
  * message.  In that case, they will ALL be executed in the order of
- * registration, unless one of them returns SYSERR in which case the
+ * registration, unless one of them returns GNUNET_SYSERR in which case the
  * remaining handlers and the rest of the message are ignored.
  *
  * @param type the message type
  * @param callback the method to call if a message of
  *        that type is received
- * @return OK on success, SYSERR if core threads are running
+ * @return GNUNET_OK on success, GNUNET_SYSERR if core threads are running
  *        and updates to the handler list are illegal!
  */
 int registerPlaintextHandler (const unsigned short type,
@@ -120,7 +120,7 @@
  * @param type the message type
  * @param callback the method to call if a message of
  *        that type is received
- * @return OK on success, SYSERR if there is a different
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there is a different
  *        handler for that type or if core threads are running
  *        and updates to the handler list are illegal!
  */
@@ -134,9 +134,9 @@
  *                    1 for ciphertext P2P,
  *                    2 for either plaintext or ciphertext P2P,
  *                    3 for client-server
- *        NO for ciphertext handlers, SYSERR for either
+ *        GNUNET_NO for ciphertext handlers, GNUNET_SYSERR for either
  * @return number of handlers registered, 0 for none,
- *        SYSERR for invalid value of handlerType
+ *        GNUNET_SYSERR for invalid value of handlerType
  */
 int isHandlerRegistered (unsigned short type, unsigned short handlerType);
 

Modified: GNUnet/src/server/startup.c
===================================================================
--- GNUnet/src/server/startup.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/server/startup.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -56,7 +56,8 @@
 #ifdef MINGW
   if (!cfg || GC_get_configuration_value_yesno (cfg,
                                                 "GNUNETD",
-                                                "WINSERVICE", NO) == YES)
+                                                "WINSERVICE",
+                                                GNUNET_NO) == GNUNET_YES)
     {
       /* If GNUnet runs as service, only the
          Service Control Manager is allowed
@@ -86,7 +87,7 @@
     }
 #endif
 
-  GNUNET_SHUTDOWN_INITIATE ();
+  GNUNET_shutdown_initiate ();
 }
 
 #ifdef MINGW
@@ -137,14 +138,14 @@
                                               "USER",
                                               "", &user) && strlen (user))
     {
-      if (OK != os_change_user (ectx, user))
+      if (GNUNET_OK != GNUNET_change_user (ectx, user))
         {
-          FREE (user);
-          return SYSERR;
+          GNUNET_free (user);
+          return GNUNET_SYSERR;
         }
     }
-  FREE (user);
-  return OK;
+  GNUNET_free (user);
+  return GNUNET_OK;
 }
 
 int
@@ -158,12 +159,12 @@
                                               "FDLIMIT",
                                               0, 65536, 1024, &limit))
     {
-      if (OK != os_set_fd_limit (ectx, (int) limit))
+      if (GNUNET_OK != GNUNET_set_fd_limit (ectx, (int) limit))
         {
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -255,9 +256,9 @@
 
   GC_get_configuration_value_filename (cfg, section, option, def, &fn);
   if (is_directory)
-    disk_directory_create (ectx, fn);
+    GNUNET_disk_directory_create (ectx, fn);
   else
-    disk_directory_create_for_file (ectx, fn);
+    GNUNET_disk_directory_create_for_file (ectx, fn);
   if ((0 != ACCESS (fn, F_OK)) && (mode == W_OK))
     {
       /* adjust check to see if directory is writable */
@@ -273,20 +274,20 @@
               GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
               _("Insufficient access permissions for `%s': %s\n"),
               fn, STRERROR (errno));
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
-  FREE (fn);
-  return OK;
+  GNUNET_free (fn);
+  return GNUNET_OK;
 }
 
-#define CHECK(a,b,c,d,e) if (OK != checkPermission(ectx, cfg, a, b, c, d, e)) 
return SYSERR;
+#define CHECK(a,b,c,d,e) if (GNUNET_OK != checkPermission(ectx, cfg, a, b, c, 
d, e)) return GNUNET_SYSERR;
 
 int
 checkPermissions (struct GE_Context *ectx, struct GC_Configuration *cfg)
 {
-  CHECK ("PATHS", "GNUNETD_HOME", "/var/lib/gnunet", YES, W_OK | X_OK);
-  CHECK ("GNUNETD", "LOGFILE", "$GNUNETD_HOME/daemon-logs", NO, W_OK);
+  CHECK ("PATHS", "GNUNETD_HOME", "/var/lib/gnunet", GNUNET_YES, W_OK | X_OK);
+  CHECK ("GNUNETD", "LOGFILE", "$GNUNETD_HOME/daemon-logs", GNUNET_NO, W_OK);
   /* these should only be checked if "fs" is actually
      loaded; we clearly should not check everything here
      that just might be used (MYSQL-CONFIG, F2F-FRIENDS),
@@ -294,10 +295,11 @@
      not great.  Would be nice if we could find a way to
      keep things decentralized and still do a nice job
      with reporting errors... */
-  CHECK ("FS", "DIR", "$GNUNETD_HOME/data/fs", YES, W_OK | X_OK);
+  CHECK ("FS", "DIR", "$GNUNETD_HOME/data/fs", GNUNET_YES, W_OK | X_OK);
   CHECK ("FS",
-         "INDEX-DIRECTORY", "$GNUNETD_HOME/data/shared", YES, W_OK | X_OK);
-  return OK;
+         "INDEX-DIRECTORY", "$GNUNETD_HOME/data/shared", GNUNET_YES,
+         W_OK | X_OK);
+  return GNUNET_OK;
 }
 
 /* end of startup.c */

Modified: GNUnet/src/server/tcpserver.c
===================================================================
--- GNUnet/src/server/tcpserver.c       2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/server/tcpserver.c       2007-11-23 11:51:54 UTC (rev 5742)
@@ -34,9 +34,9 @@
 #include "handler.h"
 #include "startup.h"
 
-#define DEBUG_TCPHANDLER NO
+#define DEBUG_TCPHANDLER GNUNET_NO
 
-#define TIME_HANDLERS NO
+#define TIME_HANDLERS GNUNET_NO
 
 /**
  * Array of the message handlers.
@@ -62,12 +62,12 @@
 /**
  * Mutex to guard access to the handler array.
  */
-static struct MUTEX *handlerlock;
+static struct GNUNET_Mutex *handlerlock;
 
 /**
  * The thread that waits for new connections.
  */
-static struct SelectHandle *selector;
+static struct GNUNET_SelectHandle *selector;
 
 static struct GE_Context *ectx;
 
@@ -79,41 +79,42 @@
 typedef struct ClientHandle
 {
 
-  struct SocketHandle *sock;
+  struct GNUNET_SocketHandle *sock;
 
 } ClientHandle;
 
 /**
  * Configuration...
  */
-static struct CIDRNetwork *trustedNetworks_ = NULL;
+static struct GNUNET_IPv4NetworkSet *trustedNetworks_ = NULL;
 
 /**
  * Is this IP labeled as trusted for CS connections?
  */
 static int
-isWhitelisted (IPaddr ip)
+isWhitelisted (GNUNET_IPv4Address ip)
 {
-  return check_ipv4_listed (trustedNetworks_, ip);
+  return GNUNET_check_ipv4_listed (trustedNetworks_, ip);
 }
 
 static int
-shutdownHandler (struct ClientHandle *client, const MESSAGE_HEADER * msg)
+shutdownHandler (struct ClientHandle *client,
+                 const GNUNET_MessageHeader * msg)
 {
   int ret;
 
-  if (ntohs (msg->size) != sizeof (MESSAGE_HEADER))
+  if (ntohs (msg->size) != sizeof (GNUNET_MessageHeader))
     {
       GE_LOG (NULL,
               GE_WARNING | GE_USER | GE_BULK,
               _("The `%s' request received from client is malformed.\n"),
               "shutdown");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   GE_LOG (NULL,
           GE_INFO | GE_USER | GE_REQUEST,
           "shutdown request accepted from client\n");
-  ret = sendTCPResultToClient (client, OK);
+  ret = sendTCPResultToClient (client, GNUNET_OK);
   shutdown_gnunetd (cfg, 0);
   return ret;
 }
@@ -121,11 +122,11 @@
 int
 registerClientExitHandler (ClientExitHandler callback)
 {
-  MUTEX_LOCK (handlerlock);
-  GROW (exitHandlers, exitHandlerCount, exitHandlerCount + 1);
+  GNUNET_mutex_lock (handlerlock);
+  GNUNET_array_grow (exitHandlers, exitHandlerCount, exitHandlerCount + 1);
   exitHandlers[exitHandlerCount - 1] = callback;
-  MUTEX_UNLOCK (handlerlock);
-  return OK;
+  GNUNET_mutex_unlock (handlerlock);
+  return GNUNET_OK;
 }
 
 int
@@ -133,107 +134,109 @@
 {
   int i;
 
-  MUTEX_LOCK (handlerlock);
+  GNUNET_mutex_lock (handlerlock);
   for (i = 0; i < exitHandlerCount; i++)
     {
       if (exitHandlers[i] == callback)
         {
           exitHandlers[i] = exitHandlers[exitHandlerCount - 1];
-          GROW (exitHandlers, exitHandlerCount, exitHandlerCount - 1);
-          MUTEX_UNLOCK (handlerlock);
-          return OK;
+          GNUNET_array_grow (exitHandlers, exitHandlerCount,
+                             exitHandlerCount - 1);
+          GNUNET_mutex_unlock (handlerlock);
+          return GNUNET_OK;
         }
     }
-  MUTEX_UNLOCK (handlerlock);
-  return SYSERR;
+  GNUNET_mutex_unlock (handlerlock);
+  return GNUNET_SYSERR;
 }
 
 static void *
 select_accept_handler (void *ah_cls,
-                       struct SelectHandle *sh,
-                       struct SocketHandle *sock,
+                       struct GNUNET_SelectHandle *sh,
+                       struct GNUNET_SocketHandle *sock,
                        const void *addr, unsigned int addr_len)
 {
   struct ClientHandle *session;
-  IPaddr ip;
+  GNUNET_IPv4Address ip;
   struct sockaddr_in *a;
 
   if (addr_len != sizeof (struct sockaddr_in))
     return NULL;
   a = (struct sockaddr_in *) addr;
-  memcpy (&ip, &a->sin_addr, sizeof (IPaddr));
+  memcpy (&ip, &a->sin_addr, sizeof (GNUNET_IPv4Address));
   if (!isWhitelisted (ip))
     return NULL;
-  session = MALLOC (sizeof (ClientHandle));
+  session = GNUNET_malloc (sizeof (ClientHandle));
   session->sock = sock;
   return session;
 }
 
 static void
 select_close_handler (void *ch_cls,
-                      struct SelectHandle *sh,
-                      struct SocketHandle *sock, void *sock_ctx)
+                      struct GNUNET_SelectHandle *sh,
+                      struct GNUNET_SocketHandle *sock, void *sock_ctx)
 {
   ClientHandle *session = sock_ctx;
   int i;
 
-  MUTEX_LOCK (handlerlock);
+  GNUNET_mutex_lock (handlerlock);
   for (i = 0; i < exitHandlerCount; i++)
     exitHandlers[i] (session);
-  MUTEX_UNLOCK (handlerlock);
-  FREE (session);
+  GNUNET_mutex_unlock (handlerlock);
+  GNUNET_free (session);
 }
 
 /**
  * Send a message to the client identified by the handle.  Note that
  * the core will typically buffer these messages as much as possible
- * and only return errors if it runs out of buffers.  Returning OK
+ * and only return errors if it runs out of buffers.  Returning GNUNET_OK
  * on the other hand does NOT confirm delivery since the actual
  * transfer happens asynchronously.
  *
- * @param force YES if this message MUST be queued
+ * @param force GNUNET_YES if this message MUST be queued
  */
 int
-sendToClient (struct ClientHandle *handle, const MESSAGE_HEADER * message,
-              int force)
+sendToClient (struct ClientHandle *handle,
+              const GNUNET_MessageHeader * message, int force)
 {
 #if DEBUG_TCPHANDLER
   GE_LOG (ectx,
           GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
           "%s: sending reply to client\n", __FUNCTION__);
 #endif
-  return select_write (selector, handle->sock, message, YES, force);
+  return GNUNET_select_write (selector, handle->sock, message, GNUNET_YES,
+                              force);
 }
 
 void
 terminateClientConnection (struct ClientHandle *sock)
 {
-  select_disconnect (selector, sock->sock);
+  GNUNET_select_disconnect (selector, sock->sock);
 }
 
 static int
 select_message_handler (void *mh_cls,
-                        struct SelectHandle *sh,
-                        struct SocketHandle *sock,
-                        void *sock_ctx, const MESSAGE_HEADER * msg)
+                        struct GNUNET_SelectHandle *sh,
+                        struct GNUNET_SocketHandle *sock,
+                        void *sock_ctx, const GNUNET_MessageHeader * msg)
 {
   struct ClientHandle *sender = sock_ctx;
   unsigned short ptyp;
   CSHandler callback;
 #if TIME_HANDLERS
-  cron_t start;
+  GNUNET_CronTime start;
 #endif
 
   ptyp = htons (msg->type);
-  MUTEX_LOCK (handlerlock);
+  GNUNET_mutex_lock (handlerlock);
   if (ptyp >= max_registeredType)
     {
       GE_LOG (ectx,
               GE_INFO | GE_USER | GE_BULK,
               "%s: Message of type %d not understood: no handler registered\n",
               __FUNCTION__, ptyp, max_registeredType);
-      MUTEX_UNLOCK (handlerlock);
-      return SYSERR;
+      GNUNET_mutex_unlock (handlerlock);
+      return GNUNET_SYSERR;
     }
   callback = handlers[ptyp];
   if (callback == NULL)
@@ -242,15 +245,15 @@
               GE_INFO | GE_USER | GE_BULK,
               "%s: Message of type %d not understood: no handler registered\n",
               __FUNCTION__, ptyp);
-      MUTEX_UNLOCK (handlerlock);
-      return SYSERR;
+      GNUNET_mutex_unlock (handlerlock);
+      return GNUNET_SYSERR;
     }
   else
     {
 #if TIME_HANDLERS
-      start = get_time ();
+      start = GNUNET_get_time ();
 #endif
-      if (OK != callback (sender, msg))
+      if (GNUNET_OK != callback (sender, msg))
         {
 #if 0
           GE_LOG (ectx,
@@ -258,19 +261,19 @@
                   "%s: Message of type %d caused error in handler\n",
                   __FUNCTION__, ptyp);
 #endif
-          MUTEX_UNLOCK (handlerlock);
-          return SYSERR;
+          GNUNET_mutex_unlock (handlerlock);
+          return GNUNET_SYSERR;
         }
 #if TIME_HANDLERS
-      if (get_time () - start > cronSECONDS)
+      if (GNUNET_get_time () - start > GNUNET_CRON_SECONDS)
         GE_LOG (ectx,
                 GE_INFO | GE_DEVELOPER | GE_IMMEDIATE,
                 "Handling message of type %u took %llu s\n",
-                ptyp, (get_time () - start) / cronSECONDS);
+                ptyp, (GNUNET_get_time () - start) / GNUNET_CRON_SECONDS);
 #endif
     }
-  MUTEX_UNLOCK (handlerlock);
-  return OK;
+  GNUNET_mutex_unlock (handlerlock);
+  return GNUNET_OK;
 }
 
 /**
@@ -298,14 +301,14 @@
 
   listenerPort = getGNUnetPort ();
   if (listenerPort == 0)
-    return SYSERR;
+    return GNUNET_SYSERR;
   listenerFD = SOCKET (PF_INET, SOCK_STREAM, 0);
   if (listenerFD < 0)
     {
       GE_LOG_STRERROR (ectx,
                        GE_FATAL | GE_ADMIN | GE_USER | GE_IMMEDIATE,
                        "socket");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   /* fill in the inet address structure */
   memset (&serverAddr, 0, sizeof (serverAddr));
@@ -324,24 +327,24 @@
               _("`%s' failed for port %d. Is gnunetd already running?\n"),
               "bind", listenerPort);
       CLOSE (listenerFD);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  selector = select_create ("tcpserver", NO, ectx, NULL, listenerFD, sizeof 
(struct sockaddr_in), 0,    /* no timeout */
-                            &select_message_handler,
-                            NULL,
-                            &select_accept_handler,
-                            NULL,
-                            &select_close_handler,
-                            NULL, 0 /* no memory quota */ ,
-                            256 /* max sockets */ );
+  selector = GNUNET_select_create ("tcpserver", GNUNET_NO, ectx, NULL, 
listenerFD, sizeof (struct sockaddr_in), 0,      /* no timeout */
+                                   &select_message_handler,
+                                   NULL,
+                                   &select_accept_handler,
+                                   NULL,
+                                   &select_close_handler,
+                                   NULL, 0 /* no memory quota */ ,
+                                   256 /* max sockets */ );
   if (selector == NULL)
     {
       CLOSE (listenerFD);       /* maybe closed already
-                                   depending on how select_create
+                                   depending on how GNUNET_select_create
                                    failed... */
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 int
@@ -353,20 +356,20 @@
                                    and other gnunet-tools that are
                                    not gnunetd */
   unregisterCSHandler (CS_PROTO_SHUTDOWN_REQUEST, &shutdownHandler);
-  GROW (handlers, max_registeredType, 0);
-  GROW (exitHandlers, exitHandlerCount, 0);
-  FREE (trustedNetworks_);
-  return OK;
+  GNUNET_array_grow (handlers, max_registeredType, 0);
+  GNUNET_array_grow (exitHandlers, exitHandlerCount, 0);
+  GNUNET_free (trustedNetworks_);
+  return GNUNET_OK;
 }
 
 void __attribute__ ((constructor)) gnunet_tcpserver_ltdl_init ()
 {
-  handlerlock = MUTEX_CREATE (YES);
+  handlerlock = GNUNET_mutex_create (GNUNET_YES);
 }
 
 void __attribute__ ((destructor)) gnunet_tcpserver_ltdl_fini ()
 {
-  MUTEX_DESTROY (handlerlock);
+  GNUNET_mutex_destroy (handlerlock);
   handlerlock = NULL;
 }
 
@@ -387,9 +390,9 @@
                                                "NETWORK",
                                                "TRUSTED",
                                                "127.0.0.0/8;", &ch))
-    return SYSERR;
+    return GNUNET_SYSERR;
   GE_ASSERT (ectx, ch != NULL);
-  trustedNetworks_ = parse_ipv4_network_specification (ectx, ch);
+  trustedNetworks_ = GNUNET_parse_ipv4_network_specification (ectx, ch);
   if (trustedNetworks_ == NULL)
     {
       GE_LOG (ectx,
@@ -397,22 +400,22 @@
               _
               ("Malformed network specification in the configuration in 
section `%s' for entry `%s': %s\n"),
               "NETWORK", "TRUSTED", ch);
-      FREE (ch);
-      return SYSERR;
+      GNUNET_free (ch);
+      return GNUNET_SYSERR;
     }
-  FREE (ch);
+  GNUNET_free (ch);
 
   registerCSHandler (CS_PROTO_SHUTDOWN_REQUEST, &shutdownHandler);
-  if ((NO == GC_get_configuration_value_yesno (cfg,
-                                               "TCPSERVER",
-                                               "DISABLE",
-                                               NO)) &&
-      (OK != startTCPServer ()))
+  if ((GNUNET_NO == GC_get_configuration_value_yesno (cfg,
+                                                      "TCPSERVER",
+                                                      "DISABLE",
+                                                      GNUNET_NO)) &&
+      (GNUNET_OK != startTCPServer ()))
     {
       doneTCPServer ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -423,10 +426,10 @@
 {
   if (selector != NULL)
     {
-      select_destroy (selector);
+      GNUNET_select_destroy (selector);
       selector = NULL;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -435,32 +438,32 @@
  * @param type the message type
  * @param callback the method to call if a message of
  *        that type is received, if the callback returns
- *        SYSERR, processing of the message is discontinued
+ *        GNUNET_SYSERR, processing of the message is discontinued
  *        afterwards (all other parts are ignored)
- * @return OK on success, SYSERR if there is already a
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there is already a
  *         handler for that type
  */
 int
 registerCSHandler (unsigned short type, CSHandler callback)
 {
-  MUTEX_LOCK (handlerlock);
+  GNUNET_mutex_lock (handlerlock);
   if (type < max_registeredType)
     {
       if (handlers[type] != NULL)
         {
-          MUTEX_UNLOCK (handlerlock);
+          GNUNET_mutex_unlock (handlerlock);
           GE_LOG (ectx,
                   GE_WARNING | GE_DEVELOPER | GE_BULK,
                   _("%s failed, message type %d already in use.\n"),
                   __FUNCTION__, type);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
     }
   else
-    GROW (handlers, max_registeredType, type + 8);
+    GNUNET_array_grow (handlers, max_registeredType, type + 8);
   handlers[type] = callback;
-  MUTEX_UNLOCK (handlerlock);
-  return OK;
+  GNUNET_mutex_unlock (handlerlock);
+  return GNUNET_OK;
 }
 
 /**
@@ -470,33 +473,33 @@
  * @param type the message type
  * @param callback the method to call if a message of
  *        that type is received, if the callback returns
- *        SYSERR, processing of the message is discontinued
+ *        GNUNET_SYSERR, processing of the message is discontinued
  *        afterwards (all other parts are ignored)
- * @return OK on success, SYSERR if there is no or another
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there is no or another
  *         handler for that type
  */
 int
 unregisterCSHandler (unsigned short type, CSHandler callback)
 {
-  MUTEX_LOCK (handlerlock);
+  GNUNET_mutex_lock (handlerlock);
   if (type < max_registeredType)
     {
       if (handlers[type] != callback)
         {
-          MUTEX_UNLOCK (handlerlock);
-          return SYSERR;        /* another handler present */
+          GNUNET_mutex_unlock (handlerlock);
+          return GNUNET_SYSERR; /* another handler present */
         }
       else
         {
           handlers[type] = NULL;
-          MUTEX_UNLOCK (handlerlock);
-          return OK;            /* success */
+          GNUNET_mutex_unlock (handlerlock);
+          return GNUNET_OK;     /* success */
         }
     }
   else
     {                           /* can't be there */
-      MUTEX_UNLOCK (handlerlock);
-      return SYSERR;
+      GNUNET_mutex_unlock (handlerlock);
+      return GNUNET_SYSERR;
     }
 }
 
@@ -505,18 +508,18 @@
  * TCP.
  * @param sock the TCP socket
  * @param ret the return value to send via TCP
- * @return SYSERR on error, OK if the return value was
+ * @return GNUNET_SYSERR on error, GNUNET_OK if the return value was
  *         send successfully
  */
 int
 sendTCPResultToClient (struct ClientHandle *sock, int ret)
 {
-  RETURN_VALUE_MESSAGE rv;
+  GNUNET_MessageReturnValue rv;
 
-  rv.header.size = htons (sizeof (RETURN_VALUE_MESSAGE));
+  rv.header.size = htons (sizeof (GNUNET_MessageReturnValue));
   rv.header.type = htons (CS_PROTO_RETURN_VALUE);
   rv.return_value = htonl (ret);
-  return sendToClient (sock, &rv.header, YES);
+  return sendToClient (sock, &rv.header, GNUNET_YES);
 }
 
 /**
@@ -524,14 +527,14 @@
  * TCP.
  * @param sock the TCP socket
  * @param message the error message to send via TCP
- * @return SYSERR on error, OK if the return value was
+ * @return GNUNET_SYSERR on error, GNUNET_OK if the return value was
  *         send successfully
  */
 int
 sendTCPErrorToClient (struct ClientHandle *sock,
                       GE_KIND kind, const char *message)
 {
-  RETURN_ERROR_MESSAGE *rv;
+  GNUNET_MessageReturnErrorMessage *rv;
   size_t msgLen;
   int ret;
 
@@ -539,14 +542,14 @@
   msgLen = ((msgLen + 3) >> 2) << 2;
   if (msgLen > 60000)
     msgLen = 60000;
-  rv = MALLOC (sizeof (RETURN_ERROR_MESSAGE) + msgLen);
-  memset (rv, 0, sizeof (RETURN_ERROR_MESSAGE) + msgLen);
-  rv->header.size = htons (sizeof (MESSAGE_HEADER) + msgLen);
+  rv = GNUNET_malloc (sizeof (GNUNET_MessageReturnErrorMessage) + msgLen);
+  memset (rv, 0, sizeof (GNUNET_MessageReturnErrorMessage) + msgLen);
+  rv->header.size = htons (sizeof (GNUNET_MessageHeader) + msgLen);
   rv->header.type = htons (CS_PROTO_RETURN_ERROR);
   rv->kind = htonl (kind);
   memcpy (&rv[1], message, strlen (message));
-  ret = sendToClient (sock, &rv->header, YES);
-  FREE (rv);
+  ret = sendToClient (sock, &rv->header, GNUNET_YES);
+  GNUNET_free (rv);
   return ret;
 }
 
@@ -560,16 +563,16 @@
 unsigned int
 isCSHandlerRegistered (unsigned short type)
 {
-  MUTEX_LOCK (handlerlock);
+  GNUNET_mutex_lock (handlerlock);
   if (type < max_registeredType)
     {
       if (handlers[type] != NULL)
         {
-          MUTEX_UNLOCK (handlerlock);
+          GNUNET_mutex_unlock (handlerlock);
           return 1;
         }
     }
-  MUTEX_UNLOCK (handlerlock);
+  GNUNET_mutex_unlock (handlerlock);
   return 0;
 }
 

Modified: GNUnet/src/server/tcpserver.h
===================================================================
--- GNUnet/src/server/tcpserver.h       2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/server/tcpserver.h       2007-11-23 11:51:54 UTC (rev 5742)
@@ -31,7 +31,7 @@
 
 /**
  * Initialize the TCP port and listen for incoming client connections.
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int initTCPServer (struct GE_Context *ectx, struct GC_Configuration *cfg);
 
@@ -42,7 +42,7 @@
 
 /**
  * Shutdown the module.
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int doneTCPServer (void);
 
@@ -52,9 +52,9 @@
  * @param type the message type
  * @param callback the method to call if a message of
  *        that type is received, if the callback returns
- *        SYSERR, processing of the message is discontinued
+ *        GNUNET_SYSERR, processing of the message is discontinued
  *        afterwards (all other parts are ignored)
- * @return OK on success, SYSERR if there is already a
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there is already a
  *         handler for that type
  */
 int registerCSHandler (unsigned short type, CSHandler callback);
@@ -65,9 +65,9 @@
  * @param type the message type
  * @param callback the method to call if a message of
  *        that type is received, if the callback returns
- *        SYSERR, processing of the message is discontinued
+ *        GNUNET_SYSERR, processing of the message is discontinued
  *        afterwards (all other parts are ignored)
- * @return OK on success, SYSERR if there is no or another
+ * @return GNUNET_OK on success, GNUNET_SYSERR if there is no or another
  *         handler for that type
  */
 int unregisterCSHandler (unsigned short type, CSHandler callback);
@@ -79,12 +79,12 @@
 /**
  * Send a message to the client identified by the handle.  Note that
  * the core will typically buffer these messages as much as possible
- * and only return SYSERR if it runs out of buffers.  Returning OK
+ * and only return GNUNET_SYSERR if it runs out of buffers.  Returning 
GNUNET_OK
  * on the other hand does NOT confirm delivery since the actual
  * transfer happens asynchronously.
  */
 int sendToClient (struct ClientHandle *handle,
-                  const MESSAGE_HEADER * message, int force);
+                  const GNUNET_MessageHeader * message, int force);
 
 
 /**
@@ -92,7 +92,7 @@
  * TCP.
  * @param sock the TCP socket
  * @param ret the return value to send via TCP
- * @return SYSERR on error, OK if the return value was
+ * @return GNUNET_SYSERR on error, GNUNET_OK if the return value was
  *         send successfully
  */
 int sendTCPResultToClient (struct ClientHandle *sock, int ret);
@@ -102,7 +102,7 @@
  * TCP.
  * @param sock the TCP socket
  * @param message the error message to send via TCP
- * @return SYSERR on error, OK if the return value was
+ * @return GNUNET_SYSERR on error, GNUNET_OK if the return value was
  *         send successfully
  */
 int sendTCPErrorToClient (struct ClientHandle *sock,

Modified: GNUnet/src/server/version.c
===================================================================
--- GNUnet/src/server/version.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/server/version.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -52,9 +52,9 @@
   val = NULL;
   GC_get_configuration_value_string (cfg, section, part, "", &val);
   if (val == NULL)
-    val = STRDUP ("");
+    val = GNUNET_strdup ("");
   len += strlen (val) + 2;
-  tmp = MALLOC (len);
+  tmp = GNUNET_malloc (len);
   strcpy (tmp, *string);
   strcat (tmp, section);
   strcat (tmp, ":");
@@ -62,26 +62,26 @@
   strcat (tmp, "=");
   strcat (tmp, val);
   strcat (tmp, ";");
-  FREE (val);
-  FREE (*string);
+  GNUNET_free (val);
+  GNUNET_free (*string);
   *string = tmp;
 }
 
 /**
- * Get the hash code that concatenated with the
+ * Get the GNUNET_hash code that concatenated with the
  * current version defines the current configuration.
  *
- * The hash is determined from the configuration file,
+ * The GNUNET_hash is determined from the configuration file,
  * since changes to certain values there will also
  * require us to run gnunet-update!
  */
 static void
-getVersionHash (struct GC_Configuration *cfg, EncName * enc)
+getVersionHash (struct GC_Configuration *cfg, GNUNET_EncName * enc)
 {
-  HashCode512 hc;
+  GNUNET_HashCode hc;
   char *string;
 
-  string = STRDUP ("");
+  string = GNUNET_strdup ("");
   /* yes, this is a bit ugly since we break the isolation between core
      and apps, but adding code to query the apps which configuration
      changes require gnunet-update feels like overkill for now; one
@@ -90,9 +90,9 @@
   dyncat (cfg, &string, "GNUNETD", "APPLICATIONS");
   dyncat (cfg, &string, "FS", "QUOTA");
   dyncat (cfg, &string, "MODULES", "sqstore");
-  hash (string, strlen (string), &hc);
-  hash2enc (&hc, enc);
-  FREE (string);
+  GNUNET_hash (string, strlen (string), &hc);
+  GNUNET_hash_to_enc (&hc, enc);
+  GNUNET_free (string);
 }
 
 static char *
@@ -108,28 +108,28 @@
                                                  VAR_DAEMON_DIRECTORY, &en))
     return NULL;
   GE_ASSERT (ectx, en != NULL);
-  cn = MALLOC (strlen (en) + strlen (VERSIONFILE) + 1);
+  cn = GNUNET_malloc (strlen (en) + strlen (VERSIONFILE) + 1);
   strcpy (cn, en);
   strcat (cn, VERSIONDIR);
-  disk_directory_create (ectx, cn);
+  GNUNET_disk_directory_create (ectx, cn);
   strcpy (cn, en);
   strcat (cn, VERSIONFILE);
-  FREE (en);
+  GNUNET_free (en);
   return cn;
 }
 
-#define MAX_VS sizeof(EncName) + 64
+#define MAX_VS sizeof(GNUNET_EncName) + 64
 
 /**
  * Check if we are up-to-date.
- * @return OK if we are
+ * @return GNUNET_OK if we are
  */
 int
 checkUpToDate (struct GE_Context *ectx, struct GC_Configuration *cfg)
 {
   char version[MAX_VS];
   int len;
-  EncName enc;
+  GNUNET_EncName enc;
   char *fn;
 
   fn = getVersionFileName (ectx, cfg);
@@ -139,28 +139,29 @@
               GE_ERROR | GE_USER | GE_BULK,
               _
               ("Failed to determine filename used to store GNUnet version 
information!\n"));
-      return OK;                /* uh uh */
+      return GNUNET_OK;         /* uh uh */
     }
-  if (disk_file_test (ectx, fn) != YES)
+  if (GNUNET_disk_file_test (ectx, fn) != GNUNET_YES)
     {
-      FREE (fn);
+      GNUNET_free (fn);
       upToDate (ectx, cfg);     /* first start */
-      return OK;
+      return GNUNET_OK;
     }
-  len = disk_file_read (ectx, fn, MAX_VS, version);
-  FREE (fn);
+  len = GNUNET_disk_file_read (ectx, fn, MAX_VS, version);
+  GNUNET_free (fn);
   if (len == -1)
     {                           /* should never happen -- file should exist */
       upToDate (ectx, cfg);     /* first start */
-      return OK;
+      return GNUNET_OK;
     }
-  if ((len != strlen (VERSION) + 1 + sizeof (EncName)) ||
+  if ((len != strlen (VERSION) + 1 + sizeof (GNUNET_EncName)) ||
       (0 != memcmp (VERSION, version, strlen (VERSION) + 1)))
-    return SYSERR;              /* wrong version */
+    return GNUNET_SYSERR;       /* wrong version */
   getVersionHash (cfg, &enc);
-  if (0 != memcmp (&enc, &version[strlen (VERSION) + 1], sizeof (EncName)))
-    return SYSERR;              /* wrong hash */
-  return OK;
+  if (0 !=
+      memcmp (&enc, &version[strlen (VERSION) + 1], sizeof (GNUNET_EncName)))
+    return GNUNET_SYSERR;       /* wrong GNUNET_hash */
+  return GNUNET_OK;
 }
 
 /**
@@ -172,18 +173,18 @@
 {
   char version[MAX_VS];
   int len;
-  EncName enc;
+  GNUNET_EncName enc;
   char *fn;
 
   fn = getVersionFileName (ectx, cfg);
-  len = strlen (VERSION) + 1 + sizeof (EncName);
+  len = strlen (VERSION) + 1 + sizeof (GNUNET_EncName);
   GE_ASSERT (ectx, len < MAX_VS);
   memcpy (version, VERSION, strlen (VERSION) + 1);
   getVersionHash (cfg, &enc);
-  memcpy (&version[strlen (VERSION) + 1], &enc, sizeof (EncName));
+  memcpy (&version[strlen (VERSION) + 1], &enc, sizeof (GNUNET_EncName));
   UNLINK (fn);
-  disk_file_write (ectx, fn, version, len, "600");
-  FREE (fn);
+  GNUNET_disk_file_write (ectx, fn, version, len, "600");
+  GNUNET_free (fn);
 }
 
 /* end of version.c */

Modified: GNUnet/src/server/version.h
===================================================================
--- GNUnet/src/server/version.h 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/server/version.h 2007-11-23 11:51:54 UTC (rev 5742)
@@ -31,7 +31,7 @@
 
 /**
  * Check if we are up-to-date.
- * @return OK if we are
+ * @return GNUNET_OK if we are
  */
 int checkUpToDate (struct GE_Context *ectx, struct GC_Configuration *cfg);
 

Modified: GNUnet/src/setup/Makefile.am
===================================================================
--- GNUnet/src/setup/Makefile.am        2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/Makefile.am        2007-11-23 11:51:54 UTC (rev 5742)
@@ -31,15 +31,10 @@
 
 gnunet_setup_LDADD = \
  $(top_builddir)/src/setup/lib/libgnunetsetup.la \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la 
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 gnunet_win_tool_SOURCE = \
  gnunet-win-tool.c
 
 gnunet_win_tool_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la 
+ $(top_builddir)/src/util/libgnunetutil.la 
\ No newline at end of file

Modified: GNUnet/src/setup/gnunet-setup.c
===================================================================
--- GNUnet/src/setup/gnunet-setup.c     2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/gnunet-setup.c     2007-11-23 11:51:54 UTC (rev 5742)
@@ -27,14 +27,12 @@
 #include "gnunet_util.h"
 #include "gnunet_directories.h"
 #include "gnunet_setup_lib.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error_loggers.h"
 
 #include "platform.h"
 
 typedef int (*ConfigurationPluginMain) (int argc,
                                         char *const *argv,
-                                        struct PluginHandle * self,
+                                        struct GNUNET_PluginHandle * self,
                                         struct GE_Context * ectx,
                                         struct GC_Configuration * cfg,
                                         struct GNS_Context * gns,
@@ -53,15 +51,15 @@
 /**
  * All gnunet-setup command line options
  */
-static struct CommandLineOption gnunetsetupOptions[] = {
-  COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),  /* -c */
+static struct GNUNET_CommandLineOption gnunetsetupOptions[] = {
+  GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&cfgFilename),   /* -c */
   {'d', "daemon", NULL,
    gettext_noop ("generate configuration for gnunetd, the GNUnet daemon"),
-   0, &gnunet_getopt_configure_set_one, &config_daemon},
-  COMMAND_LINE_OPTION_HELP (gettext_noop ("Tool to setup GNUnet.")),    /* -h 
*/
-  COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_VERBOSE,
-  COMMAND_LINE_OPTION_END,
+   0, &GNUNET_getopt_configure_set_one, &config_daemon},
+  GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Tool to setup GNUnet.")),    
 /* -h */
+  GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION), /* -v */
+  GNUNET_COMMAND_LINE_OPTION_VERBOSE,
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 static void
@@ -82,7 +80,8 @@
     return;
   if ((pos->section == NULL) || (pos->option == NULL))
     return;
-  if (NO == GC_have_configuration_value (cfg, pos->section, pos->option))
+  if (GNUNET_NO ==
+      GC_have_configuration_value (cfg, pos->section, pos->option))
     {
       val = GNS_get_default_value_as_string (pos->type, &pos->value);
       if (val != NULL)
@@ -90,7 +89,7 @@
           GC_set_configuration_value_string (cfg,
                                              ectx,
                                              pos->section, pos->option, val);
-          FREE (val);
+          GNUNET_free (val);
         }
     }
 }
@@ -101,20 +100,20 @@
             int argc, char *const *argv, const char *filename)
 {
   ConfigurationPluginMain mptr;
-  struct PluginHandle *library;
+  struct GNUNET_PluginHandle *library;
 
-  library = os_plugin_load (ectx, "libgnunet", module);
+  library = GNUNET_plugin_load (ectx, "libgnunet", module);
   if (!library)
-    return SYSERR;
-  mptr = os_plugin_resolve_function (library, mainfunc, YES);
+    return GNUNET_SYSERR;
+  mptr = GNUNET_plugin_resolve_function (library, mainfunc, GNUNET_YES);
   if (!mptr)
     {
-      os_plugin_unload (library);
-      return SYSERR;
+      GNUNET_plugin_unload (library);
+      return GNUNET_SYSERR;
     }
   mptr (argc, argv, library, ectx, cfg, gns, filename, config_daemon);
-  os_plugin_unload (library);
-  return YES;
+  GNUNET_plugin_unload (library);
+  return GNUNET_YES;
 }
 
 static const char *INFO = "gnunet-setup [OPTIONS] config|generate-defaults"
@@ -151,15 +150,15 @@
   char *specname;
   int i;
 
-  ectx = GE_create_context_stderr (NO,
+  ectx = GE_create_context_stderr (GNUNET_NO,
                                    GE_WARNING | GE_ERROR | GE_FATAL |
                                    GE_USER | GE_ADMIN | GE_DEVELOPER |
                                    GE_IMMEDIATE | GE_BULK);
   GE_setDefaultContext (ectx);
-  os_init (ectx);
-  cfg = GC_create_C_impl ();
+  GNUNET_os_init (ectx);
+  cfg = GC_create ();
   GE_ASSERT (ectx, cfg != NULL);
-  i = gnunet_parse_options (INFO,
+  i = GNUNET_parse_options (INFO,
                             ectx,
                             cfg,
                             gnunetsetupOptions, (unsigned int) argc, argv);
@@ -192,14 +191,14 @@
       operation = argv[i];
     }
   if (NULL != strstr (operation, "wizard"))
-    config_daemon = YES;        /* wizard implies daemon! */
+    config_daemon = GNUNET_YES; /* wizard implies daemon! */
   if (cfgFilename == NULL)
     cfgFilename = config_daemon
-      ? STRDUP (DEFAULT_DAEMON_CONFIG_FILE)
-      : STRDUP (DEFAULT_CLIENT_CONFIG_FILE);
-  dirname = string_expandFileName (ectx, cfgFilename);
-  FREE (cfgFilename);
-  cfgFilename = STRDUP (dirname);
+      ? GNUNET_strdup (DEFAULT_DAEMON_CONFIG_FILE)
+      : GNUNET_strdup (DEFAULT_CLIENT_CONFIG_FILE);
+  dirname = GNUNET_expand_file_name (ectx, cfgFilename);
+  GNUNET_free (cfgFilename);
+  cfgFilename = GNUNET_strdup (dirname);
   i = strlen (dirname) - 1;
   while (i > -1)
     {
@@ -211,44 +210,46 @@
         }
       i--;
     }
-  disk_directory_create (ectx, dirname);
+  GNUNET_disk_directory_create (ectx, dirname);
   if (((0 != ACCESS (cfgFilename, W_OK)) &&
        ((errno != ENOENT) || (0 != ACCESS (dirname, W_OK)))))
     GE_DIE_STRERROR_FILE (ectx,
                           GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
                           "access", dirname);
-  FREE (dirname);
+  GNUNET_free (dirname);
 
   if (0 == ACCESS (cfgFilename, F_OK))
     GC_parse_configuration (cfg, cfgFilename);
-  dirname = os_get_installation_path (IPK_DATADIR);
+  dirname = GNUNET_get_installation_path (GNUNET_IPK_DATADIR);
   GE_ASSERT (ectx, dirname != NULL);
-  specname = MALLOC (strlen (dirname) + strlen ("config-daemon.scm") + 1);
+  specname =
+    GNUNET_malloc (strlen (dirname) + strlen ("config-daemon.scm") + 1);
   strcpy (specname, dirname);
-  FREE (dirname);
+  GNUNET_free (dirname);
   if (config_daemon)
     strcat (specname, "config-daemon.scm");
   else
     strcat (specname, "config-client.scm");
   gns = GNS_load_specification (ectx, cfg, specname);
-  FREE (specname);
+  GNUNET_free (specname);
   if (gns == NULL)
     {
       GC_free (cfg);
       GE_free_context (ectx);
-      FREE (cfgFilename);
+      GNUNET_free (cfgFilename);
       return -1;
     }
   gns2cfg (GNS_get_tree (gns));
 
-  done = NO;
+  done = GNUNET_NO;
   i = 0;
-  while ((done == NO) && (modules[i] != NULL))
+  while ((done == GNUNET_NO) && (modules[i] != NULL))
     {
       if (strcmp (operation, modules[i]) == 0)
         {
           if (dyn_config (modules[i + 1],
-                          modules[i + 2], argc, argv, cfgFilename) != YES)
+                          modules[i + 2], argc, argv,
+                          cfgFilename) != GNUNET_YES)
             {
               GE_LOG (ectx,
                       GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
@@ -256,18 +257,18 @@
               GNS_free_specification (gns);
               GC_free (cfg);
               GE_free_context (ectx);
-              FREE (cfgFilename);
+              GNUNET_free (cfgFilename);
               return -1;
             }
           else
             {
-              done = YES;
+              done = GNUNET_YES;
             }
         }
       i += 3;
     }
-  FREE (cfgFilename);
-  if (done == NO)
+  GNUNET_free (cfgFilename);
+  if (done == GNUNET_NO)
     {
       fprintf (stderr, _("Unknown operation `%s'\n"), operation);
       fprintf (stderr, _("Use --help to get a list of options.\n"));

Modified: GNUnet/src/setup/gnunet-win-tool.c
===================================================================
--- GNUnet/src/setup/gnunet-win-tool.c  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/gnunet-win-tool.c  2007-11-23 11:51:54 UTC (rev 5742)
@@ -25,10 +25,7 @@
  */
 
 #include "platform.h"
-#include "gnunet_util_os.h"
-#include "gnunet_util_crypto.h"
-#include "gnunet_util_error_loggers.h"
-
+#include "gnunet_util.h"
 #include <conio.h>
 
 #define WINTOOL_VERSION "0.1.0"
@@ -50,24 +47,24 @@
 /**
  * All gnunet-win-tool command line options
  */
-static struct CommandLineOption gnunetwinOptions[] = {
+static struct GNUNET_CommandLineOption gnunetwinOptions[] = {
   {'n', "netadapters", "network adapters",
    gettext_noop ("list all network adapters"),
-   0, &gnunet_getopt_configure_set_one, &bPrintAdapters},
+   0, &GNUNET_getopt_configure_set_one, &bPrintAdapters},
   {'i', "install", "install service",
    gettext_noop ("install GNUnet as Windows service"),
-   0, &gnunet_getopt_configure_set_one, &bInstall},
+   0, &GNUNET_getopt_configure_set_one, &bInstall},
   {'u', "uninstall", "uninstall service",
    gettext_noop ("uninstall GNUnet service"),
-   0, &gnunet_getopt_configure_set_one, &bUninstall},
+   0, &GNUNET_getopt_configure_set_one, &bUninstall},
   {'C', "increase-connections", "increase connections",
    gettext_noop ("increase the maximum number of TCP/IP connections"),
-   0, &gnunet_getopt_configure_set_one, &bConn},
+   0, &GNUNET_getopt_configure_set_one, &bConn},
   {'R', "filehash", "hash",
    gettext_noop ("display a file's hash value"),
-   1, &gnunet_getopt_configure_set_string, &hashFile},
+   1, &GNUNET_getopt_configure_set_string, &hashFile},
   COMMAND_LINE_OPTION_VERSION (WINTOOL_VERSION),        /* -v */
-  COMMAND_LINE_OPTION_END,
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 /**
@@ -207,7 +204,7 @@
   fseek (pFile, 0, SEEK_SET);
   fread (pMem, 1, lMem, pFile);
 
-  switch (iCrc = crc32N (pMem, lMem))
+  switch (iCrc = GNUNET_crc32_n (pMem, lMem))
     {
     case 2151852539:
       memcpy (pMem + 0x130, chunk1, 4);
@@ -314,17 +311,17 @@
 }
 
 /**
- * Print the hash of a file
+ * Print the GNUNET_hash of a file
  */
 void
 doHash ()
 {
-  HashCode512 code;
-  EncName hex;
+  GNUNET_HashCode code;
+  GNUNET_EncName hex;
   char *c;
 
-  getFileHash (ectx, hashFile, &code);
-  hash2enc (&code, &hex);
+  GNUNET_hash_file (ectx, hashFile, &code);
+  GNUNET_hash_to_enc (&code, &hex);
   printf ("SHA512(%s)= ", hashFile);
 
   /* Flip byte order */
@@ -336,7 +333,7 @@
       c += 2;
     }
   putchar ('\n');
-  FREE (hashFile);
+  GNUNET_free (hashFile);
   hashFile = NULL;
 }
 
@@ -352,18 +349,18 @@
 {
   int res;
 
-  res = OK;
+  res = GNUNET_OK;
 
   /* startup */
-  ectx = GE_create_context_stderr (NO,
+  ectx = GE_create_context_stderr (GNUNET_NO,
                                    GE_WARNING | GE_ERROR | GE_FATAL |
                                    GE_USER | GE_ADMIN | GE_DEVELOPER |
                                    GE_IMMEDIATE | GE_BULK);
-  res = gnunet_parse_options ("gnunet-win-tool [OPTIONS] [KEYWORDS]",
+  res = GNUNET_parse_options ("gnunet-win-tool [OPTIONS] [KEYWORDS]",
                               ectx,
                               NULL,
                               gnunetwinOptions, (unsigned int) argc, argv);
-  if (res == SYSERR)
+  if (res == GNUNET_SYSERR)
     {
       GE_free_context (ectx);
       return -1;
@@ -382,7 +379,7 @@
 
   GE_free_context (ectx);
 
-  return (res == OK) ? 0 : 1;
+  return (res == GNUNET_OK) ? 0 : 1;
 }
 
 /* end of gnunet-win-tool.c */

Modified: GNUnet/src/setup/gtk/gconf.c
===================================================================
--- GNUnet/src/setup/gtk/gconf.c        2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/gtk/gconf.c        2007-11-23 11:51:54 UTC (rev 5742)
@@ -164,7 +164,7 @@
               i++;
               j *= 2;
             }
-          tmp = MALLOC (tmpl);
+          tmp = GNUNET_malloc (tmpl);
           /* For now, only allow multiple choice for less than 12 entries...
              (10 are needed for applications!) */
           if (i < 12)
@@ -192,7 +192,7 @@
                        pos->option, i);
               GE_BREAK (NULL, 0);
             }
-          FREE (tmp);
+          GNUNET_free (tmp);
           gtk_tree_store_set (model,
                               &it,
                               SETUP_TEXT_VIS, TRUE,
@@ -220,8 +220,8 @@
           break;
         case GNS_Double:
           cmodel = gtk_list_store_new (1, G_TYPE_STRING);
-          SNPRINTF (defStr, 128, "%f", pos->value.Double.def);
-          SNPRINTF (valStr, 128, "%f", pos->value.Double.val);
+          GNUNET_snprintf (defStr, 128, "%f", pos->value.Double.def);
+          GNUNET_snprintf (valStr, 128, "%f", pos->value.Double.val);
           gtk_list_store_insert_with_values (cmodel, &it2, -1, 0, valStr, -1);
           if (0 != strcmp (valStr, defStr))
             {
@@ -238,8 +238,8 @@
           break;
         case GNS_UInt64:
           cmodel = gtk_list_store_new (1, G_TYPE_STRING);
-          SNPRINTF (defStr, 128, "%llu", pos->value.UInt64.def);
-          SNPRINTF (valStr, 128, "%llu", pos->value.UInt64.val);
+          GNUNET_snprintf (defStr, 128, "%llu", pos->value.UInt64.def);
+          GNUNET_snprintf (valStr, 128, "%llu", pos->value.UInt64.val);
           gtk_list_store_insert_with_values (cmodel, &it2, -1, 0, valStr, -1);
           if (0 != strcmp (valStr, defStr))
             {
@@ -279,7 +279,7 @@
 {
   CR_Context *ctx = user_data;
 
-  GROW (ctx->paths, ctx->size, ctx->size + 1);
+  GNUNET_array_grow (ctx->paths, ctx->size, ctx->size + 1);
   ctx->paths[ctx->size - 1] = gtk_tree_path_to_string (path);
 }
 
@@ -336,7 +336,7 @@
       gtk_tree_path_free (path);
       free (crCTX.paths[i]);
     }
-  GROW (crCTX.paths, crCTX.size, 0);
+  GNUNET_array_grow (crCTX.paths, crCTX.size, 0);
 }
 
 static void
@@ -509,7 +509,7 @@
  * needs saving and possibly save configuration or do not
  * exit.
  *
- * @return TRUE to NOT exit (i.e. user hits cancel on save YES/NO/CANCEL).
+ * @return TRUE to NOT exit (i.e. user hits cancel on save 
GNUNET_YES/GNUNET_NO/CANCEL).
  */
 gboolean
 on_main_window_delete_eventsetup_gtk ()
@@ -563,7 +563,7 @@
 
 
 int
-gconf_main_post_init (struct PluginHandle *self,
+gconf_main_post_init (struct GNUNET_PluginHandle *self,
                       struct GE_Context *e,
                       struct GC_Configuration *c,
                       struct GNS_Context *gns,
@@ -599,7 +599,7 @@
 int
 gconf_mainsetup_gtk (int argc,
                      const char **argv,
-                     struct PluginHandle *self,
+                     struct GNUNET_PluginHandle *self,
                      struct GE_Context *ectx,
                      struct GC_Configuration *cfg,
                      struct GNS_Context *gns,

Modified: GNUnet/src/setup/gtk/gconf.h
===================================================================
--- GNUnet/src/setup/gtk/gconf.h        2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/gtk/gconf.h        2007-11-23 11:51:54 UTC (rev 5742)
@@ -30,13 +30,13 @@
 
 int gconf_mainsetup_gtk (int argc,
                          const char **argv,
-                         struct PluginHandle *self,
+                         struct GNUNET_PluginHandle *self,
                          struct GE_Context *ectx,
                          struct GC_Configuration *cfg,
                          struct GNS_Context *gns,
                          const char *filename, int is_daemon);
 
-int gconf_main_post_init (struct PluginHandle *lib,
+int gconf_main_post_init (struct GNUNET_PluginHandle *lib,
                           struct GE_Context *e,
                           struct GC_Configuration *c,
                           struct GNS_Context *gns,

Modified: GNUnet/src/setup/gtk/glade_support.c
===================================================================
--- GNUnet/src/setup/gtk/glade_support.c        2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/setup/gtk/glade_support.c        2007-11-23 11:51:54 UTC (rev 
5742)
@@ -25,7 +25,7 @@
 /**
  * Handle to the dynamic library (which contains this code)
  */
-static struct PluginHandle *library;
+static struct GNUNET_PluginHandle *library;
 
 /**
  * Current glade handle.
@@ -52,11 +52,11 @@
   char *path;
   char *gladeFile;
 
-  path = os_get_installation_path (IPK_DATADIR);
-  gladeFile = MALLOC (strlen (path) + 20);
+  path = GNUNET_get_installation_path (GNUNET_IPK_DATADIR);
+  gladeFile = GNUNET_malloc (strlen (path) + 20);
   strcpy (gladeFile, path);
   strcat (gladeFile, "gnunet-setup.glade");
-  FREE (path);
+  GNUNET_free (path);
   return gladeFile;
 }
 
@@ -72,7 +72,7 @@
   void *method;
 
   GE_ASSERT (NULL, xml != NULL);
-  method = os_plugin_resolve_function (library, handler_name, YES);
+  method = GNUNET_plugin_resolve_function (library, handler_name, GNUNET_YES);
   if (method == NULL)
     return;
   glade_xml_signal_connect (xml, handler_name, (GCallback) method);
@@ -90,7 +90,7 @@
     GE_DIE_STRERROR_FILE (NULL,
                           GE_USER | GE_ADMIN | GE_FATAL | GE_IMMEDIATE,
                           "open", gladeFile);
-  FREE (gladeFile);
+  GNUNET_free (gladeFile);
   glade_xml_signal_autoconnect_full (ret, &connector, ret);
   return ret;
 }
@@ -125,7 +125,7 @@
     GE_DIE_STRERROR_FILE (NULL,
                           GE_USER | GE_ADMIN | GE_FATAL | GE_IMMEDIATE,
                           "open", gladeFile);
-  FREE (gladeFile);
+  GNUNET_free (gladeFile);
   glade_xml_signal_autoconnect_full (myXML, &connector, myXML);
   msgSave = glade_xml_get_widget (myXML, name);
   gtk_widget_show (msgSave);
@@ -133,7 +133,7 @@
 }
 
 void
-setLibrary (struct PluginHandle *lib)
+setLibrary (struct GNUNET_PluginHandle *lib)
 {
   library = lib;
 }

Modified: GNUnet/src/setup/gtk/glade_support.h
===================================================================
--- GNUnet/src/setup/gtk/glade_support.h        2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/setup/gtk/glade_support.h        2007-11-23 11:51:54 UTC (rev 
5742)
@@ -31,7 +31,7 @@
 
 void destroyMainXML (void);
 
-void setLibrary (struct PluginHandle *lib);
+void setLibrary (struct GNUNET_PluginHandle *lib);
 
 GtkWidget *get_xml (const char *dialog_name);
 

Modified: GNUnet/src/setup/gtk/ngconf.c
===================================================================
--- GNUnet/src/setup/gtk/ngconf.c       2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/gtk/ngconf.c       2007-11-23 11:51:54 UTC (rev 5742)
@@ -85,7 +85,7 @@
 link_visibility (struct GNS_Tree *pos, GtkWidget * w)
 {
   struct P2W *pw;
-  pw = MALLOC (sizeof (struct P2W));
+  pw = GNUNET_malloc (sizeof (struct P2W));
   pw->pos = pos;
   pw->w = w;
   pw->next = pws;
@@ -134,7 +134,7 @@
   opt = g_object_get_data (G_OBJECT (button), "MC-value");
   if (gtk_toggle_button_get_active (button))
     {
-      ret = MALLOC (strlen (val) + strlen (opt) + 2);
+      ret = GNUNET_malloc (strlen (val) + strlen (opt) + 2);
       strcpy (ret, val);
       strcat (ret, " ");
       strcat (ret, opt);
@@ -147,7 +147,7 @@
                (s[strlen (opt)] != ' ')) || ((s != val) && (s[-1] != ' '))))
         v = s + 1;
       GE_ASSERT (NULL, s != NULL);
-      ret = MALLOC (strlen (val));
+      ret = GNUNET_malloc (strlen (val));
       s[0] = '\0';
       if (s != val)
         s[-1] = '\0';           /* kill space */
@@ -156,8 +156,8 @@
     }
   GC_set_configuration_value_string (cfg,
                                      ectx, pos->section, pos->option, ret);
-  FREE (ret);
-  FREE (val);
+  GNUNET_free (ret);
+  GNUNET_free (val);
   update_visibility ();
 }
 
@@ -262,7 +262,7 @@
 
       break;
     case GNS_Double:
-      SNPRINTF (defStr, 128, "%llf", pos->value.Double.val);
+      GNUNET_snprintf (defStr, 128, "%llf", pos->value.Double.val);
       w = gtk_entry_new ();
       tooltip (w, pos->help);
       label = gtk_label_new (pos->description);
@@ -398,7 +398,7 @@
  * needs saving and possibly save configuration or do not
  * exit.
  *
- * @return TRUE to NOT exit (i.e. user hits cancel on save YES/NO/CANCEL).
+ * @return TRUE to NOT exit (i.e. user hits cancel on save 
GNUNET_YES/GNUNET_NO/CANCEL).
  */
 gboolean
 on_main_window_delete_eventsetup_gtk ()
@@ -452,7 +452,7 @@
 
 int
 gconf_main_post_init (struct
-                      PluginHandle
+                      GNUNET_PluginHandle
                       *self,
                       struct
                       GE_Context *e,
@@ -496,7 +496,7 @@
                      const char
                      **argv,
                      struct
-                     PluginHandle
+                     GNUNET_PluginHandle
                      *self,
                      struct GE_Context
                      *ectx,

Modified: GNUnet/src/setup/gtk/wizard_gtk.c
===================================================================
--- GNUnet/src/setup/gtk/wizard_gtk.c   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/gtk/wizard_gtk.c   2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,10 +32,6 @@
 #include "wizard_gtk.h"
 #include "gconf.h"
 
-#include "gnunet_util_config.h"
-#include "gnunet_util_config_impl.h"
-#include "gnunet_util_error.h"
-
 /**
  * Current open window.
  */
@@ -45,7 +41,7 @@
 
 static int doAutoStart = 0;
 
-static int doUpdate = YES;
+static int doUpdate = GNUNET_YES;
 
 static char *user_name = NULL;
 
@@ -141,7 +137,7 @@
 
   utf8_name = g_locale_to_utf8 (name, -1, NULL, &unused, NULL);
   if (!utf8_name)
-    utf8_name = STRDUP (_("(unknown connection)"));
+    utf8_name = GNUNET_strdup (_("(unknown connection)"));
 
   gtk_combo_box_append_text (GTK_COMBO_BOX (cmbNIC), utf8_name);
   free (utf8_name);
@@ -149,7 +145,7 @@
   if (defaultNIC)
     gtk_combo_box_set_active (GTK_COMBO_BOX (cmbNIC), inc->nic_item_count);
 
-  return OK;
+  return GNUNET_OK;
 }
 
 void
@@ -172,7 +168,7 @@
                            GTK_TREE_MODEL (model));
   gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (cls.cmbNIC), 0);
 
-  os_list_network_interfaces (err_ctx, &insert_nic, &cls);
+  GNUNET_list_network_interfaces (err_ctx, &insert_nic, &cls);
 
   if (cls.nic_item_count != 0)
     {
@@ -183,7 +179,7 @@
       gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter);
       gtk_combo_box_set_active_iter (GTK_COMBO_BOX (cls.cmbNIC), &iter);
       on_cmbNIC_changedsetup_gtk (GTK_COMBO_BOX (cls.cmbNIC), NULL);
-      FREE (val);
+      GNUNET_free (val);
     }
 
   gtk_widget_set_usize (cls.cmbNIC, 10, -1);
@@ -191,14 +187,15 @@
   entIP = lookup_widget ("entIP");
   GC_get_configuration_value_string (editCfg, "NETWORK", "IP", "", &val);
   gtk_entry_set_text (GTK_ENTRY (entIP), val);
-  FREE (val);
+  GNUNET_free (val);
 
   chkFW = lookup_widget ("chkFW");
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkFW),
                                 GC_get_configuration_value_yesno (editCfg,
                                                                   "NAT",
                                                                   "LIMITED",
-                                                                  NO) == YES);
+                                                                  GNUNET_NO)
+                                == GNUNET_YES);
 
   gtk_widget_show (curwnd);
 }
@@ -224,23 +221,23 @@
                                      "LOAD",
                                      "MAXNETUPBPSTOTAL", "50000", &val);
   gtk_entry_set_text (GTK_ENTRY (entUp), val);
-  FREE (val);
+  GNUNET_free (val);
   GC_get_configuration_value_string (editCfg,
                                      "LOAD",
                                      "MAXNETDOWNBPSTOTAL", "50000", &val);
   gtk_entry_set_text (GTK_ENTRY (entDown), val);
-  FREE (val);
+  GNUNET_free (val);
   gtk_toggle_button_set_active
     (GTK_TOGGLE_BUTTON
      ((GC_get_configuration_value_yesno (editCfg,
                                          "LOAD",
                                          "BASICLIMITING",
-                                         NO) == YES)
+                                         GNUNET_NO) == GNUNET_YES)
       ? radGNUnet : radShare), TRUE);
   GC_get_configuration_value_string (editCfg,
                                      "LOAD", "MAXCPULOAD", "50", &val);
   gtk_entry_set_text (GTK_ENTRY (entCPU), val);
-  FREE (val);
+  GNUNET_free (val);
 
   gtk_widget_show (curwnd);
 }
@@ -276,55 +273,55 @@
   if (NULL == uname || strlen (uname) == 0)
     {
       if ((geteuid () == 0) || (NULL != getpwnam ("gnunet")))
-        user_name = STRDUP ("gnunet");
+        user_name = GNUNET_strdup ("gnunet");
       else
         {
           uname = getenv ("USER");
           if (uname != NULL)
-            user_name = STRDUP (uname);
+            user_name = GNUNET_strdup (uname);
           else
             user_name = NULL;
         }
     }
   else
     {
-      user_name = STRDUP (uname);
+      user_name = GNUNET_strdup (uname);
     }
   if (NULL == gname || strlen (gname) == 0)
     {
       struct group *grp;
       if ((geteuid () == 0) || (NULL != getgrnam ("gnunet")))
-        group_name = STRDUP ("gnunet");
+        group_name = GNUNET_strdup ("gnunet");
       else
         {
           grp = getgrgid (getegid ());
           if ((grp != NULL) && (grp->gr_name != NULL))
-            group_name = STRDUP (grp->gr_name);
+            group_name = GNUNET_strdup (grp->gr_name);
           else
             group_name = NULL;
         }
     }
   else
     {
-      group_name = STRDUP (gname);
+      group_name = GNUNET_strdup (gname);
     }
 
 #else
   if (NULL == uname || strlen (uname) == 0)
-    user_name = STRDUP ("");
+    user_name = GNUNET_strdup ("");
   else
-    user_name = STRDUP (uname);
+    user_name = GNUNET_strdup (uname);
   if (NULL == gname || strlen (gname) == 0)
-    group_name = STRDUP ("");
+    group_name = GNUNET_strdup ("");
   else
-    group_name = STRDUP (gname);
+    group_name = GNUNET_strdup (gname);
 #endif
 
   if (user_name != NULL)
     gtk_entry_set_text (GTK_ENTRY (entUser), user_name);
   if (group_name != NULL)
     gtk_entry_set_text (GTK_ENTRY (entGroup), group_name);
-  cap = os_modify_autostart (err_ctx, 1, 1, NULL, NULL, NULL);
+  cap = GNUNET_configure_autostart (err_ctx, 1, 1, NULL, NULL, NULL);
   gtk_widget_set_sensitive (entUser, cap);
 #ifdef WINDOWS
   cap = FALSE;
@@ -353,16 +350,16 @@
 
   GC_get_configuration_value_string (editCfg, "FS", "QUOTA", "1024", &val);
   gtk_entry_set_text (GTK_ENTRY (entQuota), val);
-  FREE (val);
+  GNUNET_free (val);
 
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkMigr),
                                 GC_get_configuration_value_yesno (editCfg,
                                                                   "FS",
                                                                   
"ACTIVEMIGRATION",
-                                                                  YES) ==
-                                YES);
+                                                                  GNUNET_YES)
+                                == GNUNET_YES);
 
-  if (os_modify_autostart (err_ctx, 1, 1, NULL, NULL, NULL))
+  if (GNUNET_configure_autostart (err_ctx, 1, 1, NULL, NULL, NULL))
     gtk_widget_set_sensitive (chkStart, TRUE);
 
 
@@ -370,7 +367,8 @@
                                 GC_get_configuration_value_yesno (editCfg,
                                                                   "GNUNETD",
                                                                   "AUTOSTART",
-                                                                  NO) == YES);
+                                                                  GNUNET_NO)
+                                == GNUNET_YES);
 
   if (doOpenEnhConfigurator)
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkEnh), 1);
@@ -390,13 +388,13 @@
   GtkWidget *dialog;
   char *err;
 
-  err = MALLOC (strlen (prefix) + strlen (error) + 2);
+  err = GNUNET_malloc (strlen (prefix) + strlen (error) + 2);
   sprintf (err, "%s %s", prefix, error);
 
   dialog = gtk_message_dialog_new (NULL,
                                    GTK_DIALOG_MODAL,
                                    GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, err);
-  FREE (err);
+  GNUNET_free (err);
   gtk_dialog_run (GTK_DIALOG (dialog));
   gtk_widget_destroy (dialog);
 }
@@ -412,13 +410,13 @@
     {
       prefix = _("Unable to save configuration file `%s':");
 
-      err = MALLOC (strlen (cfg_fn) + strlen (prefix) + 1);
+      err = GNUNET_malloc (strlen (cfg_fn) + strlen (prefix) + 1);
       sprintf (err, prefix, cfg_fn);
       showErr (err, STRERROR (errno));
-      FREE (err);
-      return SYSERR;
+      GNUNET_free (err);
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 void
@@ -427,7 +425,7 @@
   GtkWidget *dialog;
   int ok, ret;
 
-  ok = OK;
+  ok = GNUNET_OK;
 
   dialog = gtk_message_dialog_new (NULL,
                                    GTK_DIALOG_MODAL,
@@ -443,11 +441,11 @@
       ok = save_conf ();
       break;
     case GTK_RESPONSE_NO:
-      ok = OK;
+      ok = GNUNET_OK;
       break;
     case GTK_RESPONSE_CANCEL:
     default:
-      ok = NO;
+      ok = GNUNET_NO;
     }
 
   if (ok)
@@ -471,28 +469,28 @@
         return;
       }
 
-  if (wiz_autostartService (doAutoStart, user_name, group_name) != OK)
+  if (wiz_autostartService (doAutoStart, user_name, group_name) != GNUNET_OK)
     {
 #ifndef MINGW
       showErr (_("Unable to change startup process:"), STRERROR (errno));
 #endif
     }
 
-  if (OK != save_conf ())
+  if (GNUNET_OK != save_conf ())
     return;
   if (doUpdate)
     {
-      bin = os_get_installation_path (IPK_BINDIR);
-      gup = MALLOC (strlen (bin) + 30 + strlen (cfg_fn));
+      bin = GNUNET_get_installation_path (GNUNET_IPK_BINDIR);
+      gup = GNUNET_malloc (strlen (bin) + 30 + strlen (cfg_fn));
       strcpy (gup, bin);
-      FREE (bin);
+      GNUNET_free (bin);
       strcat (gup, "/gnunet-update -c ");
       strcat (gup, cfg_fn);
       if (system (gup) != 0)
         showErr (_("Running gnunet-update failed.\n"
                    "This maybe due to insufficient permissions, please check 
your configuration.\n"
                    "Finally, run gnunet-update manually."), "");
-      FREE (gup);
+      GNUNET_free (gup);
     }
   gtk_widget_destroy (curwnd);
 }
@@ -646,9 +644,9 @@
   GE_ASSERT (err_ctx, ret != NULL);
   GC_set_configuration_value_string (editCfg, err_ctx, "GNUNETD", "USER",
                                      ret);
-  FREENONNULL (user_name);
+  GNUNET_free_non_null (user_name);
   if (strlen (ret) != 0)
-    user_name = STRDUP (ret);
+    user_name = GNUNET_strdup (ret);
   else
     user_name = NULL;
   g_free (ret);
@@ -660,13 +658,13 @@
 {
   gchar *ret;
 
-  FREENONNULL (group_name);
+  GNUNET_free_non_null (group_name);
   ret = gtk_editable_get_chars (editable, 0, -1);
   GE_ASSERT (err_ctx, ret != NULL);
   GC_set_configuration_value_string (editCfg,
                                      err_ctx, "GNUNETD", "GROUP", ret);
   if (strlen (ret) != 0)
-    group_name = STRDUP (ret);
+    group_name = GNUNET_strdup (ret);
   else
     group_name = NULL;
   g_free (ret);
@@ -675,7 +673,7 @@
 int
 gtk_wizard_mainsetup_gtk (int argc,
                           char *const *argv,
-                          struct PluginHandle *self,
+                          struct GNUNET_PluginHandle *self,
                           struct GE_Context *ectx,
                           struct GC_Configuration *cfg,
                           struct GNS_Context *gns,
@@ -704,8 +702,8 @@
   destroyMainXML ();
   if (doOpenEnhConfigurator)
     gconf_main_post_init (self, ectx, cfg, gns, filename, is_daemon);
-  FREENONNULL (user_name);
-  FREENONNULL (group_name);
+  GNUNET_free_non_null (user_name);
+  GNUNET_free_non_null (group_name);
   setLibrary (NULL);
 
   return 0;

Modified: GNUnet/src/setup/gtk/wizard_gtk.h
===================================================================
--- GNUnet/src/setup/gtk/wizard_gtk.h   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/gtk/wizard_gtk.h   2007-11-23 11:51:54 UTC (rev 5742)
@@ -33,7 +33,7 @@
 
 int gtk_wizard_mainsetup_gtk (int argc,
                               char *const *argv,
-                              struct PluginHandle *self,
+                              struct GNUNET_PluginHandle *self,
                               struct GE_Context *ectx,
                               struct GC_Configuration *cfg,
                               struct GNS_Context *gns,

Modified: GNUnet/src/setup/lib/Makefile.am
===================================================================
--- GNUnet/src/setup/lib/Makefile.am    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/lib/Makefile.am    2007-11-23 11:51:54 UTC (rev 5742)
@@ -15,9 +15,7 @@
   wizard_util.c wizard_util.h
 
 libgnunetsetup_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la  
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 libgnunetsetup_la_LDFLAGS = \
  -export-dynamic -lguile

Modified: GNUnet/src/setup/lib/gns.c
===================================================================
--- GNUnet/src/setup/lib/gns.c  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/lib/gns.c  2007-11-23 11:51:54 UTC (rev 5742)
@@ -124,9 +124,9 @@
                                                 section,
                                                 option,
                                                 pos->value.Boolean.def);
-        if (val == SYSERR)
+        if (val == GNUNET_SYSERR)
           {
-            return SYSERR;
+            return GNUNET_SYSERR;
           }
         pos->value.Boolean.val = val;
         break;
@@ -135,17 +135,18 @@
       {
         unsigned long long val;
 
-        if (SYSERR == GC_get_configuration_value_number (cfg,
-                                                         section,
-                                                         option,
-                                                         pos->value.UInt64.
-                                                         min,
-                                                         pos->value.UInt64.
-                                                         max,
-                                                         pos->value.UInt64.
-                                                         def, &val))
+        if (GNUNET_SYSERR == GC_get_configuration_value_number (cfg,
+                                                                section,
+                                                                option,
+                                                                pos->value.
+                                                                UInt64.min,
+                                                                pos->value.
+                                                                UInt64.max,
+                                                                pos->value.
+                                                                UInt64.def,
+                                                                &val))
           {
-            return SYSERR;
+            return GNUNET_SYSERR;
           }
         pos->value.UInt64.val = val;
         break;
@@ -169,11 +170,11 @@
                         GE_USER | GE_ERROR | GE_IMMEDIATE,
                         "`%s' is not a valid double-precision floating point 
number.\n",
                         s);
-                FREE (s);
-                return SYSERR;
+                GNUNET_free (s);
+                return GNUNET_SYSERR;
               }
             pos->value.Double.val = d;
-            FREE (s);
+            GNUNET_free (s);
           }
         break;
       }
@@ -182,13 +183,14 @@
       {
         char *val;
 
-        if (SYSERR == GC_get_configuration_value_string (cfg,
-                                                         section,
-                                                         option,
-                                                         pos->value.String.
-                                                         def, &val))
-          return SYSERR;
-        FREE (pos->value.String.val);
+        if (GNUNET_SYSERR == GC_get_configuration_value_string (cfg,
+                                                                section,
+                                                                option,
+                                                                pos->value.
+                                                                String.def,
+                                                                &val))
+          return GNUNET_SYSERR;
+        GNUNET_free (pos->value.String.val);
         pos->value.String.val = val;
         break;
       }
@@ -196,17 +198,19 @@
       {
         const char *ival;
 
-        if (SYSERR == GC_get_configuration_value_choice (cfg,
-                                                         section,
-                                                         option,
-                                                         (const char **) pos->
-                                                         value.String.
-                                                         legalRange,
-                                                         pos->value.String.
-                                                         def, &ival))
-          return SYSERR;
-        FREE (pos->value.String.val);
-        pos->value.String.val = STRDUP (ival);
+        if (GNUNET_SYSERR == GC_get_configuration_value_choice (cfg,
+                                                                section,
+                                                                option,
+                                                                (const char
+                                                                 **) pos->
+                                                                value.String.
+                                                                legalRange,
+                                                                pos->value.
+                                                                String.def,
+                                                                &ival))
+          return GNUNET_SYSERR;
+        GNUNET_free (pos->value.String.val);
+        pos->value.String.val = GNUNET_strdup (ival);
         break;
       }
     }
@@ -244,20 +248,20 @@
       i = 0;
       while (t->value.String.legalRange[i] != NULL)
         {
-          FREE (t->value.String.legalRange[i]);
+          GNUNET_free (t->value.String.legalRange[i]);
           i++;
         }
-      FREE (t->value.String.legalRange);
-      FREE (t->value.String.val);
+      GNUNET_free (t->value.String.legalRange);
+      GNUNET_free (t->value.String.val);
       break;
     default:
       GE_BREAK (NULL, 0);
       break;
     }
-  FREE (t->description);
-  FREE (t->help);
-  FREE (t->children);
-  FREE (t);
+  GNUNET_free (t->description);
+  GNUNET_free (t->help);
+  GNUNET_free (t->children);
+  GNUNET_free (t);
 }
 
 
@@ -281,7 +285,7 @@
   root = tree_parse (ectx, specification);
   if (root == NULL)
     return NULL;
-  ctx = MALLOC (sizeof (struct GNS_Context));
+  ctx = GNUNET_malloc (sizeof (struct GNS_Context));
   ctx->ectx = ectx;
   ctx->cfg = cfg;
   ctx->root = root;
@@ -293,7 +297,7 @@
               _
               ("Configuration does not satisfy constraints of configuration 
specification file `%s'!\n"),
               specification);
-      FREE (ctx);
+      GNUNET_free (ctx);
       free_tree (root);
       return NULL;
     }
@@ -323,7 +327,7 @@
   GC_detach_change_listener (ctx->cfg, &configChangeListener, ctx);
   free_tree (ctx->root);
   GE_ASSERT (ctx->ectx, ctx->listeners == NULL);
-  FREE (ctx);
+  GNUNET_free (ctx);
 }
 
 /**
@@ -337,7 +341,7 @@
 {
   GNS_TCL *n;
 
-  n = MALLOC (sizeof (GNS_TCL));
+  n = GNUNET_malloc (sizeof (GNS_TCL));
   n->l = listener;
   n->c = cls;
   n->next = ctx->listeners;
@@ -366,7 +370,7 @@
             ctx->listeners = pos->next;
           else
             prev->next = pos->next;
-          FREE (pos);
+          GNUNET_free (pos);
           return;               /* only unregister one! */
         }
       prev = pos;
@@ -391,20 +395,20 @@
     {
     case GNS_Boolean:
       if (value->Boolean.def)
-        return STRDUP ("YES");
-      return STRDUP ("NO");
+        return GNUNET_strdup ("YES");
+      return GNUNET_strdup ("NO");
     case GNS_String:
     case GNS_MC:
     case GNS_SC:
       if (value->String.def == NULL)
         return NULL;
-      return STRDUP (value->String.def);
+      return GNUNET_strdup (value->String.def);
     case GNS_Double:
-      SNPRINTF (buf, 48, "%f", value->Double.def);
-      return STRDUP (buf);
+      GNUNET_snprintf (buf, 48, "%f", value->Double.def);
+      return GNUNET_strdup (buf);
     case GNS_UInt64:
-      SNPRINTF (buf, 48, "%llu", value->UInt64.def);
-      return STRDUP (buf);
+      GNUNET_snprintf (buf, 48, "%llu", value->UInt64.def);
+      return GNUNET_strdup (buf);
     default:
       return NULL;
     }

Modified: GNUnet/src/setup/lib/tree.c
===================================================================
--- GNUnet/src/setup/lib/tree.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/lib/tree.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -292,12 +292,12 @@
     }
 
   /* construct C object */
-  tree = MALLOC (sizeof (struct GNS_Tree));
+  tree = GNUNET_malloc (sizeof (struct GNS_Tree));
   tree->section = scm_to_locale_string (section);
   tree->option = scm_to_locale_string (option);
   tree->description = scm_to_locale_string (description);
   tree->help = scm_to_locale_string (help);
-  tree->children = MALLOC (sizeof (struct GNS_Tree *) * (clen + 1));
+  tree->children = GNUNET_malloc (sizeof (struct GNS_Tree *) * (clen + 1));
   for (i = 0; i < clen; i++)
     {
       child = scm_list_ref (children, scm_from_signed_integer (i));
@@ -312,7 +312,8 @@
       tree->value.String.val = scm_to_locale_string (value);
       tree->value.String.def = scm_to_locale_string (value);
       len = scm_to_int (scm_length (range));
-      tree->value.String.legalRange = MALLOC (sizeof (char *) * (len + 1));
+      tree->value.String.legalRange =
+        GNUNET_malloc (sizeof (char *) * (len + 1));
       for (i = 0; i < len - 1; i++)
         tree->value.String.legalRange[i]
           = scm_to_locale_string (scm_list_ref (range,
@@ -327,7 +328,7 @@
                                                    scm_from_signed_integer
                                                    (0)));
       else
-        type = STRDUP ("*");
+        type = GNUNET_strdup ("*");
       GE_ASSERT (NULL, type != NULL);
       if (0 == strcasecmp (type, "MC"))
         {
@@ -342,7 +343,7 @@
           GE_BREAK (NULL, 0 == strcasecmp (type, "*"));
           tree->type |= GNS_String;
         }
-      FREE (type);
+      GNUNET_free (type);
     }
   else if (scm_is_integer (value))
     {

Modified: GNUnet/src/setup/lib/wizard_util.c
===================================================================
--- GNUnet/src/setup/lib/wizard_util.c  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/lib/wizard_util.c  2007-11-23 11:51:54 UTC (rev 5742)
@@ -44,7 +44,7 @@
   /* default NIC for unixes */
   if (strcmp (nic, "eth0") == 0)
     {
-      FREE (nic);
+      GNUNET_free (nic);
       nic = NULL;
     }
 #endif
@@ -78,7 +78,7 @@
  * @param doAutoStart true to enable autostart, false to disable it
  * @param username name of the user account to use
  * @param groupname name of the group to use
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
 wiz_autostartService (int doAutoStart, char *username, char *groupname)
@@ -86,8 +86,8 @@
   int ret;
   char *exe;
 
-  exe = os_get_installation_path (IPK_BINDIR);
-  exe = (char *) REALLOC (exe, strlen (exe) + 12);      /* 11 = "gnunetd.exe" 
*/
+  exe = GNUNET_get_installation_path (GNUNET_IPK_BINDIR);
+  exe = (char *) GNUNET_realloc (exe, strlen (exe) + 12);       /* 11 = 
"gnunetd.exe" */
   strcat (exe,
 #ifndef WINDOWS
           "gnunetd");
@@ -96,10 +96,10 @@
 #endif
 
   ret =
-    os_modify_autostart (NULL /* FIXME 0.7.1 NILS */ , 0, doAutoStart, exe,
-                         username, groupname);
-  FREE (exe);
-  if (ret != YES)
+    GNUNET_configure_autostart (NULL /* FIXME 0.7.1 NILS */ , 0, doAutoStart,
+                                exe, username, groupname);
+  GNUNET_free (exe);
+  if (ret != GNUNET_YES)
     {
 #ifdef WINDOWS
       char *err = NULL;
@@ -141,9 +141,9 @@
         }
 #endif
 
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -157,7 +157,7 @@
 {
   int ret;
 
-  ret = os_modify_user (0, 1, user_name, group_name);
+  ret = GNUNET_configure_user_account (0, 1, user_name, group_name);
 
   if (ret)
     {

Modified: GNUnet/src/setup/ncurses/mconf.c
===================================================================
--- GNUnet/src/setup/ncurses/mconf.c    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/ncurses/mconf.c    2007-11-23 11:51:54 UTC (rev 5742)
@@ -27,7 +27,7 @@
 #include <dialog.h>
 
 #undef _
-#undef OK
+#undef GNUNET_OK
 #include "platform.h"
 #include "gnunet_util.h"
 #include "gnunet_setup_lib.h"
@@ -106,7 +106,7 @@
             }
           if (st == 0)
             return;             /* no visible entries */
-          items = MALLOC (sizeof (DIALOG_LISTITEM) * st);
+          items = GNUNET_malloc (sizeof (DIALOG_LISTITEM) * st);
           i = 0;
           st = 0;
           while (pos->children[i] != NULL)
@@ -127,7 +127,7 @@
           st = dlg_menu (gettext (pos->description),
                          "Select configuration option to change",
                          20, 70, 13, st, items, &msel, NULL);
-          FREE (items);
+          GNUNET_free (items);
           switch (st)
             {
             case DLG_EXIT_OK:
@@ -192,7 +192,7 @@
               break;
             case GNS_String:
               /* free form */
-              fitem.text = MALLOC (65536);
+              fitem.text = GNUNET_malloc (65536);
               strcpy (fitem.text, pos->value.String.val);
               fitem.text_len = strlen (fitem.text);
               fitem.help = pos->help;
@@ -212,7 +212,7 @@
                                  ("Internal error! (Value invalid?)"));
                       break;
                     }
-                  FREE (fitem.text);
+                  GNUNET_free (fitem.text);
                   return;
                 case DLG_EXIT_HELP:
                   show_help (pos->option, pos->help);
@@ -220,12 +220,12 @@
                 case DLG_EXIT_CANCEL:
                 case DLG_EXIT_ERROR:
                 case DLG_EXIT_ESC:
-                  FREE (fitem.text);
+                  GNUNET_free (fitem.text);
                   return;
                 default:
                   break;
                 }
-              FREE (fitem.text);
+              GNUNET_free (fitem.text);
               /* end free form */
               break;
             case GNS_SC:
@@ -235,7 +235,7 @@
               while (val->String.legalRange[i] != NULL)
                 i++;
               GE_ASSERT (ectx, i != 0);
-              items = MALLOC (sizeof (DIALOG_LISTITEM) * i);
+              items = GNUNET_malloc (sizeof (DIALOG_LISTITEM) * i);
               i = 0;
               msel = -1;
 
@@ -261,7 +261,7 @@
                                   gettext (pos->description),
                                   20,
                                   70, 13, i, items, " *", FLAG_RADIO, &msel);
-              FREE (items);
+              GNUNET_free (items);
               switch (st)
                 {
                 case DLG_EXIT_OK:
@@ -297,7 +297,7 @@
               while (val->String.legalRange[i] != NULL)
                 i++;
               GE_ASSERT (ectx, i != 0);
-              items = MALLOC (sizeof (DIALOG_LISTITEM) * i);
+              items = GNUNET_malloc (sizeof (DIALOG_LISTITEM) * i);
               i = 0;
               msel = 0;
               while (val->String.legalRange[i] != NULL)
@@ -333,7 +333,7 @@
               switch (st)
                 {
                 case DLG_EXIT_OK:
-                  tmp = MALLOC (tlen);
+                  tmp = GNUNET_malloc (tlen);
                   tmp[0] = '\0';
                   i = 0;
                   while (val->String.legalRange[i] != NULL)
@@ -353,14 +353,14 @@
                                                               pos->option,
                                                               tmp))
                     {
-                      FREE (tmp);
+                      GNUNET_free (tmp);
                       show_help (pos->option,
                                  gettext_noop
                                  ("Internal error! (Choice invalid?)"));
                       break;
                     }
-                  FREE (tmp);
-                  FREE (items);
+                  GNUNET_free (tmp);
+                  GNUNET_free (items);
                   return;
                 case DLG_EXIT_HELP:
                   show_help (pos->option, pos->help);
@@ -369,14 +369,14 @@
                 case DLG_EXIT_ERROR:
                 case DLG_EXIT_CANCEL:
                 default:
-                  FREE (items);
+                  GNUNET_free (items);
                   return;
                 }
-              FREE (items);
+              GNUNET_free (items);
               break;
             case GNS_Double:
-              fitem.text = MALLOC (64);
-              SNPRINTF (fitem.text, 64, "%f", pos->value.Double.val);
+              fitem.text = GNUNET_malloc (64);
+              GNUNET_snprintf (fitem.text, 64, "%f", pos->value.Double.val);
               fitem.text_len = strlen (fitem.text);
               fitem.help = pos->help;
               st = DLG_EXIT_HELP;
@@ -403,7 +403,7 @@
                                  ("Internal error! (Value invalid?)"));
                       break;
                     }
-                  FREE (fitem.text);
+                  GNUNET_free (fitem.text);
                   return;
                 case DLG_EXIT_HELP:
                   show_help (pos->option, pos->help);
@@ -411,12 +411,12 @@
                 default:
                   break;
                 }
-              FREE (fitem.text);
+              GNUNET_free (fitem.text);
               break;
 
             case GNS_UInt64:
-              fitem.text = MALLOC (64);
-              SNPRINTF (fitem.text, 64, "%llu", pos->value.UInt64.val);
+              fitem.text = GNUNET_malloc (64);
+              GNUNET_snprintf (fitem.text, 64, "%llu", pos->value.UInt64.val);
               fitem.text_len = strlen (fitem.text);
               fitem.help = pos->help;
               st = DLG_EXIT_HELP;
@@ -463,7 +463,7 @@
                       break;
                     }
                 }
-              FREE (fitem.text);
+              GNUNET_free (fitem.text);
               return;
             default:
               GE_BREAK (ectx, 0);
@@ -483,7 +483,7 @@
 int
 mconf_mainsetup_curses (int argc,
                         const char **argv,
-                        struct PluginHandle *self,
+                        struct GNUNET_PluginHandle *self,
                         struct GE_Context *e,
                         struct GC_Configuration *cfg,
                         struct GNS_Context *gns,

Modified: GNUnet/src/setup/ncurses/mconf.h
===================================================================
--- GNUnet/src/setup/ncurses/mconf.h    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/ncurses/mconf.h    2007-11-23 11:51:54 UTC (rev 5742)
@@ -30,7 +30,7 @@
 
 int main_setup_ncurses (int argc,
                         const char **argv,
-                        struct PluginHandle *self,
+                        struct GNUNET_PluginHandle *self,
                         struct GE_Context *ectx,
                         struct GC_Configuration *cfg,
                         struct GNS_Context *gns,

Modified: GNUnet/src/setup/ncurses/wizard_curs.c
===================================================================
--- GNUnet/src/setup/ncurses/wizard_curs.c      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/setup/ncurses/wizard_curs.c      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -34,7 +34,7 @@
 #include <dialog.h>
 
 #undef _
-#undef OK
+#undef GNUNET_OK
 #include "platform.h"
 #include "gnunet_util.h"
 #include "gnunet_setup_lib.h"
@@ -60,10 +60,10 @@
 {
   char *err;
 
-  err = MALLOC (strlen (prefix) + strlen (error) + 2);
+  err = GNUNET_malloc (strlen (prefix) + strlen (error) + 2);
   sprintf (err, "%s %s", prefix, error);
   dialog_msgbox (_("Error"), err, 70, 15, 1);
-  FREE (err);
+  GNUNET_free (err);
 }
 
 static void
@@ -142,7 +142,7 @@
   dialog_vars.cancel_label = _("Abort");
   dialog_vars.ok_label = _("Ok");
   fitem.type = 0;
-  fitem.name = STRDUP (question);
+  fitem.name = GNUNET_strdup (question);
   fitem.name_len = strlen (question);
   fitem.name_y = 3;
   fitem.name_x = 5;
@@ -153,10 +153,10 @@
   fitem.text_ilen = 63;
   fitem.text_free = 0;
   fitem.help_free = 0;
-  fitem.text = MALLOC (65536);
+  fitem.text = GNUNET_malloc (65536);
   strcpy (fitem.text, def);
   fitem.text_len = strlen (fitem.text);
-  fitem.help = STRDUP (help);
+  fitem.help = GNUNET_strdup (help);
   msel = 0;
 
   ret = 2;
@@ -196,9 +196,9 @@
           break;
         }
     }
-  FREE (fitem.name);
-  FREE (fitem.text);
-  FREE (fitem.help);
+  GNUNET_free (fitem.name);
+  GNUNET_free (fitem.text);
+  GNUNET_free (fitem.help);
   return ret;
 }
 
@@ -229,13 +229,13 @@
   while ((pos < MAX_NIC) && (nic_items[pos].text != NULL))
     pos++;
   if (pos == MAX_NIC)
-    return SYSERR;
+    return GNUNET_SYSERR;
   item = &nic_items[pos];
   item->name = "";
-  item->text = STRDUP (name);
+  item->text = GNUNET_strdup (name);
   item->help = "";
   item->state = defaultNIC;
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
@@ -260,7 +260,7 @@
   fitem.text_free = 0;
   fitem.help_free = 0;
   memset (nic_items, 0, sizeof (DIALOG_LISTITEM) * MAX_NIC);
-  os_list_network_interfaces (NULL, &insert_nic_curs, nic_items);
+  GNUNET_list_network_interfaces (NULL, &insert_nic_curs, nic_items);
   total = 0;
   while ((total < MAX_NIC) && (nic_items[total].text != NULL))
     {
@@ -388,7 +388,9 @@
 static int
 user ()
 {
-  if (YES != os_modify_user (YES, YES, "gnunet", "gnunet"))
+  if (GNUNET_YES !=
+      GNUNET_configure_user_account (GNUNET_YES, GNUNET_YES, "gnunet",
+                                     "gnunet"))
     return last;                /* ignore option */
   return query_string (_("Daemon configuration: user account"),
                        _("As which user should gnunetd be run?"),
@@ -406,7 +408,9 @@
 static int
 group ()
 {
-  if (YES != os_modify_user (YES, YES, "gnunet", "gnunet"))
+  if (GNUNET_YES !=
+      GNUNET_configure_user_account (GNUNET_YES, GNUNET_YES, "gnunet",
+                                     "gnunet"))
     return last;                /* ignore option */
   return query_string (_("Daemon configuration: group account"),
                        _("As which group should gnunetd be run?"),
@@ -445,16 +449,16 @@
   char *user_name;
   char *group_name;
 
-  ret = OK;
+  ret = GNUNET_OK;
 
   if ((0 != GC_test_dirty (cfg)) &&
       (0 != GC_write_configuration (cfg, cfg_fn)))
     {
       prefix = _("Unable to save configuration file `%s':");
-      err = MALLOC (strlen (cfg_fn) + strlen (prefix) + 1);
+      err = GNUNET_malloc (strlen (cfg_fn) + strlen (prefix) + 1);
       sprintf (err, prefix, cfg_fn);
       showCursErr (err, STRERROR (errno));
-      ret = SYSERR;
+      ret = GNUNET_SYSERR;
     }
   user_name = NULL;
   GC_get_configuration_value_string (cfg, "GNUNETD", "USER", "", &user_name);
@@ -462,24 +466,26 @@
                                      "GNUNETD", "GROUP", "", &group_name);
   if (((strlen (user_name) > 0) ||
        (strlen (group_name) > 0)) &&
-      (OK == os_modify_user (YES,
-                             YES,
-                             user_name,
-                             group_name)) &&
-      (OK != os_modify_user (NO, YES, user_name, group_name)))
+      (GNUNET_OK == GNUNET_configure_user_account (GNUNET_YES,
+                                                   GNUNET_YES,
+                                                   user_name,
+                                                   group_name)) &&
+      (GNUNET_OK !=
+       GNUNET_configure_user_account (GNUNET_NO, GNUNET_YES, user_name,
+                                      group_name)))
     {
       showCursErr (_("Unable to create user account for daemon."), "");
-      ret = SYSERR;
+      ret = GNUNET_SYSERR;
     }
-  if ((YES == GC_get_configuration_value_yesno (cfg, "GNUNETD", "AUTOSTART", 
NO)) && (YES != os_modify_autostart (ectx, NO, YES, "gnunetd",     /* specify 
full path? */
-                                                                               
                                   user_name,
-                                                                               
                                   group_name)))
+  if ((GNUNET_YES == GC_get_configuration_value_yesno (cfg, "GNUNETD", 
"AUTOSTART", GNUNET_NO)) && (GNUNET_YES != GNUNET_configure_autostart (ectx, 
GNUNET_NO, GNUNET_YES, "gnunetd",   /* specify full path? */
+                                                                               
                                                               user_name,
+                                                                               
                                                               group_name)))
     {
       showCursErr (_("Unable to setup autostart for daemon."), "");
-      ret = SYSERR;
+      ret = GNUNET_SYSERR;
     }
-  FREE (user_name);
-  FREE (group_name);
+  GNUNET_free (user_name);
+  GNUNET_free (group_name);
   return ret;
 }
 
@@ -495,7 +501,7 @@
   switch (ret)
     {
     case DLG_EXIT_OK:
-      if (OK != finish ())
+      if (GNUNET_OK != finish ())
         return 0;               /* error */
       return 1;
     case DLG_EXIT_CANCEL:
@@ -514,7 +520,7 @@
 int
 wizard_curs_mainsetup_curses (int argc,
                               const char **argv,
-                              struct PluginHandle *self,
+                              struct GNUNET_PluginHandle *self,
                               struct GE_Context *e,
                               struct GC_Configuration *c,
                               struct GNS_Context *gns,
@@ -539,8 +545,8 @@
   init_dialog (stdin, stderr);
 
   phase = 0;
-  ret = NO;
-  while (ret == NO)
+  ret = GNUNET_NO;
+  while (ret == GNUNET_NO)
     {
       switch (phase)
         {
@@ -579,7 +585,7 @@
           break;
         case 11:
           dir = 0;
-          ret = OK;
+          ret = GNUNET_OK;
           break;
         default:
           GE_BREAK (NULL, 0);
@@ -589,7 +595,7 @@
       phase += dir;
       last = dir;
       if (dir == 0)
-        ret = SYSERR;
+        ret = GNUNET_SYSERR;
     }
   end_dialog ();
 #ifndef MINGW

Modified: GNUnet/src/setup/ncurses/wizard_curs.h
===================================================================
--- GNUnet/src/setup/ncurses/wizard_curs.h      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/setup/ncurses/wizard_curs.h      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -30,7 +30,7 @@
 
 int wizard_curs_mainsetup_curses (int argc,
                                   const char **argv,
-                                  struct PluginHandle *self,
+                                  struct GNUNET_PluginHandle *self,
                                   struct GE_Context *ectx,
                                   struct GC_Configuration *cfg,
                                   struct GNS_Context *gns,

Modified: GNUnet/src/setup/text/conf.c
===================================================================
--- GNUnet/src/setup/text/conf.c        2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/text/conf.c        2007-11-23 11:51:54 UTC (rev 5742)
@@ -76,20 +76,20 @@
     {
     case GNS_Boolean:
       if (val->Boolean.val)
-        return STRDUP (_("yes"));
-      return STRDUP (_("no"));
+        return GNUNET_strdup (_("yes"));
+      return GNUNET_strdup (_("no"));
     case GNS_String:
     case GNS_SC:
     case GNS_MC:
-      return STRDUP (val->String.val);
+      return GNUNET_strdup (val->String.val);
     case GNS_Double:
-      SNPRINTF (buf, 92, "%f", val->Double.val);
-      return STRDUP (buf);
+      GNUNET_snprintf (buf, 92, "%f", val->Double.val);
+      return GNUNET_strdup (buf);
     case GNS_UInt64:
-      SNPRINTF (buf, 92, "%llu", val->UInt64.val);
-      return STRDUP (buf);
+      GNUNET_snprintf (buf, 92, "%llu", val->UInt64.val);
+      return GNUNET_strdup (buf);
     }
-  return STRDUP ("Internal error.");
+  return GNUNET_strdup ("Internal error.");
 }
 
 static void
@@ -158,7 +158,7 @@
 }
 
 /**
- * @return OK on success, NO to display help, SYSERR to abort
+ * @return GNUNET_OK on success, GNUNET_NO to display help, GNUNET_SYSERR to 
abort
  */
 static int
 readValue (GNS_Type type, GNS_Value * val)
@@ -179,23 +179,23 @@
             {
             case '\n':
               printf ("\n");
-              return YES;       /* skip */
+              return GNUNET_YES;        /* skip */
             case 'y':
             case 'Y':
               val->Boolean.val = 1;
               printf (_("Yes\n"));
-              return YES;
+              return GNUNET_YES;
             case 'n':
             case 'N':
               val->Boolean.val = 0;
               printf (_("No\n"));
-              return YES;
+              return GNUNET_YES;
             case '?':
               printf (_("Help\n"));
-              return NO;
+              return GNUNET_NO;
             case 'q':
               printf (_("Abort\n"));
-              return SYSERR;
+              return GNUNET_SYSERR;
             default:
               break;
             }
@@ -210,7 +210,7 @@
           if (buf[i] == 'q')
             {
               printf (_("Abort\n"));
-              return SYSERR;
+              return GNUNET_SYSERR;
             }
 #if 0
           if (buf[i] == '\b')
@@ -226,19 +226,19 @@
           if ((buf[i] == 'd') && (i == 0))
             {
               printf ("%s\n", val->String.def);
-              FREE (val->String.val);
-              val->String.val = STRDUP (val->String.def);
-              return YES;
+              GNUNET_free (val->String.val);
+              val->String.val = GNUNET_strdup (val->String.def);
+              return GNUNET_YES;
             }
           if ((buf[i] == '?') && (i == 0))
             {
               printf (_("Help\n"));
-              return NO;
+              return GNUNET_NO;
             }
           if ((buf[i] == '\n') && (i == 0))
             {
               printf ("%s\n", val->String.val);
-              return YES;       /* keep */
+              return GNUNET_YES;        /* keep */
             }
           if (buf[i] != '\n')
             {
@@ -252,10 +252,10 @@
             }
           break;
         }
-      FREE (val->String.val);
-      val->String.val = STRDUP (buf[0] == ' ' ? &buf[1] : buf);
+      GNUNET_free (val->String.val);
+      val->String.val = GNUNET_strdup (buf[0] == ' ' ? &buf[1] : buf);
       printf ("\n");
-      return OK;
+      return GNUNET_OK;
     case GNS_SC:
       while (1)
         {
@@ -263,17 +263,17 @@
           if (c == '?')
             {
               printf (_("Help\n"));
-              return NO;
+              return GNUNET_NO;
             }
           if (c == '\n')
             {
               printf ("%s\n", val->String.val);
-              return YES;
+              return GNUNET_YES;
             }
           if (c == 'q')
             {
               printf (_("Abort\n"));
-              return SYSERR;
+              return GNUNET_SYSERR;
             }
           i = -1;
           if ((c >= '0') && (c <= '9'))
@@ -290,10 +290,10 @@
               }
           if (i == -1)
             continue;           /* invalid entry */
-          FREE (val->String.val);
-          val->String.val = STRDUP (val->String.legalRange[i]);
+          GNUNET_free (val->String.val);
+          val->String.val = GNUNET_strdup (val->String.legalRange[i]);
           printf ("%s\n", val->String.val);
-          return OK;
+          return GNUNET_OK;
         }
       /* unreachable */
     case GNS_Double:
@@ -304,7 +304,7 @@
           if (buf[i] == 'q')
             {
               printf (_("Abort\n"));
-              return SYSERR;
+              return GNUNET_SYSERR;
             }
 #if 0
           if (buf[i] == '\b')
@@ -321,12 +321,12 @@
             {
               val->Double.val = val->Double.def;
               printf ("%f\n", val->Double.val);
-              return YES;       /* default */
+              return GNUNET_YES;        /* default */
             }
           if (buf[i] == '?')
             {
               printf (_("Help\n"));
-              return NO;
+              return GNUNET_NO;
             }
           if (buf[i] != '\n')
             {
@@ -341,13 +341,13 @@
           if (i == 0)
             {
               printf ("%f\n", val->Double.val);
-              return YES;       /* keep */
+              return GNUNET_YES;        /* keep */
             }
           buf[i + 1] = '\0';
           if (1 == sscanf (buf, "%lf", &val->Double.val))
             {
               printf ("\n");
-              return OK;
+              return GNUNET_OK;
             }
           i = 0;
           printf (_("\nInvalid entry, try again (use '?' for help): "));
@@ -362,7 +362,7 @@
           if (buf[i] == 'q')
             {
               printf (_("Abort\n"));
-              return SYSERR;
+              return GNUNET_SYSERR;
             }
 #if 0
           if (buf[i] == '\b')
@@ -379,12 +379,12 @@
             {
               val->UInt64.val = val->UInt64.def;
               printf ("%llu\n", val->UInt64.val);
-              return YES;       /* default */
+              return GNUNET_YES;        /* default */
             }
           if (buf[i] == '?')
             {
               printf (_("Help\n"));
-              return NO;
+              return GNUNET_NO;
             }
           if (buf[i] != '\n')
             {
@@ -399,7 +399,7 @@
           if (i == 0)
             {
               printf ("%llu\n", val->UInt64.val);
-              return YES;       /* keep */
+              return GNUNET_YES;        /* keep */
             }
           buf[i + 1] = '\0';
           if ((1 == sscanf (buf,
@@ -409,7 +409,7 @@
             {
               val->UInt64.val = l;
               printf ("\n");
-              return OK;
+              return GNUNET_OK;
             }
           i = 0;
           printf (_("\nInvalid entry, try again (use '?' for help): "));
@@ -420,9 +420,9 @@
       fprintf (stderr,
                _("Unknown kind %x (internal error).  Skipping option.\n"),
                type & GNS_TypeMask);
-      return OK;
+      return GNUNET_OK;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
@@ -436,7 +436,7 @@
   int i;
 
   if (!tree->visible)
-    return OK;
+    return GNUNET_OK;
   switch (tree->type & GNS_KindMask)
     {
     case GNS_Leaf:
@@ -448,12 +448,12 @@
           iprintf (indent, "%s\n", gettext (tree->description));
           printChoice (indent, tree->type, &tree->value);
           i = readValue (tree->type, &tree->value);
-          if (i == SYSERR)
+          if (i == GNUNET_SYSERR)
             {
-              FREE (ovalue);
-              return SYSERR;
+              GNUNET_free (ovalue);
+              return GNUNET_SYSERR;
             }
-          if (i == OK)
+          if (i == GNUNET_OK)
             break;
           printf ("\n\n");
           iprintf (0, "%s\n", gettext (tree->help));
@@ -466,13 +466,13 @@
                                                    tree->section,
                                                    tree->option, value)))
         {
-          FREE (value);
-          FREE (ovalue);
+          GNUNET_free (value);
+          GNUNET_free (ovalue);
           return conf (indent, cfg, ectx, tree);        /* try again */
         }
-      FREE (value);
-      FREE (ovalue);
-      return OK;
+      GNUNET_free (value);
+      GNUNET_free (ovalue);
+      return GNUNET_OK;
     case GNS_Node:
       choice = '\0';
       while (choice == '\0')
@@ -486,10 +486,10 @@
             case 'N':
             case 'n':
               iprintf (indent, "%c\n", choice);
-              return OK;
+              return GNUNET_OK;
             case 'q':
               iprintf (indent, _("Aborted.\n"));
-              return SYSERR;    /* escape */
+              return GNUNET_SYSERR;     /* escape */
             case '?':
               iprintf (indent, "%c\n", choice);
               iprintf (indent, "%s\n", gettext (tree->help));
@@ -511,24 +511,25 @@
       i = 0;
       while (tree->children[i] != NULL)
         {
-          if (SYSERR == conf (indent + 1, cfg, ectx, tree->children[i]))
-            return SYSERR;
+          if (GNUNET_SYSERR ==
+              conf (indent + 1, cfg, ectx, tree->children[i]))
+            return GNUNET_SYSERR;
           i++;
         }
-      return OK;
+      return GNUNET_OK;
     default:
       fprintf (stderr,
                _("Unknown kind %x (internal error).  Aborting.\n"),
                tree->type & GNS_KindMask);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 int
 main_setup_text (int argc,
                  const char **argv,
-                 struct PluginHandle *self,
+                 struct GNUNET_PluginHandle *self,
                  struct GE_Context *ectx,
                  struct GC_Configuration *cfg,
                  struct GNS_Context *gns, const char *filename, int is_daemon)
@@ -555,7 +556,7 @@
   c = 'r';
   while (c == 'r')
     {
-      if (OK != conf (-1, cfg, ectx, root))
+      if (GNUNET_OK != conf (-1, cfg, ectx, root))
         {
           ioctl (0, TCSETS, &oldT);
           return 1;
@@ -606,7 +607,7 @@
 int
 dump_setup_text (int argc,
                  const char **argv,
-                 struct PluginHandle *self,
+                 struct GNUNET_PluginHandle *self,
                  struct GE_Context *ectx,
                  struct GC_Configuration *cfg,
                  struct GNS_Context *gns, const char *filename, int is_daemon)

Modified: GNUnet/src/setup/text/conf.h
===================================================================
--- GNUnet/src/setup/text/conf.h        2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/setup/text/conf.h        2007-11-23 11:51:54 UTC (rev 5742)
@@ -33,7 +33,7 @@
 
 int main_setup_text (int argc,
                      const char **argv,
-                     struct PluginHandle *self,
+                     struct GNUNET_PluginHandle *self,
                      struct GE_Context *ectx,
                      struct GC_Configuration *cfg,
                      struct GNS_Context *gns,
@@ -41,7 +41,7 @@
 
 int dump_setup_text (int argc,
                      const char **argv,
-                     struct PluginHandle *self,
+                     struct GNUNET_PluginHandle *self,
                      struct GE_Context *ectx,
                      struct GC_Configuration *cfg,
                      struct GNS_Context *gns,

Modified: GNUnet/src/transports/Makefile.am
===================================================================
--- GNUnet/src/transports/Makefile.am   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/Makefile.am   2007-11-23 11:51:54 UTC (rev 5742)
@@ -66,7 +66,6 @@
 libgnunettransport_http_la_LIBADD = \
  -lmicrohttpd @LIBCURL@ \
  $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
  libgnunetip.la
 libgnunettransport_http_la_LDFLAGS = \
  -export-dynamic -avoid-version -module 
@@ -117,60 +116,30 @@
 test_udp_SOURCES = \
  test.c 
 test_udp_LDADD = \
- $(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/boot/libgnunetutil_boot.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 test_tcp_SOURCES = \
  test.c 
 test_tcp_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
- $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 test_http_SOURCES = \
  test.c 
 test_http_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
- $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 testrepeat_tcp_SOURCES = \
  test_repeat.c 
 testrepeat_tcp_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
- $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 testrepeat_udp_SOURCES = \
  test_repeat.c 
 testrepeat_udp_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
- $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 testrepeat_http_SOURCES = \
  test_repeat.c 
 testrepeat_http_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
- $(top_builddir)/src/util/boot/libgnunetutil_boot.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la
+ $(top_builddir)/src/util/libgnunetutil.la 
 

Modified: GNUnet/src/transports/http.c
===================================================================
--- GNUnet/src/transports/http.c        2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/http.c        2007-11-23 11:51:54 UTC (rev 5742)
@@ -34,13 +34,13 @@
 #include <curl/curl.h>
 #include "ip.h"
 
-#define DEBUG_HTTP NO
+#define DEBUG_HTTP GNUNET_NO
 
 /**
- * Disable GET (for debugging only!).  Must be YES
+ * Disable GET (for debugging only!).  Must be GNUNET_YES
  * in production use!
  */
-#define DO_GET YES
+#define DO_GET GNUNET_YES
 
 /**
  * After how much time of the core not being associated with a http
@@ -49,7 +49,7 @@
  * Needs to be larger than SECONDS_INACTIVE_DROP in
  * core's connection.s
  */
-#define HTTP_TIMEOUT (600 * cronSECONDS)
+#define HTTP_TIMEOUT (600 * GNUNET_CRON_SECONDS)
 
 /**
  * Default maximum size of the HTTP read and write buffer.
@@ -58,14 +58,14 @@
 
 /**
  * Text of the response sent back after the last bytes of a PUT
- * request have been received (just to formally obey the HTTP 
+ * request have been received (just to formally obey the HTTP
  * protocol).
  */
 #define HTTP_PUT_RESPONSE "Thank you!"
 
-#define ENTER() /* fprintf(stderr, "E(%u-%s)\n", __LINE__, __FUNCTION__) */
-#define EXIT() /* fprintf(stderr, "X(%u-%s)\n", __LINE__, __FUNCTION__) */
-#define STEP() /* fprintf(stderr, "S(%u-%s)\n", __LINE__, __FUNCTION__) */
+#define ENTER()                 /* fprintf(stderr, "E(%u-%s)\n", __LINE__, 
__FUNCTION__) */
+#define EXIT()                  /* fprintf(stderr, "X(%u-%s)\n", __LINE__, 
__FUNCTION__) */
+#define STEP()                  /* fprintf(stderr, "S(%u-%s)\n", __LINE__, 
__FUNCTION__) */
 
 /**
  * Host-Address in a HTTP network.
@@ -75,7 +75,7 @@
   /**
    * claimed IP of the sender, network byte order
    */
-  IPaddr ip;
+  GNUNET_IPv4Address ip;
 
   /**
    * claimed port of the sender, network byte order
@@ -107,7 +107,7 @@
   /**
    * Last time we made progress with the PUT.
    */
-  cron_t last_activity;
+  GNUNET_CronTime last_activity;
 
   /**
    * The message we are sending.
@@ -153,12 +153,12 @@
    * Last time we received data on this PUT
    * connection.
    */
-  cron_t last_activity;
+  GNUNET_CronTime last_activity;
 
   /**
    * Read buffer for the header (from PUT)
    */
-  char rbuff1[sizeof (MESSAGE_HEADER)];
+  char rbuff1[sizeof (GNUNET_MessageHeader)];
 
   /**
    * The read buffer (used only receiving PUT data).
@@ -207,7 +207,7 @@
   /**
    * mutex for synchronized access to struct
    */
-  struct MUTEX *lock;
+  struct GNUNET_Mutex *lock;
 
   /**
    * MHD connection handle for this request.
@@ -233,7 +233,7 @@
    * What was the last time we were able to
    * transmit data using the current get handle?
    */
-  cron_t last_get_activity;
+  GNUNET_CronTime last_get_activity;
 
   /**
    * Current write position in wbuff
@@ -266,13 +266,13 @@
   /**
    * mutex for synchronized access to struct
    */
-  struct MUTEX *lock;
+  struct GNUNET_Mutex *lock;
 
   /**
    * To whom are we talking to (set to our identity
    * if we are still waiting for the welcome message)
    */
-  PeerIdentity sender;
+  GNUNET_PeerIdentity sender;
 
   /**
    * number of users of this session
@@ -332,7 +332,7 @@
       /**
        * Last time the GET was active.
        */
-      cron_t last_get_activity;
+      GNUNET_CronTime last_get_activity;
 
       /**
        * GET operation
@@ -342,7 +342,7 @@
       /**
        * Read buffer for the header (from GET).
        */
-      char rbuff1[sizeof (MESSAGE_HEADER)];
+      char rbuff1[sizeof (GNUNET_MessageHeader)];
 
       /**
        * The read buffer (used only receiving GET data).
@@ -411,14 +411,14 @@
 static CURLM *curl_multi;
 
 /**
- * Set to YES while the transport is running.
+ * Set to GNUNET_YES while the transport is running.
  */
 static int http_running;
 
 /**
  * Thread running libcurl activities.
  */
-static struct PTHREAD *curl_thread;
+static struct GNUNET_ThreadHandle *curl_thread;
 
 /**
  * Array of currently active HTTP sessions.
@@ -438,7 +438,7 @@
 /**
  * Blacklist configuration
  */
-static struct CIDRNetwork *filteredNetworks_;
+static struct GNUNET_IPv4NetworkSet *filteredNetworks_;
 
 /**
  * Universal plug & play (firewall hole punching)
@@ -457,13 +457,13 @@
  * prevent the select thread from operating and removing
  * is done by the only therad that reads from the array.
  */
-static struct MUTEX * httplock;
+static struct GNUNET_Mutex *httplock;
 
 /**
  * CURL requires that only one thread manipulates each
  * handle.  This lock is used to ensure that.
  */
-static struct MUTEX * curllock;
+static struct GNUNET_Mutex *curllock;
 
 
 /**
@@ -474,9 +474,9 @@
 signal_select ()
 {
   static char c;
-  ENTER();
+  ENTER ();
   write (signal_pipe[1], &c, sizeof (c));
-  EXIT();
+  EXIT ();
 }
 
 /**
@@ -486,15 +486,16 @@
 acceptPolicyCallback (void *cls,
                       const struct sockaddr *addr, socklen_t addr_len)
 {
-  IPaddr ip;
+  GNUNET_IPv4Address ip;
   int ret;
 
-  ENTER();
+  ENTER ();
   if (addr_len == sizeof (struct sockaddr_in))
     {
-      memcpy (&ip, &((struct sockaddr_in *) addr)->sin_addr, sizeof (IPaddr));
+      memcpy (&ip, &((struct sockaddr_in *) addr)->sin_addr,
+              sizeof (GNUNET_IPv4Address));
     }
-  else if (addr_len == sizeof (IPaddr))
+  else if (addr_len == sizeof (GNUNET_IPv4Address))
     {
       memcpy (&ip, addr, addr_len);
     }
@@ -505,27 +506,27 @@
               GE_DEBUG | GE_DEVELOPER | GE_BULK,
               "Rejecting HTTP connection\n");
 #endif
-      EXIT();
+      EXIT ();
       return MHD_NO;
     }
-  MUTEX_LOCK (httplock);
-  ret = check_ipv4_listed (filteredNetworks_, ip);
-  MUTEX_UNLOCK (httplock);
-  if (YES == ret)
+  GNUNET_mutex_lock (httplock);
+  ret = GNUNET_check_ipv4_listed (filteredNetworks_, ip);
+  GNUNET_mutex_unlock (httplock);
+  if (GNUNET_YES == ret)
     {
 #if DEBUG_HTTP
       GE_LOG (coreAPI->ectx,
               GE_DEBUG | GE_DEVELOPER | GE_BULK,
               "Rejecting HTTP connection\n");
 #endif
-      EXIT();
+      EXIT ();
       return MHD_NO;
     }
 #if DEBUG_HTTP
   GE_LOG (coreAPI->ectx,
           GE_DEBUG | GE_DEVELOPER | GE_BULK, "Accepting HTTP connection\n");
 #endif
-  EXIT();
+  EXIT ();
   return MHD_YES;
 }
 
@@ -535,28 +536,28 @@
  * For the core, aquiration means to call associate or
  * connect. The number of disconnects must match the
  * number of calls to connect+associate.
- * 
+ *
  * Sessions are actually discarded in cleanup_connections.
- * 
  *
+ *
  * @param tsession the session that is closed
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
 httpDisconnect (TSession * tsession)
 {
   HTTPSession *httpsession = tsession->internal;
-  ENTER();
+  ENTER ();
   if (httpsession == NULL)
     {
-      FREE (tsession);
-      return OK;
+      GNUNET_free (tsession);
+      return GNUNET_OK;
     }
-  MUTEX_LOCK (httpsession->lock);
+  GNUNET_mutex_lock (httpsession->lock);
   httpsession->users--;
-  MUTEX_UNLOCK (httpsession->lock);
-  EXIT();
-  return OK;
+  GNUNET_mutex_unlock (httpsession->lock);
+  EXIT ();
+  return GNUNET_OK;
 }
 
 static void
@@ -574,8 +575,8 @@
   struct MHD_Response *r;
   int i;
 
-  ENTER();
-  MUTEX_LOCK (httplock);
+  ENTER ();
+  GNUNET_mutex_lock (httplock);
   for (i = 0; i < tsessionCount; i++)
     {
       if (tsessions[i] == tsession)
@@ -584,51 +585,52 @@
           break;
         }
     }
-  MUTEX_UNLOCK (httplock);
+  GNUNET_mutex_unlock (httplock);
   if (httpsession->is_client)
     {
-      MUTEX_LOCK (curllock);
+      GNUNET_mutex_lock (curllock);
 #if DO_GET
-      STEP();
+      STEP ();
       curl_multi_remove_handle (curl_multi, httpsession->cs.client.get);
-      STEP();
+      STEP ();
       signal_select ();
-      STEP();
+      STEP ();
       curl_easy_cleanup (httpsession->cs.client.get);
-      STEP();
-      GROW (httpsession->cs.client.rbuff2, httpsession->cs.client.rsize2, 0);
+      STEP ();
+      GNUNET_array_grow (httpsession->cs.client.rbuff2,
+                         httpsession->cs.client.rsize2, 0);
 #endif
-      FREE (httpsession->cs.client.url);
+      GNUNET_free (httpsession->cs.client.url);
       pos = httpsession->cs.client.puts;
       while (pos != NULL)
         {
           next = pos->next;
-         STEP();
+          STEP ();
           curl_multi_remove_handle (curl_multi, pos->curl_put);
-         STEP();
+          STEP ();
           signal_select ();
           curl_easy_cleanup (pos->curl_put);
-         STEP();
-          FREE (pos->msg);
-          FREE (pos);
+          STEP ();
+          GNUNET_free (pos->msg);
+          GNUNET_free (pos);
           pos = next;
         }
-      MUTEX_UNLOCK (curllock);
-      MUTEX_DESTROY (httpsession->lock);
-      FREE (httpsession);
-      FREE (tsession);
+      GNUNET_mutex_unlock (curllock);
+      GNUNET_mutex_destroy (httpsession->lock);
+      GNUNET_free (httpsession);
+      GNUNET_free (tsession);
     }
   else
     {
-      httpsession->destroyed = YES;
+      httpsession->destroyed = GNUNET_YES;
       mpos = httpsession->cs.server.puts;
       /* this should be NULL already, but just
          in case it is not, we free it anyway... */
       while (mpos != NULL)
         {
           mnext = mpos->next;
-          GROW (mpos->rbuff2, mpos->rsize2, 0);
-          FREE (mpos);
+          GNUNET_array_grow (mpos->rbuff2, mpos->rsize2, 0);
+          GNUNET_free (mpos);
           mpos = mnext;
         }
       httpsession->cs.server.puts = NULL;
@@ -636,7 +638,7 @@
       gpos = httpsession->cs.server.gets;
       while (gpos != NULL)
         {
-          GROW (gpos->wbuff, gpos->wsize, 0);
+          GNUNET_array_grow (gpos->wbuff, gpos->wsize, 0);
           r = gpos->get;
           gpos->get = NULL;
           /* contentReaderFreeCallback WILL
@@ -647,11 +649,11 @@
         }
       httpsession->cs.server.gets = NULL;
 #endif
-      MUTEX_DESTROY (httpsession->lock);
-      FREE (httpsession->tsession);
-      FREE (httpsession);
+      GNUNET_mutex_destroy (httpsession->lock);
+      GNUNET_free (httpsession->tsession);
+      GNUNET_free (httpsession);
     }
-  EXIT();
+  EXIT ();
 }
 
 /**
@@ -671,7 +673,7 @@
   struct MHDGetData *gpos;
 #endif
 
-  ENTER();
+  ENTER ();
   if (httpsession == NULL)
     return;                     /* oops */
   GE_ASSERT (NULL, !httpsession->is_client);
@@ -704,7 +706,7 @@
     }
 #endif
   httpsession->is_mhd_active--;
-  EXIT();
+  EXIT ();
 }
 
 /**
@@ -716,12 +718,12 @@
 {
   unsigned long long port;
 
-  ENTER();
+  ENTER ();
   if (-1 == GC_get_configuration_value_number (coreAPI->cfg,
                                                "HTTP",
                                                "PORT", 0, 65535, 1080, &port))
     port = 1080;
-  EXIT();
+  EXIT ();
   return (unsigned short) port;
 }
 
@@ -734,7 +736,7 @@
 {
   unsigned long long port;
 
-  ENTER();
+  ENTER ();
   if (!GC_have_configuration_value (coreAPI->cfg, "HTTP", "ADVERTISED-PORT"))
     {
       port = getGNUnetHTTPPort ();
@@ -744,7 +746,7 @@
                                                     "ADVERTISED-PORT", 0,
                                                     65535, 80, &port))
     port = getGNUnetHTTPPort ();
-  EXIT();
+  EXIT ();
   return (unsigned short) port;
 }
 
@@ -756,7 +758,7 @@
  * later, in this case the argument session is NULL. This can be used
  * to test if the connection must be closed by the core or if the core
  * can assume that it is going to be self-managed (if associate
- * returns OK and session was NULL, the transport layer is responsible
+ * returns GNUNET_OK and session was NULL, the transport layer is responsible
  * for eventually freeing resources associated with the tesession). If
  * session is not NULL, the core takes responsbility for eventually
  * calling disconnect.
@@ -764,33 +766,33 @@
  * @param tsession the session handle passed along
  *   from the call to receive that was made by the transport
  *   layer
- * @return OK if the session could be associated,
- *         SYSERR if not.
+ * @return GNUNET_OK if the session could be associated,
+ *         GNUNET_SYSERR if not.
  */
 static int
 httpAssociate (TSession * tsession)
 {
   HTTPSession *httpSession;
 
-  ENTER();
+  ENTER ();
   if (tsession == NULL)
     {
       GE_BREAK (NULL, 0);
-      EXIT();  
-      return SYSERR;
+      EXIT ();
+      return GNUNET_SYSERR;
     }
   httpSession = tsession->internal;
-  MUTEX_LOCK (httpSession->lock);
-  if (httpSession->destroyed == YES)
+  GNUNET_mutex_lock (httpSession->lock);
+  if (httpSession->destroyed == GNUNET_YES)
     {
-      MUTEX_UNLOCK (httpSession->lock);
-      EXIT();
-      return SYSERR;
+      GNUNET_mutex_unlock (httpSession->lock);
+      EXIT ();
+      return GNUNET_SYSERR;
     }
   httpSession->users++;
-  MUTEX_UNLOCK (httpSession->lock);
-  EXIT();
-  return OK;
+  GNUNET_mutex_unlock (httpSession->lock);
+  EXIT ();
+  return GNUNET_OK;
 }
 
 
@@ -801,46 +803,46 @@
  * success.
  * @param helo the hello message to verify
  *        (the signature/crc have been verified before)
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
-verifyHello (const P2P_hello_MESSAGE * hello)
+verifyHello (const GNUNET_MessageHello * hello)
 {
   const HostAddress *haddr;
 
-  ENTER();
+  ENTER ();
   haddr = (const HostAddress *) &hello[1];
   if ((ntohs (hello->senderAddressSize) != sizeof (HostAddress)) ||
-      (ntohs (hello->header.size) != P2P_hello_MESSAGE_size (hello)) ||
+      (ntohs (hello->header.size) != GNUNET_sizeof_hello (hello)) ||
       (ntohs (hello->header.type) != p2p_PROTO_hello) ||
       (ntohs (hello->protocol) != HTTP_PROTOCOL_NUMBER) ||
       (MHD_NO == acceptPolicyCallback (NULL,
                                        (const struct sockaddr *) haddr,
-                                       sizeof (IPaddr))))
+                                       sizeof (GNUNET_IPv4Address))))
     {
       GE_BREAK_OP (NULL, 0);
-      EXIT();
-      return SYSERR;            /* obviously invalid */
+      EXIT ();
+      return GNUNET_SYSERR;     /* obviously invalid */
     }
-  EXIT();
-  return OK;
+  EXIT ();
+  return GNUNET_OK;
 }
 
 /**
  * Create a hello-Message for the current node. The hello is
  * created without signature and without a timestamp. The
- * GNUnet core will sign the message and add an expiration time.
+ * GNUnet core will GNUNET_RSA_sign the message and add an expiration time.
  *
  * @return hello on success, NULL on error
  */
-static P2P_hello_MESSAGE *
+static GNUNET_MessageHello *
 createhello ()
 {
-  P2P_hello_MESSAGE *msg;
+  GNUNET_MessageHello *msg;
   HostAddress *haddr;
   unsigned short port;
 
-  ENTER();
+  ENTER ();
   port = getGNUnetAdvertisedHTTPPort ();
   if (0 == port)
     {
@@ -849,20 +851,20 @@
               GE_DEBUG | GE_REQUEST | GE_USER,
               "HTTP port is 0, will only send using HTTP.\n");
 #endif
-      EXIT();
+      EXIT ();
       return NULL;              /* HTTP transport is configured SEND-only! */
     }
-  msg = MALLOC (sizeof (P2P_hello_MESSAGE) + sizeof (HostAddress));
+  msg = GNUNET_malloc (sizeof (GNUNET_MessageHello) + sizeof (HostAddress));
   haddr = (HostAddress *) & msg[1];
 
   if (!(((upnp != NULL) &&
-         (OK == upnp->get_ip (port,
-                              "TCP",
-                              &haddr->ip))) ||
-        (SYSERR != getPublicIPAddress (coreAPI->cfg,
-                                       coreAPI->ectx, &haddr->ip))))
+         (GNUNET_OK == upnp->get_ip (port,
+                                     "TCP",
+                                     &haddr->ip))) ||
+        (GNUNET_SYSERR != getPublicIPAddress (coreAPI->cfg,
+                                              coreAPI->ectx, &haddr->ip))))
     {
-      FREE (msg);
+      GNUNET_free (msg);
       GE_LOG (coreAPI->ectx,
               GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
               _("HTTP: Could not determine my public IP address.\n"));
@@ -872,14 +874,14 @@
   GE_LOG (coreAPI->ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "HTTP uses IP address %u.%u.%u.%u.\n",
-          PRIP (ntohl (*(int *) &haddr->ip)));
+          GNUNET_PRIP (ntohl (*(int *) &haddr->ip)));
 #endif
   haddr->port = htons (port);
   haddr->reserved = htons (0);
   msg->senderAddressSize = htons (sizeof (HostAddress));
   msg->protocol = htons (HTTP_PROTOCOL_NUMBER);
   msg->MTU = htonl (0);
-  EXIT();
+  EXIT ();
   return msg;
 }
 
@@ -895,14 +897,15 @@
 {
   unsigned int i;
 
-  ENTER();
-  MUTEX_LOCK (httplock);
+  ENTER ();
+  GNUNET_mutex_lock (httplock);
   if (tsessionCount == tsessionArrayLength)
-    GROW (tsessions, tsessionArrayLength, tsessionArrayLength * 2);
+    GNUNET_array_grow (tsessions, tsessionArrayLength,
+                       tsessionArrayLength * 2);
   i = tsessionCount;
   tsessions[tsessionCount++] = tsession;
-  MUTEX_UNLOCK (httplock);
-  EXIT();
+  GNUNET_mutex_unlock (httplock);
+  EXIT ();
   return i;
 }
 
@@ -921,21 +924,21 @@
 contentReaderCallback (void *cls, size_t pos, char *buf, int max)
 {
   struct MHDGetData *mgd = cls;
-  cron_t now;
+  GNUNET_CronTime now;
 
-  ENTER();
-  MUTEX_LOCK (mgd->lock);
+  ENTER ();
+  GNUNET_mutex_lock (mgd->lock);
   if (mgd->wpos < max)
     max = mgd->wpos;
   memcpy (buf, &mgd->wbuff[mgd->woff], max);
   mgd->wpos -= max;
   mgd->woff += max;
-  now = get_time ();
+  now = GNUNET_get_time ();
   if (max > 0)
     mgd->last_get_activity = now;
   if (mgd->wpos == 0)
     mgd->woff = 0;
-  MUTEX_UNLOCK (mgd->lock);
+  GNUNET_mutex_unlock (mgd->lock);
 #if DEBUG_HTTP
   GE_LOG (coreAPI->ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
@@ -943,11 +946,12 @@
 #endif
   if (stats != NULL)
     stats->change (stat_bytesSent, max);
-  if ((max == 0) && (mgd->httpsession->cs.server.gets != mgd)) {
-    EXIT();
-    return -1;                  /* end of response (another GET replaces this 
one) */
-  }
-  EXIT();
+  if ((max == 0) && (mgd->httpsession->cs.server.gets != mgd))
+    {
+      EXIT ();
+      return -1;                /* end of response (another GET replaces this 
one) */
+    }
+  EXIT ();
   return max;
 }
 #endif
@@ -962,12 +966,12 @@
 {
   struct MHDGetData *mgd = cls;
 
-  ENTER();
+  ENTER ();
   GE_ASSERT (NULL, mgd->get == NULL);
-  MUTEX_DESTROY (mgd->lock);
-  GROW (mgd->wbuff, mgd->wsize, 0);
-  FREE (mgd);
-  EXIT();
+  GNUNET_mutex_destroy (mgd->lock);
+  GNUNET_array_grow (mgd->wbuff, mgd->wsize, 0);
+  GNUNET_free (mgd);
+  EXIT ();
 }
 #endif
 
@@ -993,21 +997,22 @@
   struct MHDGetData *get;
   HTTPSession *httpSession;
   struct MHD_Response *response;
-  HashCode512 client;
+  GNUNET_HashCode client;
   int i;
   unsigned int have;
-  MESSAGE_HEADER *hdr;
+  GNUNET_MessageHeader *hdr;
   P2P_PACKET *mp;
   unsigned int cpy;
   unsigned int poff;
 
-  ENTER();
+  ENTER ();
   /* convert URL to sender peer id */
-  if ((strlen (url) < 2) || (OK != enc2hash (&url[1], &client)))
+  if ((strlen (url) < 2)
+      || (GNUNET_OK != GNUNET_enc_to_hash (&url[1], &client)))
     {
       /* invalid request */
-      /* GE_BREAK_OP (NULL, 0); -- this happens a lot, most likely 
-        somebody scanning for MyDoom.X-opened backdoors */
+      /* GE_BREAK_OP (NULL, 0); -- this happens a lot, most likely
+         somebody scanning for MyDoom.X-opened backdoors */
       return MHD_NO;
     }
 
@@ -1015,19 +1020,20 @@
   httpSession = *httpSessionCache;
   if (httpSession == NULL)
     {
-      MUTEX_LOCK (httplock);
+      GNUNET_mutex_lock (httplock);
       for (i = 0; i < tsessionCount; i++)
         {
           tsession = tsessions[i];
           httpSession = tsession->internal;
           if ((0 ==
-               memcmp (&httpSession->sender, &client, sizeof (HashCode512)))
-              && (httpSession->is_client == NO))
+               memcmp (&httpSession->sender, &client,
+                       sizeof (GNUNET_HashCode)))
+              && (httpSession->is_client == GNUNET_NO))
             break;
           tsession = NULL;
           httpSession = NULL;
         }
-      MUTEX_UNLOCK (httplock);
+      GNUNET_mutex_unlock (httplock);
     }
   /* create new session if necessary */
   if (httpSession == NULL)
@@ -1038,12 +1044,12 @@
               "HTTP/MHD creates new session for request from `%s'.\n",
               &url[1]);
 #endif
-      httpSession = MALLOC (sizeof (HTTPSession));
+      httpSession = GNUNET_malloc (sizeof (HTTPSession));
       memset (httpSession, 0, sizeof (HTTPSession));
       httpSession->sender.hashPubKey = client;
-      httpSession->lock = MUTEX_CREATE (YES);
+      httpSession->lock = GNUNET_mutex_create (GNUNET_YES);
       httpSession->users = 0;   /* MHD */
-      tsession = MALLOC (sizeof (TSession));
+      tsession = GNUNET_malloc (sizeof (TSession));
       memset (tsession, 0, sizeof (TSession));
       tsession->ttype = HTTP_PROTOCOL_NUMBER;
       tsession->internal = httpSession;
@@ -1056,7 +1062,7 @@
       httpSession->is_mhd_active++;
       *httpSessionCache = httpSession;
     }
-  MUTEX_LOCK (httpSession->lock);
+  GNUNET_mutex_lock (httpSession->lock);
 #if DO_GET
   if (0 == strcasecmp (MHD_HTTP_METHOD_GET, method))
     {
@@ -1066,27 +1072,27 @@
               "HTTP/MHD receives GET request from `%s'.\n", &url[1]);
 #endif
 
-      /* handle get; create response object if we do not 
+      /* handle get; create response object if we do not
          have one already */
-      get = MALLOC (sizeof (struct MHDGetData));
+      get = GNUNET_malloc (sizeof (struct MHDGetData));
       memset (get, 0, sizeof (struct MHDGetData));
-      get->lock = MUTEX_CREATE (NO);
+      get->lock = GNUNET_mutex_create (GNUNET_NO);
       get->next = httpSession->cs.server.gets;
       httpSession->cs.server.gets = get;
       get->session = session;
       get->httpsession = httpSession;
-      get->last_get_activity = get_time ();
-      STEP();
+      get->last_get_activity = GNUNET_get_time ();
+      STEP ();
       get->get = MHD_create_response_from_callback (-1,
                                                     64 * 1024,
                                                     contentReaderCallback,
                                                     get,
                                                     contentReaderFreeCallback);
-      STEP();
+      STEP ();
       MHD_queue_response (session, MHD_HTTP_OK, get->get);
-      STEP();
-      MUTEX_UNLOCK (httpSession->lock);
-      EXIT();
+      STEP ();
+      GNUNET_mutex_unlock (httpSession->lock);
+      EXIT ();
       return MHD_YES;
     }
 #endif
@@ -1103,13 +1109,13 @@
         put = put->next;
       if (put == NULL)
         {
-          put = MALLOC (sizeof (struct MHDPutData));
+          put = GNUNET_malloc (sizeof (struct MHDPutData));
           memset (put, 0, sizeof (struct MHDPutData));
           put->next = httpSession->cs.server.puts;
           httpSession->cs.server.puts = put;
           put->session = session;
         }
-      put->last_activity = get_time ();
+      put->last_activity = GNUNET_get_time ();
 
       /* handle put (upload_data!) */
       poff = 0;
@@ -1117,33 +1123,34 @@
       if (stats != NULL)
         stats->change (stat_bytesReceived, have);
       *upload_data_size = 0;    /* we will always process everything */
-      if ((have == 0) && (put->done == NO) && (put->ready == YES))
+      if ((have == 0) && (put->done == GNUNET_NO)
+          && (put->ready == GNUNET_YES))
         {
-          put->done = YES;
+          put->done = GNUNET_YES;
           /* end of upload, send response! */
 #if DEBUG_HTTP
           GE_LOG (coreAPI->ectx,
                   GE_DEBUG | GE_REQUEST | GE_USER,
                   "HTTP/MHD queues dummy response to completed PUT 
request.\n");
 #endif
-         STEP();
+          STEP ();
           response =
             MHD_create_response_from_data (strlen (HTTP_PUT_RESPONSE),
                                            HTTP_PUT_RESPONSE, MHD_NO, MHD_NO);
-         STEP();
+          STEP ();
           MHD_queue_response (session, MHD_HTTP_OK, response);
-         STEP();
+          STEP ();
           MHD_destroy_response (response);
-         STEP();
-          MUTEX_UNLOCK (httpSession->lock);
+          STEP ();
+          GNUNET_mutex_unlock (httpSession->lock);
           return MHD_YES;
         }
       while (have > 0)
         {
-          put->ready = NO;
-          if (put->rpos1 < sizeof (MESSAGE_HEADER))
+          put->ready = GNUNET_NO;
+          if (put->rpos1 < sizeof (GNUNET_MessageHeader))
             {
-              cpy = sizeof (MESSAGE_HEADER) - put->rpos1;
+              cpy = sizeof (GNUNET_MessageHeader) - put->rpos1;
               if (cpy > have)
                 cpy = have;
               memcpy (&put->rbuff1[put->rpos1], &upload_data[poff], cpy);
@@ -1152,14 +1159,18 @@
               poff += cpy;
               put->rpos2 = 0;
             }
-          if (put->rpos1 < sizeof (MESSAGE_HEADER))
+          if (put->rpos1 < sizeof (GNUNET_MessageHeader))
             break;
-          hdr = (MESSAGE_HEADER *) put->rbuff1;
-          GROW (put->rbuff2,
-                put->rsize2, ntohs (hdr->size) - sizeof (MESSAGE_HEADER));
-          if (put->rpos2 < ntohs (hdr->size) - sizeof (MESSAGE_HEADER))
+          hdr = (GNUNET_MessageHeader *) put->rbuff1;
+          GNUNET_array_grow (put->rbuff2,
+                             put->rsize2,
+                             ntohs (hdr->size) -
+                             sizeof (GNUNET_MessageHeader));
+          if (put->rpos2 < ntohs (hdr->size) - sizeof (GNUNET_MessageHeader))
             {
-              cpy = ntohs (hdr->size) - sizeof (MESSAGE_HEADER) - put->rpos2;
+              cpy =
+                ntohs (hdr->size) - sizeof (GNUNET_MessageHeader) -
+                put->rpos2;
               if (cpy > have)
                 cpy = have;
               memcpy (&put->rbuff2[put->rpos2], &upload_data[poff], cpy);
@@ -1167,13 +1178,13 @@
               poff += cpy;
               put->rpos2 += cpy;
             }
-          if (put->rpos2 < ntohs (hdr->size) - sizeof (MESSAGE_HEADER))
+          if (put->rpos2 < ntohs (hdr->size) - sizeof (GNUNET_MessageHeader))
             break;
-          mp = MALLOC (sizeof (P2P_PACKET));
+          mp = GNUNET_malloc (sizeof (P2P_PACKET));
           mp->msg = put->rbuff2;
           mp->sender = httpSession->sender;
           mp->tsession = httpSession->tsession;
-          mp->size = ntohs (hdr->size) - sizeof (MESSAGE_HEADER);
+          mp->size = ntohs (hdr->size) - sizeof (GNUNET_MessageHeader);
 #if DEBUG_HTTP
           GE_LOG (coreAPI->ectx,
                   GE_DEBUG | GE_REQUEST | GE_USER,
@@ -1185,14 +1196,14 @@
           put->rpos2 = 0;
           put->rsize2 = 0;
           put->rpos1 = 0;
-          put->ready = YES;
+          put->ready = GNUNET_YES;
         }
-      MUTEX_UNLOCK (httpSession->lock);
+      GNUNET_mutex_unlock (httpSession->lock);
       return MHD_YES;
     }
-  MUTEX_UNLOCK (httpSession->lock);
+  GNUNET_mutex_unlock (httpSession->lock);
   GE_BREAK_OP (NULL, 0);        /* invalid request */
-  EXIT();
+  EXIT ();
   return MHD_NO;
 }
 
@@ -1208,11 +1219,11 @@
   size_t have = size * nmemb;
   size_t poff = 0;
   size_t cpy;
-  MESSAGE_HEADER *hdr;
+  GNUNET_MessageHeader *hdr;
   P2P_PACKET *mp;
 
-  ENTER();
-  httpSession->cs.client.last_get_activity = get_time ();
+  ENTER ();
+  httpSession->cs.client.last_get_activity = GNUNET_get_time ();
 #if DEBUG_HTTP
   GE_LOG (coreAPI->ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
@@ -1220,9 +1231,9 @@
 #endif
   while (have > 0)
     {
-      if (httpSession->cs.client.rpos1 < sizeof (MESSAGE_HEADER))
+      if (httpSession->cs.client.rpos1 < sizeof (GNUNET_MessageHeader))
         {
-          cpy = sizeof (MESSAGE_HEADER) - httpSession->cs.client.rpos1;
+          cpy = sizeof (GNUNET_MessageHeader) - httpSession->cs.client.rpos1;
           if (cpy > have)
             cpy = have;
           memcpy (&httpSession->cs.client.
@@ -1232,17 +1243,17 @@
           poff += cpy;
           httpSession->cs.client.rpos2 = 0;
         }
-      if (httpSession->cs.client.rpos1 < sizeof (MESSAGE_HEADER))
+      if (httpSession->cs.client.rpos1 < sizeof (GNUNET_MessageHeader))
         break;
-      hdr = (MESSAGE_HEADER *) httpSession->cs.client.rbuff1;
-      GROW (httpSession->cs.client.rbuff2,
-            httpSession->cs.client.rsize2,
-            ntohs (hdr->size) - sizeof (MESSAGE_HEADER));
+      hdr = (GNUNET_MessageHeader *) httpSession->cs.client.rbuff1;
+      GNUNET_array_grow (httpSession->cs.client.rbuff2,
+                         httpSession->cs.client.rsize2,
+                         ntohs (hdr->size) - sizeof (GNUNET_MessageHeader));
       if (httpSession->cs.client.rpos2 <
-          ntohs (hdr->size) - sizeof (MESSAGE_HEADER))
+          ntohs (hdr->size) - sizeof (GNUNET_MessageHeader))
         {
           cpy =
-            ntohs (hdr->size) - sizeof (MESSAGE_HEADER) -
+            ntohs (hdr->size) - sizeof (GNUNET_MessageHeader) -
             httpSession->cs.client.rpos2;
           if (cpy > have)
             cpy = have;
@@ -1253,13 +1264,13 @@
           httpSession->cs.client.rpos2 += cpy;
         }
       if (httpSession->cs.client.rpos2 <
-          ntohs (hdr->size) - sizeof (MESSAGE_HEADER))
+          ntohs (hdr->size) - sizeof (GNUNET_MessageHeader))
         break;
-      mp = MALLOC (sizeof (P2P_PACKET));
+      mp = GNUNET_malloc (sizeof (P2P_PACKET));
       mp->msg = httpSession->cs.client.rbuff2;
       mp->sender = httpSession->sender;
       mp->tsession = httpSession->tsession;
-      mp->size = ntohs (hdr->size) - sizeof (MESSAGE_HEADER);
+      mp->size = ntohs (hdr->size) - sizeof (GNUNET_MessageHeader);
       coreAPI->receive (mp);
       httpSession->cs.client.rbuff2 = NULL;
       httpSession->cs.client.rpos2 = 0;
@@ -1268,7 +1279,7 @@
     }
   if (stats != NULL)
     stats->change (stat_bytesReceived, size * nmemb);
-  EXIT();
+  EXIT ();
   return size * nmemb;
 }
 #endif
@@ -1283,8 +1294,8 @@
   struct HTTPPutData *put = ctx;
   size_t max = size * nmemb;
 
-  ENTER();
-  put->last_activity = get_time ();
+  ENTER ();
+  put->last_activity = GNUNET_get_time ();
   if (max > put->size - put->pos)
     max = put->size - put->pos;
   memcpy (ptr, &put->msg[put->pos], max);
@@ -1296,7 +1307,7 @@
 #endif
   if (stats != NULL)
     stats->change (stat_bytesSent, max);
-  EXIT();
+  EXIT ();
   return max;
 }
 
@@ -1306,31 +1317,32 @@
 create_session_url (HTTPSession * httpSession)
 {
   char *url;
-  EncName enc;
+  GNUNET_EncName enc;
 
-  ENTER();
+  ENTER ();
   url = httpSession->cs.client.url;
   if (url == NULL)
     {
-      hash2enc (&coreAPI->myIdentity->hashPubKey, &enc);
-      url = MALLOC (64 + sizeof (EncName));
-      SNPRINTF (url,
-                64 + sizeof (EncName),
-                "http://%u.%u.%u.%u:%u/%s";,
-                PRIP (ntohl
-                      (*(int *) &httpSession->cs.client.address.ip.addr)),
-                ntohs (httpSession->cs.client.address.port), &enc);
+      GNUNET_hash_to_enc (&coreAPI->myIdentity->hashPubKey, &enc);
+      url = GNUNET_malloc (64 + sizeof (GNUNET_EncName));
+      GNUNET_snprintf (url,
+                       64 + sizeof (GNUNET_EncName),
+                       "http://%u.%u.%u.%u:%u/%s";,
+                       GNUNET_PRIP (ntohl
+                                    (*(int *) &httpSession->cs.client.address.
+                                     ip.addr)),
+                       ntohs (httpSession->cs.client.address.port), &enc);
       httpSession->cs.client.url = url;
     }
-  EXIT();
+  EXIT ();
 }
 
 #if DO_GET
 /**
  * Try to do a GET on the other peer of the given
  * http session.
- * 
- * @return OK on success, SYSERR on error
+ *
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
 create_curl_get (HTTPSession * httpSession)
@@ -1339,24 +1351,24 @@
   CURLcode ret;
   CURLMcode mret;
 
-  ENTER();
+  ENTER ();
   curl_get = httpSession->cs.client.get;
   if (curl_get != NULL)
     {
-      STEP();
-      MUTEX_LOCK (curllock);
+      STEP ();
+      GNUNET_mutex_lock (curllock);
       curl_multi_remove_handle (curl_multi, curl_get);
       signal_select ();
-      STEP();
+      STEP ();
       curl_easy_cleanup (curl_get);
-      MUTEX_UNLOCK (curllock);
-      STEP();
+      GNUNET_mutex_unlock (curllock);
+      STEP ();
       httpSession->cs.client.get = NULL;
     }
   curl_get = curl_easy_init ();
-  STEP();
+  STEP ();
   if (curl_get == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   /* create GET */
   CURL_EASY_SETOPT (curl_get, CURLOPT_FAILONERROR, 1);
   CURL_EASY_SETOPT (curl_get, CURLOPT_URL, httpSession->cs.client.url);
@@ -1376,14 +1388,14 @@
   if (ret != CURLE_OK)
     {
       curl_easy_cleanup (curl_get);
-      EXIT();
-      return SYSERR;
+      EXIT ();
+      return GNUNET_SYSERR;
     }
-  STEP();
-  MUTEX_LOCK (curllock);
+  STEP ();
+  GNUNET_mutex_lock (curllock);
   mret = curl_multi_add_handle (curl_multi, curl_get);
-  MUTEX_UNLOCK (curllock);
-  STEP();
+  GNUNET_mutex_unlock (curllock);
+  STEP ();
   if (mret != CURLM_OK)
     {
       GE_LOG (coreAPI->ectx,
@@ -1392,19 +1404,19 @@
               "curl_multi_add_handle",
               __FILE__, __LINE__, curl_multi_strerror (mret));
       curl_easy_cleanup (curl_get);
-      EXIT();
-      return SYSERR;
+      EXIT ();
+      return GNUNET_SYSERR;
     }
   signal_select ();
-  httpSession->cs.client.last_get_activity = get_time ();
+  httpSession->cs.client.last_get_activity = GNUNET_get_time ();
   httpSession->cs.client.get = curl_get;
 #if DEBUG_HTTP
   GE_LOG (coreAPI->ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "HTTP/CURL initiated GET request.\n");
 #endif
-  EXIT();
-  return OK;
+  EXIT ();
+  return GNUNET_OK;
 }
 #endif
 
@@ -1413,10 +1425,10 @@
  *
  * @param hello the hello-Message for the target node
  * @param tsessionPtr the session handle that is set
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
-httpConnect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr,
+httpConnect (const GNUNET_MessageHello * hello, TSession ** tsessionPtr,
              int may_reuse)
 {
   const HostAddress *haddr = (const HostAddress *) &hello[1];
@@ -1424,39 +1436,39 @@
   HTTPSession *httpSession;
   int i;
 
-  ENTER();
+  ENTER ();
   /* check if we have a session pending for this peer */
   tsession = NULL;
   if (may_reuse)
     {
-      MUTEX_LOCK (httplock);
+      GNUNET_mutex_lock (httplock);
       for (i = 0; i < tsessionCount; i++)
         {
           if (0 == memcmp (&hello->senderIdentity,
-                           &tsessions[i]->peer, sizeof (PeerIdentity)))
+                           &tsessions[i]->peer, sizeof (GNUNET_PeerIdentity)))
             {
               tsession = tsessions[i];
               break;
             }
         }
-      if ((tsession != NULL) && (OK == httpAssociate (tsession)))
+      if ((tsession != NULL) && (GNUNET_OK == httpAssociate (tsession)))
         {
           *tsessionPtr = tsession;
-          MUTEX_UNLOCK (httplock);
-         EXIT();
-          return OK;
+          GNUNET_mutex_unlock (httplock);
+          EXIT ();
+          return GNUNET_OK;
         }
-      MUTEX_UNLOCK (httplock);
+      GNUNET_mutex_unlock (httplock);
     }
   /* no session pending, initiate a new one! */
-  httpSession = MALLOC (sizeof (HTTPSession));
+  httpSession = GNUNET_malloc (sizeof (HTTPSession));
   memset (httpSession, 0, sizeof (HTTPSession));
   httpSession->sender = hello->senderIdentity;
-  httpSession->lock = MUTEX_CREATE (YES);
+  httpSession->lock = GNUNET_mutex_create (GNUNET_YES);
   httpSession->users = 1;       /* us only, core has not seen this tsession! */
-  httpSession->is_client = YES;
+  httpSession->is_client = GNUNET_YES;
   httpSession->cs.client.address = *haddr;
-  tsession = MALLOC (sizeof (TSession));
+  tsession = GNUNET_malloc (sizeof (TSession));
   memset (tsession, 0, sizeof (TSession));
   httpSession->tsession = tsession;
   tsession->ttype = HTTP_PROTOCOL_NUMBER;
@@ -1464,12 +1476,12 @@
   tsession->peer = hello->senderIdentity;
   create_session_url (httpSession);
 #if DO_GET
-  if (OK != create_curl_get (httpSession))
+  if (GNUNET_OK != create_curl_get (httpSession))
     {
-      FREE (tsession);
-      FREE (httpSession);
-      EXIT();
-      return SYSERR;
+      GNUNET_free (tsession);
+      GNUNET_free (httpSession);
+      EXIT ();
+      return GNUNET_SYSERR;
     }
 #endif
   /* PUTs will be created as needed */
@@ -1481,8 +1493,8 @@
           "HTTP/CURL initiated connection to `%s'.\n",
           httpSession->cs.client.url);
 #endif
-  EXIT();
-  return OK;
+  EXIT ();
+  return GNUNET_OK;
 }
 
 /**
@@ -1495,12 +1507,12 @@
 {
   struct HTTPPutData *put = put_cls;
   /* this condition should pretty much always be
-     true; just checking here in case the PUT 
+     true; just checking here in case the PUT
      response comes early somehow */
-  ENTER();
+  ENTER ();
   if (put->pos == put->size)
-    put->done = YES;
-  EXIT();
+    put->done = GNUNET_YES;
+  EXIT ();
   return size * nmemb;
 }
 
@@ -1515,15 +1527,15 @@
   CURLMcode mret;
   long size;
 
-  ENTER();
+  ENTER ();
   /* we should have initiated a GET earlier,
      so URL must not be NULL here */
   GE_ASSERT (NULL, httpSession->cs.client.url != NULL);
-  STEP();
+  STEP ();
   curl_put = curl_easy_init ();
-  STEP();
+  STEP ();
   if (curl_put == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   CURL_EASY_SETOPT (curl_put, CURLOPT_FAILONERROR, 1);
   CURL_EASY_SETOPT (curl_put, CURLOPT_URL, httpSession->cs.client.url);
   if (strlen (proxy) > 0)
@@ -1547,14 +1559,14 @@
   if (ret != CURLE_OK)
     {
       curl_easy_cleanup (curl_put);
-      EXIT();
-      return SYSERR;
+      EXIT ();
+      return GNUNET_SYSERR;
     }
-  STEP();
-  MUTEX_LOCK (curllock);
+  STEP ();
+  GNUNET_mutex_lock (curllock);
   mret = curl_multi_add_handle (curl_multi, curl_put);
-  MUTEX_UNLOCK (curllock);
-  STEP();
+  GNUNET_mutex_unlock (curllock);
+  STEP ();
   if (mret != CURLM_OK)
     {
       GE_LOG (coreAPI->ectx,
@@ -1562,9 +1574,9 @@
               _("%s failed at %s:%d: `%s'\n"),
               "curl_multi_add_handle",
               __FILE__, __LINE__, curl_multi_strerror (mret));
-      MUTEX_UNLOCK (httplock);
-      EXIT();
-      return SYSERR;
+      GNUNET_mutex_unlock (httplock);
+      EXIT ();
+      return GNUNET_SYSERR;
     }
   signal_select ();
   put->curl_put = curl_put;
@@ -1574,8 +1586,8 @@
           "HTTP/CURL initiated PUT request to `%s'.\n",
           httpSession->cs.client.url);
 #endif
-  EXIT();
-  return OK;
+  EXIT ();
+  return GNUNET_OK;
 }
 
 
@@ -1587,10 +1599,10 @@
  * even bother to construct (and encrypt) this kind
  * of message.
  *
- * @return YES if the transport would try (i.e. queue
+ * @return GNUNET_YES if the transport would try (i.e. queue
  *         the message or call the OS to send),
- *         NO if the transport would just drop the message,
- *         SYSERR if the size/session is invalid
+ *         GNUNET_NO if the transport would just drop the message,
+ *         GNUNET_SYSERR if the size/session is invalid
  */
 static int
 httpTestWouldTry (TSession * tsession, const unsigned int size, int important)
@@ -1599,56 +1611,57 @@
   struct MHDGetData *get;
   int ret;
 
-  ENTER();
-  if (size >= MAX_BUFFER_SIZE - sizeof (MESSAGE_HEADER))
+  ENTER ();
+  if (size >= GNUNET_MAX_BUFFER_SIZE - sizeof (GNUNET_MessageHeader))
     {
       GE_BREAK (coreAPI->ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (size == 0)
     {
       GE_BREAK (coreAPI->ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (httpSession->is_client)
     {
       /* client */
-      EXIT();
-      if ((important != YES) && (httpSession->cs.client.puts != NULL))
-        return NO;
-      return YES;
+      EXIT ();
+      if ((important != GNUNET_YES) && (httpSession->cs.client.puts != NULL))
+        return GNUNET_NO;
+      return GNUNET_YES;
     }
   else
     {
       /* server */
-      MUTEX_LOCK (httpSession->lock);
+      GNUNET_mutex_lock (httpSession->lock);
       get = httpSession->cs.server.gets;
       if (get == NULL)
-        ret = NO;
+        ret = GNUNET_NO;
       else
         {
           if (get->wsize == 0)
-            ret = YES;
-          else if ((get->wpos + size > get->wsize) && (important != YES))
-            ret = NO;
+            ret = GNUNET_YES;
+          else if ((get->wpos + size > get->wsize)
+                   && (important != GNUNET_YES))
+            ret = GNUNET_NO;
           else
-            ret = YES;
+            ret = GNUNET_YES;
         }
-      MUTEX_UNLOCK (httpSession->lock);
-      EXIT();
+      GNUNET_mutex_unlock (httpSession->lock);
+      EXIT ();
       return ret;
     }
-  EXIT();
+  EXIT ();
 }
 
 
 /**
  * Send a message to the specified remote node.
  *
- * @param tsession the P2P_hello_MESSAGE identifying the remote node
+ * @param tsession the GNUNET_MessageHello identifying the remote node
  * @param msg the message
  * @param size the size of the message
- * @return SYSERR on error, OK on success, NO if queue is full
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success, GNUNET_NO if queue is 
full
  */
 static int
 httpSend (TSession * tsession,
@@ -1656,62 +1669,62 @@
 {
   HTTPSession *httpSession = tsession->internal;
   struct HTTPPutData *putData;
-  MESSAGE_HEADER *hdr;
+  GNUNET_MessageHeader *hdr;
 #if DO_GET
   struct MHDGetData *getData;
   char *tmp;
 #endif
 
-  ENTER();
+  ENTER ();
   if (httpSession->is_client)
     {
       /* we need to do a PUT (we are the client) */
-      if (size >= MAX_BUFFER_SIZE)
-        return SYSERR;
+      if (size >= GNUNET_MAX_BUFFER_SIZE)
+        return GNUNET_SYSERR;
       if (size == 0)
         {
           GE_BREAK (NULL, 0);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
-      if (important != YES)
+      if (important != GNUNET_YES)
         {
-          MUTEX_LOCK (httpSession->lock);
+          GNUNET_mutex_lock (httpSession->lock);
           if (httpSession->cs.client.puts != NULL)
             {
               /* do not queue more than one unimportant PUT at a time */
-              if (httpSession->cs.client.puts->done == YES)
+              if (httpSession->cs.client.puts->done == GNUNET_YES)
                 signal_select ();       /* do clean up now! */
-              MUTEX_UNLOCK (httpSession->lock);
+              GNUNET_mutex_unlock (httpSession->lock);
               if (stats != NULL)
                 stats->change (stat_bytesDropped, size);
 
-             EXIT();
-              return NO;
+              EXIT ();
+              return GNUNET_NO;
             }
-          MUTEX_UNLOCK (httpSession->lock);
+          GNUNET_mutex_unlock (httpSession->lock);
         }
-      putData = MALLOC (sizeof (struct HTTPPutData));
+      putData = GNUNET_malloc (sizeof (struct HTTPPutData));
       memset (putData, 0, sizeof (struct HTTPPutData));
-      putData->msg = MALLOC (size + sizeof (MESSAGE_HEADER));
-      hdr = (MESSAGE_HEADER *) putData->msg;
-      hdr->size = htons (size + sizeof (MESSAGE_HEADER));
+      putData->msg = GNUNET_malloc (size + sizeof (GNUNET_MessageHeader));
+      hdr = (GNUNET_MessageHeader *) putData->msg;
+      hdr->size = htons (size + sizeof (GNUNET_MessageHeader));
       hdr->type = htons (0);
-      memcpy (&putData->msg[sizeof (MESSAGE_HEADER)], msg, size);
-      putData->size = size + sizeof (MESSAGE_HEADER);
-      putData->last_activity = get_time ();
-      if (OK != create_curl_put (httpSession, putData))
+      memcpy (&putData->msg[sizeof (GNUNET_MessageHeader)], msg, size);
+      putData->size = size + sizeof (GNUNET_MessageHeader);
+      putData->last_activity = GNUNET_get_time ();
+      if (GNUNET_OK != create_curl_put (httpSession, putData))
         {
-          FREE (putData->msg);
-          FREE (putData);
-         EXIT();  
-          return SYSERR;
+          GNUNET_free (putData->msg);
+          GNUNET_free (putData);
+          EXIT ();
+          return GNUNET_SYSERR;
         }
-      MUTEX_LOCK (httpSession->lock);
+      GNUNET_mutex_lock (httpSession->lock);
       putData->next = httpSession->cs.client.puts;
       httpSession->cs.client.puts = putData;
-      MUTEX_UNLOCK (httpSession->lock);
-      EXIT();
-      return OK;
+      GNUNET_mutex_unlock (httpSession->lock);
+      EXIT ();
+      return GNUNET_OK;
     }
 
   /* httpSession->isClient == false, respond to a GET (we
@@ -1723,35 +1736,35 @@
           size);
 #endif
 #if DO_GET
-  MUTEX_LOCK (httpSession->lock);
+  GNUNET_mutex_lock (httpSession->lock);
   getData = httpSession->cs.server.gets;
   if (getData == NULL)
     {
-      MUTEX_UNLOCK (httpSession->lock);
-      EXIT();
-      return SYSERR;
+      GNUNET_mutex_unlock (httpSession->lock);
+      EXIT ();
+      return GNUNET_SYSERR;
     }
-  MUTEX_LOCK (getData->lock);
+  GNUNET_mutex_lock (getData->lock);
   if (getData->wsize == 0)
-    GROW (getData->wbuff, getData->wsize, HTTP_BUF_SIZE);
-  size += sizeof (MESSAGE_HEADER);
+    GNUNET_array_grow (getData->wbuff, getData->wsize, HTTP_BUF_SIZE);
+  size += sizeof (GNUNET_MessageHeader);
   if (getData->wpos + size > getData->wsize)
     {
       /* need to grow or discard */
       if (!important)
         {
-          MUTEX_UNLOCK (getData->lock);
-          MUTEX_UNLOCK (httpSession->lock);
-         EXIT();
-          return NO;
+          GNUNET_mutex_unlock (getData->lock);
+          GNUNET_mutex_unlock (httpSession->lock);
+          EXIT ();
+          return GNUNET_NO;
         }
-      tmp = MALLOC (getData->wpos + size);
+      tmp = GNUNET_malloc (getData->wpos + size);
       memcpy (tmp, &getData->wbuff[getData->woff], getData->wpos);
-      hdr = (MESSAGE_HEADER *) & tmp[getData->wpos];
+      hdr = (GNUNET_MessageHeader *) & tmp[getData->wpos];
       hdr->type = htons (0);
       hdr->size = htons (size);
-      memcpy (&hdr[1], msg, size - sizeof (MESSAGE_HEADER));
-      FREE (getData->wbuff);
+      memcpy (&hdr[1], msg, size - sizeof (GNUNET_MessageHeader));
+      GNUNET_free (getData->wbuff);
       getData->wbuff = tmp;
       getData->wsize = getData->wpos + size;
       getData->woff = 0;
@@ -1768,18 +1781,18 @@
           getData->woff = 0;
         }
       /* append */
-      hdr = (MESSAGE_HEADER *) & getData->
+      hdr = (GNUNET_MessageHeader *) & getData->
         wbuff[getData->woff + getData->wpos];
       hdr->size = htons (size);
       hdr->type = htons (0);
-      memcpy (&hdr[1], msg, size - sizeof (MESSAGE_HEADER));
+      memcpy (&hdr[1], msg, size - sizeof (GNUNET_MessageHeader));
       getData->wpos += size;
     }
-  MUTEX_UNLOCK (getData->lock);
-  MUTEX_UNLOCK (httpSession->lock);
+  GNUNET_mutex_unlock (getData->lock);
+  GNUNET_mutex_unlock (httpSession->lock);
 #endif
-  EXIT();
-  return OK;
+  EXIT ();
+  return GNUNET_OK;
 }
 
 /**
@@ -1802,15 +1815,15 @@
   struct MHDGetData *gpos;
   struct MHDGetData *gnext;
 #endif
-  cron_t now;
+  GNUNET_CronTime now;
 
-  ENTER();
-  MUTEX_LOCK (httplock);
-  now = get_time ();
+  ENTER ();
+  GNUNET_mutex_lock (httplock);
+  now = GNUNET_get_time ();
   for (i = 0; i < tsessionCount; i++)
     {
       s = tsessions[i]->internal;
-      MUTEX_LOCK (s->lock);
+      GNUNET_mutex_lock (s->lock);
       if (s->is_client)
         {
           if ((s->cs.client.puts == NULL) && (s->users == 0)
@@ -1819,7 +1832,7 @@
 #endif
             )
             {
-              MUTEX_UNLOCK (s->lock);
+              GNUNET_mutex_unlock (s->lock);
 #if DO_GET
 #if DEBUG_HTTP
               GE_LOG (coreAPI->ectx,
@@ -1838,24 +1851,24 @@
           while (pos != NULL)
             {
               if (pos->last_activity + HTTP_TIMEOUT < now)
-                pos->done = YES;
+                pos->done = GNUNET_YES;
               if (pos->done)
                 {
                   if (prev == NULL)
                     s->cs.client.puts = pos->next;
                   else
                     prev->next = pos->next;
-                  FREE (pos->msg);
-                 STEP();
-                 MUTEX_LOCK (curllock);
-                  curl_multi_remove_handle (curl_multi, pos->curl_put);        
-                 MUTEX_UNLOCK (curllock);
-                 STEP();
+                  GNUNET_free (pos->msg);
+                  STEP ();
+                  GNUNET_mutex_lock (curllock);
+                  curl_multi_remove_handle (curl_multi, pos->curl_put);
+                  GNUNET_mutex_unlock (curllock);
+                  STEP ();
                   signal_select ();
-                 STEP();
-                 curl_easy_cleanup (pos->curl_put);
-                 STEP();
-                  FREE (pos);
+                  STEP ();
+                  curl_easy_cleanup (pos->curl_put);
+                  STEP ();
+                  GNUNET_free (pos);
                   if (prev == NULL)
                     pos = s->cs.client.puts;
                   else
@@ -1877,15 +1890,15 @@
           mprev = NULL;
           while (mpos != NULL)
             {
-              if ((mpos->done == YES) ||
+              if ((mpos->done == GNUNET_YES) ||
                   (mpos->last_activity + HTTP_TIMEOUT < now))
                 {
                   if (mprev == NULL)
                     s->cs.server.puts = mpos->next;
                   else
                     mprev->next = mpos->next;
-                  GROW (mpos->rbuff2, mpos->rsize2, 0);
-                  FREE (mpos);
+                  GNUNET_array_grow (mpos->rbuff2, mpos->rsize2, 0);
+                  GNUNET_free (mpos);
                   if (mprev == NULL)
                     mpos = s->cs.server.puts;
                   else
@@ -1910,9 +1923,9 @@
                     s->cs.server.gets = NULL;
                   r = gpos->get;
                   gpos->get = NULL;
-                 STEP();
+                  STEP ();
                   MHD_destroy_response (r);
-                 STEP();
+                  STEP ();
                 }
               gpos = gnext;
             }
@@ -1923,7 +1936,7 @@
 #endif
                (s->is_mhd_active == 0) && (s->users == 0))
             {
-              MUTEX_UNLOCK (s->lock);
+              GNUNET_mutex_unlock (s->lock);
 #if DO_GET
 #if DEBUG_HTTP
               GE_LOG (coreAPI->ectx,
@@ -1936,10 +1949,10 @@
               continue;
             }
         }
-      MUTEX_UNLOCK (s->lock);
+      GNUNET_mutex_unlock (s->lock);
     }
-  MUTEX_UNLOCK (httplock);
-  EXIT();
+  GNUNET_mutex_unlock (httplock);
+  EXIT ();
 }
 
 /**
@@ -1960,23 +1973,23 @@
   int have_tv;
   char buf[128];                /* for reading from pipe */
 
-  ENTER();
+  ENTER ();
 #if DEBUG_HTTP
   GE_LOG (coreAPI->ectx,
           GE_DEBUG | GE_REQUEST | GE_USER,
           "HTTP transport select thread started\n");
 #endif
-  while (YES == http_running)
+  while (GNUNET_YES == http_running)
     {
       max = 0;
       FD_ZERO (&rs);
       FD_ZERO (&ws);
       FD_ZERO (&es);
-      STEP();
-      MUTEX_LOCK (curllock);
+      STEP ();
+      GNUNET_mutex_lock (curllock);
       mret = curl_multi_fdset (curl_multi, &rs, &ws, &es, &max);
-      MUTEX_UNLOCK (curllock);
-      STEP();
+      GNUNET_mutex_unlock (curllock);
+      STEP ();
       if (mret != CURLM_OK)
         {
           GE_LOG (coreAPI->ectx,
@@ -1986,44 +1999,45 @@
                   __FILE__, __LINE__, curl_multi_strerror (mret));
           break;
         }
-      STEP();
+      STEP ();
       if (mhd_daemon != NULL)
         MHD_get_fdset (mhd_daemon, &rs, &ws, &es, &max);
-      STEP();
+      STEP ();
       timeout = 0;
       have_tv = MHD_NO;
       if (mhd_daemon != NULL)
         have_tv = MHD_get_timeout (mhd_daemon, &timeout);
-      STEP();
-      MUTEX_LOCK (curllock);
+      STEP ();
+      GNUNET_mutex_lock (curllock);
       if ((CURLM_OK == curl_multi_timeout (curl_multi, &ms)) &&
           (ms != -1) && ((ms < timeout) || (have_tv == MHD_NO)))
         {
           timeout = ms;
           have_tv = MHD_YES;
-        } 
-      MUTEX_UNLOCK (curllock);
-      STEP();
+        }
+      GNUNET_mutex_unlock (curllock);
+      STEP ();
       FD_SET (signal_pipe[0], &rs);
       if (max < signal_pipe[0])
         max = signal_pipe[0];
       tv.tv_sec = timeout / 1000;
       tv.tv_usec = (timeout % 1000) * 1000;
-      STEP();
+      STEP ();
       SELECT (max + 1, &rs, &ws, &es, (have_tv == MHD_YES) ? &tv : NULL);
-      STEP();
-      if (YES != http_running)
+      STEP ();
+      if (GNUNET_YES != http_running)
         break;
       running = 0;
       do
         {
-         STEP();
-         MUTEX_LOCK (curllock);
+          STEP ();
+          GNUNET_mutex_lock (curllock);
           mret = curl_multi_perform (curl_multi, &running);
-         MUTEX_UNLOCK (curllock);
-         STEP();
+          GNUNET_mutex_unlock (curllock);
+          STEP ();
         }
-      while ((mret == CURLM_CALL_MULTI_PERFORM) && (http_running == YES));
+      while ((mret == CURLM_CALL_MULTI_PERFORM)
+             && (http_running == GNUNET_YES));
       if (FD_ISSET (signal_pipe[0], &rs))
         read (signal_pipe[0], buf, 1);
       if ((mret != CURLM_OK) && (mret != CURLM_CALL_MULTI_PERFORM))
@@ -2032,10 +2046,10 @@
                 _("%s failed at %s:%d: `%s'\n"),
                 "curl_multi_perform",
                 __FILE__, __LINE__, curl_multi_strerror (mret));
-      STEP();
+      STEP ();
       if (mhd_daemon != NULL)
         MHD_run (mhd_daemon);
-      STEP();
+      STEP ();
       cleanup_connections ();
     }
 #if DEBUG_HTTP
@@ -2043,32 +2057,32 @@
           GE_DEBUG | GE_REQUEST | GE_USER,
           "HTTP transport select thread exits.\n");
 #endif
-  EXIT();
+  EXIT ();
   return NULL;
 }
 
 
 /**
  * Start the server process to receive inbound traffic.
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
 startTransportServer ()
 {
   unsigned short port;
 
-  ENTER();
-  if ((curl_multi != NULL) || (http_running == YES))
-    return SYSERR;
-  STEP();
+  ENTER ();
+  if ((curl_multi != NULL) || (http_running == GNUNET_YES))
+    return GNUNET_SYSERR;
+  STEP ();
   curl_multi = curl_multi_init ();
-  STEP();
+  STEP ();
   if (curl_multi == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   port = getGNUnetHTTPPort ();
   if ((mhd_daemon == NULL) && (port != 0))
     {
-      STEP();
+      STEP ();
       mhd_daemon = MHD_start_daemon (MHD_NO_FLAG,
                                      port,
                                      &acceptPolicyCallback,
@@ -2082,27 +2096,27 @@
                                      MHD_OPTION_NOTIFY_COMPLETED,
                                      &requestCompletedCallback, NULL,
                                      MHD_OPTION_END);
-      STEP();
+      STEP ();
     }
   if (0 != PIPE (signal_pipe))
     {
-      STEP();
+      STEP ();
       MHD_stop_daemon (mhd_daemon);
-      STEP();
+      STEP ();
       curl_multi_cleanup (curl_multi);
-      STEP();
+      STEP ();
       curl_multi = NULL;
       mhd_daemon = NULL;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  network_make_pipe_nonblocking (coreAPI->ectx, signal_pipe[0]);
-  http_running = YES;
-  curl_thread = PTHREAD_CREATE (&curl_runner, NULL, 32 * 1024);
+  GNUNET_pipe_make_nonblocking (coreAPI->ectx, signal_pipe[0]);
+  http_running = GNUNET_YES;
+  curl_thread = GNUNET_thread_create (&curl_runner, NULL, 32 * 1024);
   if (curl_thread == NULL)
     GE_DIE_STRERROR (coreAPI->ectx,
                      GE_FATAL | GE_ADMIN | GE_IMMEDIATE, "pthread_create");
-  EXIT();
-  return OK;
+  EXIT ();
+  return GNUNET_OK;
 }
 
 /**
@@ -2116,20 +2130,20 @@
   int i;
   HTTPSession *s;
 
-  ENTER();
-  if ((http_running == NO) || (curl_multi == NULL))
-    return SYSERR;
-  http_running = NO;
+  ENTER ();
+  if ((http_running == GNUNET_NO) || (curl_multi == NULL))
+    return GNUNET_SYSERR;
+  http_running = GNUNET_NO;
   signal_select ();
-  PTHREAD_STOP_SLEEP (curl_thread);
-  PTHREAD_JOIN (curl_thread, &unused);
+  GNUNET_thread_stop_sleep (curl_thread);
+  GNUNET_thread_join (curl_thread, &unused);
   CLOSE (signal_pipe[0]);
   CLOSE (signal_pipe[1]);
   if (mhd_daemon != NULL)
     {
-      STEP();
+      STEP ();
       MHD_stop_daemon (mhd_daemon);
-      STEP();
+      STEP ();
       mhd_daemon = NULL;
     }
   for (i = 0; i < tsessionCount; i++)
@@ -2141,12 +2155,12 @@
           i--;
         }
     }
-  STEP();
+  STEP ();
   curl_multi_cleanup (curl_multi);
-  STEP();
+  STEP ();
   curl_multi = NULL;
-  EXIT();
-  return OK;
+  EXIT ();
+  return GNUNET_OK;
 }
 
 /**
@@ -2161,17 +2175,17 @@
 {
   char *ch;
 
-  ENTER();
+  ENTER ();
   if (0 != strcmp (section, "HTTP"))
     return 0;                   /* fast path */
-  MUTEX_LOCK (httplock);
-  FREENONNULL (filteredNetworks_);
+  GNUNET_mutex_lock (httplock);
+  GNUNET_free_non_null (filteredNetworks_);
   ch = NULL;
   GC_get_configuration_value_string (cfg, "HTTP", "BLACKLIST", "", &ch);
-  filteredNetworks_ = parse_ipv4_network_specification (ectx, ch);
-  FREE (ch);
-  MUTEX_UNLOCK (httplock);
-  EXIT();
+  filteredNetworks_ = GNUNET_parse_ipv4_network_specification (ectx, ch);
+  GNUNET_free (ch);
+  GNUNET_mutex_unlock (httplock);
+  EXIT ();
   return 0;
 }
 
@@ -2179,22 +2193,22 @@
  * Convert HTTP hello to IP address
  */
 static int
-helloToAddress (const P2P_hello_MESSAGE * hello,
+helloToAddress (const GNUNET_MessageHello * hello,
                 void **sa, unsigned int *sa_len)
 {
   const HostAddress *haddr = (const HostAddress *) &hello[1];
   struct sockaddr_in *serverAddr;
 
-  ENTER();
+  ENTER ();
   *sa_len = sizeof (struct sockaddr_in);
-  serverAddr = MALLOC (sizeof (struct sockaddr_in));
+  serverAddr = GNUNET_malloc (sizeof (struct sockaddr_in));
   *sa = serverAddr;
   memset (serverAddr, 0, sizeof (struct sockaddr_in));
   serverAddr->sin_family = AF_INET;
-  memcpy (&serverAddr->sin_addr, haddr, sizeof (IPaddr));
+  memcpy (&serverAddr->sin_addr, haddr, sizeof (GNUNET_IPv4Address));
   serverAddr->sin_port = haddr->port;
-  EXIT();
-  return OK;
+  EXIT ();
+  return GNUNET_OK;
 }
 
 
@@ -2209,28 +2223,29 @@
 {
   static TransportAPI httpAPI;
 
-  ENTER();
+  ENTER ();
   coreAPI = core;
-  httplock = MUTEX_CREATE (YES);
-  curllock = MUTEX_CREATE (YES);
+  httplock = GNUNET_mutex_create (GNUNET_YES);
+  curllock = GNUNET_mutex_create (GNUNET_YES);
   if (0 != GC_attach_change_listener (coreAPI->cfg,
                                       &reloadConfiguration, NULL))
     {
-      MUTEX_DESTROY (httplock);
+      GNUNET_mutex_destroy (httplock);
       return NULL;
     }
   if (0 != curl_global_init (CURL_GLOBAL_WIN32))
     {
       GE_BREAK (NULL, 0);
       GC_detach_change_listener (coreAPI->cfg, &reloadConfiguration, NULL);
-      MUTEX_DESTROY (httplock);
+      GNUNET_mutex_destroy (httplock);
       return NULL;
     }
   tsessionCount = 0;
   tsessionArrayLength = 0;
-  GROW (tsessions, tsessionArrayLength, 32);
+  GNUNET_array_grow (tsessions, tsessionArrayLength, 32);
   if (GC_get_configuration_value_yesno (coreAPI->cfg,
-                                        "HTTP", "UPNP", YES) == YES)
+                                        "HTTP", "UPNP",
+                                        GNUNET_YES) == GNUNET_YES)
     {
       upnp = coreAPI->requestService ("upnp");
 
@@ -2269,7 +2284,7 @@
   httpAPI.stopTransportServer = &stopTransportServer;
   httpAPI.helloToAddress = &helloToAddress;
   httpAPI.testWouldTry = &httpTestWouldTry;
-  EXIT();
+  EXIT ();
 
   return &httpAPI;
 }
@@ -2277,7 +2292,7 @@
 void
 donetransport_http ()
 {
-  ENTER();
+  ENTER ();
   GC_detach_change_listener (coreAPI->cfg, &reloadConfiguration, NULL);
   if (stats != NULL)
     {
@@ -2289,14 +2304,14 @@
       coreAPI->releaseService (upnp);
       stats = NULL;
     }
-  FREENONNULL (filteredNetworks_);
-  MUTEX_DESTROY (httplock);
-  MUTEX_DESTROY (curllock);
+  GNUNET_free_non_null (filteredNetworks_);
+  GNUNET_mutex_destroy (httplock);
+  GNUNET_mutex_destroy (curllock);
   curl_global_cleanup ();
-  FREENONNULL (proxy);
+  GNUNET_free_non_null (proxy);
   proxy = NULL;
-  GROW (tsessions, tsessionArrayLength, 0);
-  EXIT();
+  GNUNET_array_grow (tsessions, tsessionArrayLength, 0);
+  EXIT ();
 }
 
 /* end of http.c */

Modified: GNUnet/src/transports/ip.c
===================================================================
--- GNUnet/src/transports/ip.c  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/ip.c  2007-11-23 11:51:54 UTC (rev 5742)
@@ -35,37 +35,37 @@
 
 /**
  * Get the IP address for the local machine.
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 int
 getPublicIPAddress (struct GC_Configuration *cfg,
-                    struct GE_Context *ectx, IPaddr * address)
+                    struct GE_Context *ectx, GNUNET_IPv4Address * address)
 {
-  static IPaddr myAddress;
-  static cron_t last;
-  static cron_t lastError;
-  cron_t now;
+  static GNUNET_IPv4Address myAddress;
+  static GNUNET_CronTime last;
+  static GNUNET_CronTime lastError;
+  GNUNET_CronTime now;
   char *ips;
 
-  now = get_time ();
-  if (last + cronMINUTES < now)
+  now = GNUNET_get_time ();
+  if (last + GNUNET_CRON_MINUTES < now)
     {
-      if (lastError + 30 * cronSECONDS > now)
-        return SYSERR;
-      ips = network_get_local_ip (cfg, ectx, &myAddress);
+      if (lastError + 30 * GNUNET_CRON_SECONDS > now)
+        return GNUNET_SYSERR;
+      ips = GNUNET_get_local_ip (cfg, ectx, &myAddress);
       if (ips == NULL)
         {
           GE_LOG (ectx,
                   GE_WARNING | GE_USER | GE_BULK,
                   _("Failed to obtain my (external) %s address!\n"), "IP");
           lastError = now;
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
-      FREE (ips);
+      GNUNET_free (ips);
       last = now;
     }
-  memcpy (address, &myAddress, sizeof (IPaddr));
-  return OK;
+  memcpy (address, &myAddress, sizeof (GNUNET_IPv4Address));
+  return GNUNET_OK;
 }
 
 struct PICache
@@ -73,13 +73,13 @@
   struct PICache *next;
   void *address;
   unsigned int len;
-  PeerIdentity peer;
-  cron_t expire;
+  GNUNET_PeerIdentity peer;
+  GNUNET_CronTime expire;
 };
 
 static struct PICache *pi_head;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 static void
 expirePICache ()
@@ -87,9 +87,9 @@
   struct PICache *pos;
   struct PICache *next;
   struct PICache *prev;
-  cron_t now;
+  GNUNET_CronTime now;
 
-  now = get_time ();
+  now = GNUNET_get_time ();
   pos = pi_head;
   prev = NULL;
   while (pos != NULL)
@@ -97,8 +97,8 @@
       next = pos->next;
       if (pos->expire < now)
         {
-          FREE (pos->address);
-          FREE (pos);
+          GNUNET_free (pos->address);
+          GNUNET_free (pos);
           if (prev == NULL)
             pi_head = next;
           else
@@ -112,37 +112,37 @@
 
 
 /**
- * We only have the PeerIdentity.  Do we have any
+ * We only have the GNUNET_PeerIdentity.  Do we have any
  * clue about the address based on
  * the "accept" of the connection?  Note that the
  * response is just the best guess.
  *
  * @param sa set to the address
- * @return OK if we found an address, SYSERR if not
+ * @return GNUNET_OK if we found an address, GNUNET_SYSERR if not
  */
 int
-getIPaddressFromPID (const PeerIdentity * peer,
+getIPaddressFromPID (const GNUNET_PeerIdentity * peer,
                      void **sa, unsigned int *salen)
 {
   struct PICache *cache;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   expirePICache ();
   cache = pi_head;
   while (cache != NULL)
     {
-      if (0 == memcmp (peer, &cache->peer, sizeof (PeerIdentity)))
+      if (0 == memcmp (peer, &cache->peer, sizeof (GNUNET_PeerIdentity)))
         {
           *salen = cache->len;
-          *sa = MALLOC (cache->len);
+          *sa = GNUNET_malloc (cache->len);
           memcpy (*sa, cache->address, cache->len);
-          MUTEX_UNLOCK (lock);
-          return OK;
+          GNUNET_mutex_unlock (lock);
+          return GNUNET_OK;
         }
       cache = cache->next;
     }
-  MUTEX_UNLOCK (lock);
-  return SYSERR;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -154,43 +154,43 @@
  * us to validate the address).
  */
 void
-setIPaddressFromPID (const PeerIdentity * peer,
+setIPaddressFromPID (const GNUNET_PeerIdentity * peer,
                      const void *sa, unsigned int salen)
 {
   struct PICache *next;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   next = pi_head;
   while (next != NULL)
     {
-      if (0 == memcmp (peer, &next->peer, sizeof (PeerIdentity)))
+      if (0 == memcmp (peer, &next->peer, sizeof (GNUNET_PeerIdentity)))
         {
-          next->expire = get_time () + 12 * cronHOURS;
+          next->expire = GNUNET_get_time () + 12 * GNUNET_CRON_HOURS;
           if ((salen == next->len) &&
               (0 == memcmp (sa, next->address, salen)))
             {
-              MUTEX_UNLOCK (lock);
+              GNUNET_mutex_unlock (lock);
               return;
             }
-          FREE (next->address);
-          next->address = MALLOC (salen);
+          GNUNET_free (next->address);
+          next->address = GNUNET_malloc (salen);
           next->len = salen;
           memcpy (next->address, sa, salen);
-          MUTEX_UNLOCK (lock);
+          GNUNET_mutex_unlock (lock);
           return;
         }
       next = next->next;
     }
-  next = MALLOC (sizeof (struct PICache));
+  next = GNUNET_malloc (sizeof (struct PICache));
   next->peer = *peer;
-  next->address = MALLOC (salen);
+  next->address = GNUNET_malloc (salen);
   memcpy (next->address, sa, salen);
   next->len = salen;
-  next->expire = get_time () + 12 * cronHOURS;
+  next->expire = GNUNET_get_time () + 12 * GNUNET_CRON_HOURS;
   expirePICache ();
   next->next = pi_head;
   pi_head = next;
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
 
 }
 
@@ -198,18 +198,18 @@
 
 void __attribute__ ((constructor)) gnunet_ip_ltdl_init ()
 {
-  lock = MUTEX_CREATE (YES);
+  lock = GNUNET_mutex_create (GNUNET_YES);
 }
 
 void __attribute__ ((destructor)) gnunet_ip_ltdl_fini ()
 {
   struct PICache *ppos;
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   while (pi_head != NULL)
     {
       ppos = pi_head->next;
-      FREE (pi_head->address);
-      FREE (pi_head);
+      GNUNET_free (pi_head->address);
+      GNUNET_free (pi_head);
       pi_head = ppos;
     }
 }

Modified: GNUnet/src/transports/ip.h
===================================================================
--- GNUnet/src/transports/ip.h  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/ip.h  2007-11-23 11:51:54 UTC (rev 5742)
@@ -43,21 +43,22 @@
  * (dynDNS? static IP? NAT?) and at the end what the user
  * needs.
  *
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 int getPublicIPAddress (struct GC_Configuration *cfg,
-                        struct GE_Context *ectx, IPaddr * address);
+                        struct GE_Context *ectx,
+                        GNUNET_IPv4Address * address);
 
 /**
- * We only have the PeerIdentity.  Do we have any
+ * We only have the GNUNET_PeerIdentity.  Do we have any
  * clue about the address based on
  * the "accept" of the connection?  Note that the
  * response is just the best guess.
  *
  * @param sa set to the address
- * @return OK if we found an address, SYSERR if not
+ * @return GNUNET_OK if we found an address, GNUNET_SYSERR if not
  */
-int getIPaddressFromPID (const PeerIdentity * peer,
+int getIPaddressFromPID (const GNUNET_PeerIdentity * peer,
                          void **sa, unsigned int *salen);
 
 /**
@@ -68,7 +69,7 @@
  * NOT validated (and it may well be impossible for
  * us to validate the address).
  */
-void setIPaddressFromPID (const PeerIdentity * peer,
+void setIPaddressFromPID (const GNUNET_PeerIdentity * peer,
                           const void *sa, unsigned int salen);
 
 #endif

Modified: GNUnet/src/transports/ip6.c
===================================================================
--- GNUnet/src/transports/ip6.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/ip6.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -48,10 +48,11 @@
 /**
  * Obtain the identity information for the current node
  * (connection information), conInfo.
- * @return SYSERR on failure, OK on success
+ * @return GNUNET_SYSERR on failure, GNUNET_OK on success
  */
 static int
-getAddress6FromHostname (struct GE_Context *ectx, IP6addr * identity)
+getAddress6FromHostname (struct GE_Context *ectx,
+                         GNUNET_IPv6Address * identity)
 {
   char hostname[MAX_HOSTNAME];
   struct hostent *ip;
@@ -61,7 +62,7 @@
       GE_LOG_STRERROR (ectx,
                        GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
                        "gethostname");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   /* GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
      " looking up $HOSTNAME (%s) to obtain local IP\n",
@@ -74,22 +75,23 @@
               GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
               _("Could not find IP of host `%s': %s\n"),
               hostname, hstrerror (h_errno));
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (ip->h_addrtype != AF_INET6)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   GE_ASSERT (ectx, sizeof (struct in6_addr) == sizeof (identity->addr));
   memcpy (&identity->addr[0], ip->h_addr_list[0], sizeof (struct in6_addr));
-  return OK;
+  return GNUNET_OK;
 }
 
-#if HAVE_GETIFADDRS && HAVE_FREEIFADDRS
+#if HAVE_GETIFADDRS && HAVE_GNUNET_freeIFADDRS
 static int
 getAddress6FromGetIfAddrs (struct GC_Configuration *cfg,
-                           struct GE_Context *ectx, IP6addr * identity)
+                           struct GE_Context *ectx,
+                           GNUNET_IPv6Address * identity)
 {
   char *interfaces;
   struct ifaddrs *ifa_first;
@@ -103,7 +105,7 @@
               GE_ERROR | GE_BULK | GE_USER,
               _("No interface specified in section `%s' under `%s'!\n"),
               "NETWORK", "INTERFACE");
-      return SYSERR;            /* that won't work! */
+      return GNUNET_SYSERR;     /* that won't work! */
     }
 
   if (getifaddrs (&ifa_first) == 0)
@@ -124,8 +126,8 @@
                       &(((struct sockaddr_in6 *) ifa_ptr->ifa_addr)->
                         sin6_addr), sizeof (struct in6_addr));
               freeifaddrs (ifa_first);
-              FREE (interfaces);
-              return OK;
+              GNUNET_free (interfaces);
+              return GNUNET_OK;
             }
         }
       freeifaddrs (ifa_first);
@@ -134,24 +136,24 @@
           GE_WARNING | GE_USER | GE_BULK,
           _("Could not obtain IP for interface `%s' using `%s'.\n"),
           interfaces, "getifaddrs");
-  FREE (interfaces);
-  return SYSERR;
+  GNUNET_free (interfaces);
+  return GNUNET_SYSERR;
 }
 #endif
 
 /**
  * Get the IP address for the local machine.
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 static int
 getAddress6 (struct GC_Configuration *cfg,
-             struct GE_Context *ectx, IP6addr * address)
+             struct GE_Context *ectx, GNUNET_IPv6Address * address)
 {
   char *ipString;
   int retval;
   struct hostent *ip;           /* for the lookup of the IP in gnunet.conf */
 
-  retval = SYSERR;
+  retval = GNUNET_SYSERR;
   if (GC_have_configuration_value (cfg, "NETWORK", "IP6"))
     {
       ipString = NULL;
@@ -170,7 +172,7 @@
           else if (ip->h_addrtype != AF_INET6)
             {
               GE_ASSERT (ectx, 0);
-              retval = SYSERR;
+              retval = GNUNET_SYSERR;
             }
           else
             {
@@ -178,51 +180,51 @@
                          sizeof (struct in6_addr) == sizeof (address->addr));
               memcpy (&address->addr[0],
                       ip->h_addr_list[0], sizeof (struct in6_addr));
-              retval = OK;
+              retval = GNUNET_OK;
             }
         }
-      FREE (ipString);
+      GNUNET_free (ipString);
     }
-#if HAVE_GETIFADDRS && HAVE_FREEIFADDRS
-  if (retval == SYSERR)
-    if (OK == getAddress6FromGetIfAddrs (cfg, ectx, address))
-      retval = OK;
+#if HAVE_GETIFADDRS && HAVE_GNUNET_freeIFADDRS
+  if (retval == GNUNET_SYSERR)
+    if (GNUNET_OK == getAddress6FromGetIfAddrs (cfg, ectx, address))
+      retval = GNUNET_OK;
 #endif
-  if (retval == SYSERR)
+  if (retval == GNUNET_SYSERR)
     retval = getAddress6FromHostname (ectx, address);
   return retval;
 }
 
 /**
  * Get the IPv6 address for the local machine.
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 int
 getPublicIP6Address (struct GC_Configuration *cfg,
-                     struct GE_Context *ectx, IP6addr * address)
+                     struct GE_Context *ectx, GNUNET_IPv6Address * address)
 {
-  static IP6addr myAddress;
-  static cron_t last;
-  static cron_t lastError;
-  cron_t now;
+  static GNUNET_IPv6Address myAddress;
+  static GNUNET_CronTime last;
+  static GNUNET_CronTime lastError;
+  GNUNET_CronTime now;
 
-  now = get_time ();
-  if (last + cronMINUTES < now)
+  now = GNUNET_get_time ();
+  if (last + GNUNET_CRON_MINUTES < now)
     {
-      if (lastError + 30 * cronSECONDS > now)
-        return SYSERR;
-      if (SYSERR == getAddress6 (cfg, ectx, &myAddress))
+      if (lastError + 30 * GNUNET_CRON_SECONDS > now)
+        return GNUNET_SYSERR;
+      if (GNUNET_SYSERR == getAddress6 (cfg, ectx, &myAddress))
         {
           lastError = now;
           GE_LOG (ectx,
                   GE_WARNING | GE_USER | GE_BULK,
                   _("Failed to obtain my (external) %s address!\n"), "IPv6");
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       last = now;
     }
-  memcpy (address, &myAddress, sizeof (IP6addr));
-  return OK;
+  memcpy (address, &myAddress, sizeof (GNUNET_IPv6Address));
+  return GNUNET_OK;
 }
 
 /* end of ip6.c */

Modified: GNUnet/src/transports/ip6.h
===================================================================
--- GNUnet/src/transports/ip6.h 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/ip6.h 2007-11-23 11:51:54 UTC (rev 5742)
@@ -31,9 +31,10 @@
 /**
  * @brief Get the IPv6 address for the local machine.
  *
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 int getPublicIP6Address (struct GC_Configuration *cfg,
-                         struct GE_Context *ectx, IP6addr * address);
+                         struct GE_Context *ectx,
+                         GNUNET_IPv6Address * address);
 
 #endif

Modified: GNUnet/src/transports/nat.c
===================================================================
--- GNUnet/src/transports/nat.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/nat.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -30,7 +30,7 @@
 #include "platform.h"
 #include "ip.h"
 
-#define DEBUG_NAT NO
+#define DEBUG_NAT GNUNET_NO
 
 /**
  * Host-Address in a NAT network.  Since the idea behind
@@ -57,45 +57,47 @@
  *
  * @param hello the hello message to verify
  *        (the signature/crc have been verified before)
- * @return OK on success, SYSERR on failure
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
 static int
-verifyHello (const P2P_hello_MESSAGE * hello)
+verifyHello (const GNUNET_MessageHello * hello)
 {
   if ((ntohs (hello->senderAddressSize) != sizeof (HostAddress)) ||
-      (ntohs (hello->header.size) != P2P_hello_MESSAGE_size (hello)) ||
+      (ntohs (hello->header.size) != GNUNET_sizeof_hello (hello)) ||
       (ntohs (hello->header.type) != p2p_PROTO_hello))
-    return SYSERR;              /* obviously invalid */
-  if (YES == GC_get_configuration_value_yesno (coreAPI->cfg,
-                                               "NAT", "LIMITED", NO))
+    return GNUNET_SYSERR;       /* obviously invalid */
+  if (GNUNET_YES == GC_get_configuration_value_yesno (coreAPI->cfg,
+                                                      "NAT", "LIMITED",
+                                                      GNUNET_NO))
     {
       /* if WE are a NAT and this is not our hello,
          it is invalid since NAT-to-NAT is not possible! */
       if (0 == memcmp (&coreAPI->myIdentity->hashPubKey,
                        &hello->senderIdentity.hashPubKey,
-                       sizeof (HashCode512)))
-        return OK;
-      return SYSERR;
+                       sizeof (GNUNET_HashCode)))
+        return GNUNET_OK;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Create a hello-Message for the current node. The hello is created
  * without signature and without a timestamp. The GNUnet core will
- * sign the message and add an expiration time.
+ * GNUNET_RSA_sign the message and add an expiration time.
  *
  * @return hello on success, NULL on error
  */
-static P2P_hello_MESSAGE *
+static GNUNET_MessageHello *
 createhello ()
 {
-  P2P_hello_MESSAGE *msg;
+  GNUNET_MessageHello *msg;
 
-  if (NO == GC_get_configuration_value_yesno (coreAPI->cfg,
-                                              "NAT", "LIMITED", NO))
+  if (GNUNET_NO == GC_get_configuration_value_yesno (coreAPI->cfg,
+                                                     "NAT", "LIMITED",
+                                                     GNUNET_NO))
     return NULL;
-  msg = MALLOC (sizeof (P2P_hello_MESSAGE) + sizeof (HostAddress));
+  msg = GNUNET_malloc (sizeof (GNUNET_MessageHello) + sizeof (HostAddress));
   msg->senderAddressSize = htons (sizeof (HostAddress));
   msg->protocol = htons (NAT_PROTOCOL_NUMBER);
   msg->MTU = htonl (0);
@@ -106,13 +108,13 @@
  * Establish a connection to a remote node.
  * @param hello the hello-Message for the target node
  * @param tsessionPtr the session handle that is to be set
- * @return always fails (returns SYSERR)
+ * @return always fails (returns GNUNET_SYSERR)
  */
 static int
-natConnect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr,
+natConnect (const GNUNET_MessageHello * hello, TSession ** tsessionPtr,
             int may_reuse)
 {
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -123,51 +125,51 @@
  * @param tsession the session handle passed along
  *   from the call to receive that was made by the transport
  *   layer
- * @return OK if the session could be associated,
- *         SYSERR if not.
+ * @return GNUNET_OK if the session could be associated,
+ *         GNUNET_SYSERR if not.
  */
 int
 natAssociate (TSession * tsession)
 {
-  return SYSERR;                /* NAT connections can never be associated */
+  return GNUNET_SYSERR;         /* NAT connections can never be associated */
 }
 
 /**
  * Send a message to the specified remote node.
  *
- * @param tsession the P2P_hello_MESSAGE identifying the remote node
+ * @param tsession the GNUNET_MessageHello identifying the remote node
  * @param message what to send
  * @param size the size of the message
- * @return SYSERR (always fails)
+ * @return GNUNET_SYSERR (always fails)
  */
 static int
 natSend (TSession * tsession,
          const void *message, const unsigned int size, int important)
 {
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /**
  * Disconnect from a remote node.
  *
  * @param tsession the session that is closed
- * @return always SYSERR
+ * @return always GNUNET_SYSERR
  */
 static int
 natDisconnect (TSession * tsession)
 {
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /**
  * Start the server process to receive inbound traffic.
  *
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
 startTransportServer ()
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -177,14 +179,14 @@
 static int
 stopTransportServer ()
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Convert NAT address to a string.
  */
 static int
-helloToAddress (const P2P_hello_MESSAGE * hello,
+helloToAddress (const GNUNET_MessageHello * hello,
                 void **sa, unsigned int *sa_len)
 {
   return getIPaddressFromPID (&hello->senderIdentity, sa, sa_len);
@@ -193,7 +195,7 @@
 static int
 testWouldTry (TSession * tsession, unsigned int size, int important)
 {
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /**

Modified: GNUnet/src/transports/smtp.c
===================================================================
--- GNUnet/src/transports/smtp.c        2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/smtp.c        2007-11-23 11:51:54 UTC (rev 5742)
@@ -31,7 +31,7 @@
 #include "platform.h"
 #include <libesmtp.h>
 
-#define DEBUG_SMTP NO
+#define DEBUG_SMTP GNUNET_NO
 
 #define FILTER_STRING_SIZE 64
 
@@ -83,9 +83,9 @@
   unsigned short size;
 
   /**
-   * What is the identity of the sender (hash of public key)
+   * What is the identity of the sender (GNUNET_hash of public key)
    */
-  PeerIdentity sender;
+  GNUNET_PeerIdentity sender;
 
 } SMTPMessage;
 
@@ -103,12 +103,12 @@
 /**
  * Thread that listens for inbound messages
  */
-static struct PTHREAD *dispatchThread;
+static struct GNUNET_ThreadHandle *dispatchThread;
 
 /**
  * Flag to indicate that server has been shut down.
  */
-static int smtp_shutdown = YES;
+static int smtp_shutdown = GNUNET_YES;
 
 
 /** ******************** Base64 encoding ***********/
@@ -139,8 +139,8 @@
     (*output)[ret++] = '\n'; \
   }
   ret = 0;
-  *output = MALLOC ((((len * 4 / 3) + 8) * (MAX_CHAR_PER_LINE + 2)) /
-                    MAX_CHAR_PER_LINE);
+  *output = GNUNET_malloc ((((len * 4 / 3) + 8) * (MAX_CHAR_PER_LINE + 2)) /
+                           MAX_CHAR_PER_LINE);
   for (i = 0; i < len; ++i)
     {
       c = (data[i] >> 2) & 0x3f;
@@ -209,7 +209,7 @@
                        if (i >= len) goto END;  \
                }
 
-  *output = MALLOC ((len * 3 / 4) + 8);
+  *output = GNUNET_malloc ((len * 3 / 4) + 8);
 #if DEBUG_SMTP
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           "base64_decode decoding len=%d\n", len);
@@ -275,18 +275,18 @@
   if (0 != mkfifo (pipename, S_IWUSR | S_IRUSR))
     GE_DIE_STRERROR (ectx, GE_ADMIN | GE_BULK | GE_FATAL, "mkfifo");
   LINESIZE = ((smtpAPI.mtu * 4 / 3) + 8) * (MAX_CHAR_PER_LINE + 2) / 
MAX_CHAR_PER_LINE; /* maximum size of a line supported */
-  line = MALLOC (LINESIZE + 2); /* 2 bytes for off-by-one errors, just to be 
safe... */
+  line = GNUNET_malloc (LINESIZE + 2);  /* 2 bytes for off-by-one errors, just 
to be safe... */
 
 #define READLINE(l,limit) \
   do { retl = fgets(l, limit, fdes); \
-    if ( (retl == NULL) || (smtp_shutdown == YES)) {\
+    if ( (retl == NULL) || (smtp_shutdown == GNUNET_YES)) {\
   goto END; \
     }\
     incrementBytesReceived(strlen(retl));\
   } while (0)
 
 
-  while (smtp_shutdown == NO)
+  while (smtp_shutdown == GNUNET_NO)
     {
       FILE *fdes;
       char *retl;
@@ -296,15 +296,15 @@
       P2P_PACKET *coreMP;
       int fd;
 
-      fd = disk_file_open (ectx, pipename, O_RDONLY);
+      fd = GNUNET_disk_file_open (ectx, pipename, O_RDONLY);
       if (fd == -1)
         {
-          if (smtp_shutdown == NO)
-            PTHREAD_SLEEP (5 * cronSECONDS);
+          if (smtp_shutdown == GNUNET_NO)
+            GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);
           continue;
         }
       fdes = fdopen (fd, "r");
-      while (smtp_shutdown == NO)
+      while (smtp_shutdown == GNUNET_NO)
         {
           do
             {
@@ -316,10 +316,10 @@
             {
               goto END;
             }
-          boundary = STRDUP (&line[strlen ("  boundary=\"") - 2]);
+          boundary = GNUNET_strdup (&line[strlen ("  boundary=\"") - 2]);
           if (boundary[strlen (boundary) - 2] != '\"')
             {
-              FREE (boundary);
+              GNUNET_free (boundary);
               goto END;         /* format error */
             }
           else
@@ -345,7 +345,7 @@
           if (size < sizeof (SMTPMessage))
             {
               GE_BREAK (ectx, 0);
-              FREE (out);
+              GNUNET_free (out);
               goto END;
             }
 
@@ -363,11 +363,11 @@
 #endif
               goto END;
             }
-          coreMP = MALLOC (sizeof (P2P_PACKET));
+          coreMP = GNUNET_malloc (sizeof (P2P_PACKET));
           coreMP->msg = out;
           coreMP->size = size - sizeof (SMTPMessage);
           coreMP->tsession = NULL;
-          memcpy (&coreMP->sender, &mp->sender, sizeof (PeerIdentity));
+          memcpy (&coreMP->sender, &mp->sender, sizeof (GNUNET_PeerIdentity));
 #if DEBUG_SMTP
           GE_LOG (ectx,
                   GE_DEBUG | GE_REQUEST | GE_USER,
@@ -386,7 +386,7 @@
         fclose (fdes);
     }
   UNLINK (pipename);
-  FREE (pipename);
+  GNUNET_free (pipename);
 
   return NULL;
 }
@@ -400,22 +400,22 @@
  *
  * @param helo the hello message to verify
  *        (the signature/crc have been verified before)
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
-verifyHelo (const P2P_hello_MESSAGE * helo)
+verifyHelo (const GNUNET_MessageHello * helo)
 {
   EmailAddress *maddr;
 
   maddr = (EmailAddress *) & helo[1];
   if ((ntohs (helo->header.size) !=
-       sizeof (P2P_hello_MESSAGE) + ntohs (helo->senderAddressSize)) ||
+       sizeof (GNUNET_MessageHello) + ntohs (helo->senderAddressSize)) ||
       (maddr->
        senderAddress[ntohs (helo->senderAddressSize) - 1 -
                      FILTER_STRING_SIZE] != '\0'))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;            /* obviously invalid */
+      return GNUNET_SYSERR;     /* obviously invalid */
     }
   else
     {
@@ -423,21 +423,21 @@
       GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
               "Verified SMTP helo from `%s'.\n", &maddr->senderAddress[0]);
 #endif
-      return OK;
+      return GNUNET_OK;
     }
 }
 
 /**
  * Create a hello-Message for the current node. The hello is created
  * without signature and without a timestamp. The GNUnet core will
- * sign the message and add an expiration time.
+ * GNUNET_RSA_sign the message and add an expiration time.
  *
  * @return hello on success, NULL on error
  */
-static P2P_hello_MESSAGE *
+static GNUNET_MessageHello *
 createhello ()
 {
-  P2P_hello_MESSAGE *msg;
+  GNUNET_MessageHello *msg;
   char *email;
   char *filter;
   EmailAddress *haddr;
@@ -461,7 +461,7 @@
       GE_LOG (ectx, GE_ERROR | GE_BULK | GE_USER,
               _
               ("No filter for E-mail specified, cannot create SMTP 
advertisement.\n"));
-      FREE (email);
+      GNUNET_free (email);
       return NULL;
     }
   if (strlen (filter) > FILTER_STRING_SIZE)
@@ -471,8 +471,9 @@
               _("SMTP filter string to long, capped to `%s'\n"), filter);
     }
   i = (strlen (email) + 8) & (~7);      /* make multiple of 8 */
-  msg = MALLOC (sizeof (P2P_hello_MESSAGE) + sizeof (EmailAddress) + i);
-  memset (msg, 0, sizeof (P2P_hello_MESSAGE) + sizeof (EmailAddress) + i);
+  msg =
+    GNUNET_malloc (sizeof (GNUNET_MessageHello) + sizeof (EmailAddress) + i);
+  memset (msg, 0, sizeof (GNUNET_MessageHello) + sizeof (EmailAddress) + i);
   haddr = (EmailAddress *) & msg[1];
   memset (&haddr->filter[0], 0, FILTER_STRING_SIZE);
   strcpy (&haddr->filter[0], filter);
@@ -480,9 +481,9 @@
   msg->senderAddressSize = htons (strlen (email) + 1 + sizeof (EmailAddress));
   msg->protocol = htons (SMTP_PROTOCOL_NUMBER);
   msg->MTU = htonl (smtpAPI.mtu);
-  msg->header.size = htons (P2P_hello_MESSAGE_size (msg));
-  FREE (email);
-  if (verifyHelo (msg) == SYSERR)
+  msg->header.size = htons (GNUNET_sizeof_hello (msg));
+  GNUNET_free (email);
+  if (verifyHelo (msg) == GNUNET_SYSERR)
     GE_ASSERT (ectx, 0);
   return msg;
 }
@@ -491,20 +492,20 @@
  * Establish a connection to a remote node.
  * @param helo the hello-Message for the target node
  * @param tsessionPtr the session handle that is to be set
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
-smtpConnect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr)
+smtpConnect (const GNUNET_MessageHello * hello, TSession ** tsessionPtr)
 {
   TSession *tsession;
 
-  tsession = MALLOC (sizeof (TSession));
-  tsession->internal = MALLOC (P2P_hello_MESSAGE_size (hello));
+  tsession = GNUNET_malloc (sizeof (TSession));
+  tsession->internal = GNUNET_malloc (GNUNET_sizeof_hello (hello));
   tsession->peer = hello->senderIdentity;
-  memcpy (tsession->internal, hello, P2P_hello_MESSAGE_size (hello));
+  memcpy (tsession->internal, hello, GNUNET_sizeof_hello (hello));
   tsession->ttype = smtpAPI.protocolNumber;
   (*tsessionPtr) = tsession;
-  return OK;
+  return GNUNET_OK;
 }
 
 #define MIN(a,b) (((a)<(b))?(a):(b))
@@ -517,22 +518,22 @@
  * @param tsession the session handle passed along
  *   from the call to receive that was made by the transport
  *   layer
- * @return OK if the session could be associated,
- *         SYSERR if not.
+ * @return GNUNET_OK if the session could be associated,
+ *         GNUNET_SYSERR if not.
  */
 int
 smtpAssociate (TSession * tsession)
 {
-  return SYSERR;                /* SMTP connections can never be associated */
+  return GNUNET_SYSERR;         /* SMTP connections can never be associated */
 }
 
 /**
  * Send a message to the specified remote node.
  *
- * @param tsession the P2P_hello_MESSAGE identifying the remote node
+ * @param tsession the GNUNET_MessageHello identifying the remote node
  * @param message what to send
  * @param size the size of the message
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 static int
 smtpSend (TSession * tsession,
@@ -540,7 +541,7 @@
 {
   char *msg;
   SMTPMessage *mp;
-  P2P_hello_MESSAGE *helo;
+  GNUNET_MessageHello *helo;
   EmailAddress *haddr;
   char *ebody;
   int res;
@@ -552,16 +553,16 @@
   char ebuf[EBUF_LEN];
   char *smtpServer;
 
-  if (smtp_shutdown == YES)
-    return SYSERR;
+  if (smtp_shutdown == GNUNET_YES)
+    return GNUNET_SYSERR;
   if ((size == 0) || (size > smtpAPI.mtu))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  helo = (P2P_hello_MESSAGE *) tsession->internal;
+  helo = (GNUNET_MessageHello *) tsession->internal;
   if (helo == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
 
   smtp_sock = smtp_create_session ();
   if (smtp_sock == NULL)
@@ -578,7 +579,7 @@
 
   haddr = (EmailAddress *) & helo[1];
   ssize2 = ssize = size + sizeof (SMTPMessage);
-  msg = MALLOC (ssize);
+  msg = GNUNET_malloc (ssize);
   mp = (SMTPMessage *) & msg[size];
   mp->size = htons (ssize);
   mp->sender = *coreAPI->myIdentity;
@@ -595,8 +596,8 @@
           GE_DEBUG | GE_REQUEST | GE_USER,
           "Base64-encoded message size is %d bytes.\n", ssize);
 #endif
-  FREE (msg);
-  res = SYSERR;
+  GNUNET_free (msg);
+  res = GNUNET_SYSERR;
 
   message = smtp_add_message (smtp_sock);
   if (message == NULL)
@@ -605,17 +606,17 @@
               GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
               "Failed to create smtp message: %s\n",
               smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   smtp_size_set_estimate (message, ssize);
   smtp_set_messagecb (message, &getMessage, &msg);
 
 #if 0
-  if (OK == writeSMTPLine (smtp_sock,
-                           "%-*s\r\n",
-                           MIN (FILTER_STRING_SIZE,
-                                strlen (&haddr->filter[0])),
-                           &haddr->filter[0]))
+  if (GNUNET_OK == writeSMTPLine (smtp_sock,
+                                  "%-*s\r\n",
+                                  MIN (FILTER_STRING_SIZE,
+                                       strlen (&haddr->filter[0])),
+                                  &haddr->filter[0]))
     {
     }
 #endif
@@ -624,12 +625,12 @@
     {
       /* FIXME */
     }
-  if (res != OK)
+  if (res != GNUNET_OK)
     GE_LOG (ectx,
             GE_WARNING | GE_BULK | GE_USER,
             _("Sending E-mail to `%s' failed.\n"), &haddr->senderAddress[0]);
   incrementBytesSent (ssize);
-  FREE (ebody);
+  GNUNET_free (ebody);
   smtp_destroy_session (smtp_sock);
 
 
@@ -640,7 +641,7 @@
  * Disconnect from a remote node.
  *
  * @param tsession the session that is closed
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
 smtpDisconnect (TSession * tsession)
@@ -648,25 +649,26 @@
   if (tsession != NULL)
     {
       if (tsession->internal != NULL)
-        FREE (tsession->internal);
-      FREE (tsession);
+        GNUNET_free (tsession->internal);
+      GNUNET_free (tsession);
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Start the server process to receive inbound traffic.
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
 startTransportServer (void)
 {
-  smtp_shutdown = NO;
+  smtp_shutdown = GNUNET_NO;
   /* initialize SMTP network */
-  dispatchThread = PTHREAD_CREATE (&listenAndDistribute, NULL, 1024 * 4);
+  dispatchThread =
+    GNUNET_thread_create (&listenAndDistribute, NULL, 1024 * 4);
   if (dispatchThread == NULL)
     GE_DIE_STRERROR (ectx, GE_ADMIN | GE_BULK | GE_FATAL, "pthread_create");
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -678,17 +680,17 @@
 {
   void *unused;
 
-  smtp_shutdown = YES;
-  PTHREAD_STOP_SLEEP (dispatchThread);
-  PTHREAD_JOIN (dispatchThread, &unused);
-  return OK;
+  smtp_shutdown = GNUNET_YES;
+  GNUNET_thread_stop_sleep (dispatchThread);
+  GNUNET_thread_join (dispatchThread, &unused);
+  return GNUNET_OK;
 }
 
 /**
  * Convert TCP address to a string.
  */
 static char *
-addressToString (const P2P_hello_MESSAGE * helo)
+addressToString (const GNUNET_MessageHello * helo)
 {
   char *ret;
   EmailAddress *addr;
@@ -696,11 +698,11 @@
 
   addr = (EmailAddress *) & helo[1];
   n = FILTER_STRING_SIZE + strlen (addr->senderAddress) + 16;
-  ret = MALLOC (n);
-  SNPRINTF (ret,
-            n,
-            _("%.*s filter %s (SMTP)"),
-            FILTER_STRING_SIZE, addr->filter, addr->senderAddress);
+  ret = GNUNET_malloc (n);
+  GNUNET_snprintf (ret,
+                   n,
+                   _("%.*s filter %s (SMTP)"),
+                   FILTER_STRING_SIZE, addr->filter, addr->senderAddress);
   return ret;
 }
 

Modified: GNUnet/src/transports/tcp.c
===================================================================
--- GNUnet/src/transports/tcp.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/tcp.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,7 +32,7 @@
 #include "platform.h"
 #include "ip.h"
 
-#define DEBUG_TCP NO
+#define DEBUG_TCP GNUNET_NO
 
 /**
  * after how much time of the core not being associated with a tcp
@@ -41,7 +41,7 @@
  * Needs to be larger than SECONDS_INACTIVE_DROP in
  * core's connection.s
  */
-#define TCP_TIMEOUT (600 * cronSECONDS)
+#define TCP_TIMEOUT (600 * GNUNET_CRON_SECONDS)
 
 /**
  * after how much time of the core not being associated with a tcp
@@ -50,7 +50,7 @@
  * Needs to be larger than SECONDS_INACTIVE_DROP in
  * core's connection.s
  */
-#define TCP_FAST_TIMEOUT (5 * cronSECONDS)
+#define TCP_FAST_TIMEOUT (5 * GNUNET_CRON_SECONDS)
 
 #define TARGET_BUFFER_SIZE 4092
 
@@ -64,7 +64,7 @@
   /**
    * claimed IP of the sender, network byte order
    */
-  IPaddr ip;
+  GNUNET_IPv4Address ip;
 
   /**
    * claimed port of the sender, network byte order
@@ -84,13 +84,13 @@
 
 static UPnP_ServiceAPI *upnp;
 
-static struct CIDRNetwork *filteredNetworks_;
+static struct GNUNET_IPv4NetworkSet *filteredNetworks_;
 
-static struct CIDRNetwork *allowedNetworks_;
+static struct GNUNET_IPv4NetworkSet *allowedNetworks_;
 
 static struct GC_Configuration *cfg;
 
-static struct MUTEX *tcpblacklistlock;
+static struct GNUNET_Mutex *tcpblacklistlock;
 
 /**
  * Check if we are allowed to connect to the given IP.
@@ -98,14 +98,15 @@
 static int
 isBlacklisted (const void *addr, unsigned int addr_len)
 {
-  IPaddr ip;
+  GNUNET_IPv4Address ip;
   int ret;
 
   if (addr_len == sizeof (struct sockaddr_in))
     {
-      memcpy (&ip, &((struct sockaddr_in *) addr)->sin_addr, sizeof (IPaddr));
+      memcpy (&ip, &((struct sockaddr_in *) addr)->sin_addr,
+              sizeof (GNUNET_IPv4Address));
     }
-  else if (addr_len == sizeof (IPaddr))
+  else if (addr_len == sizeof (GNUNET_IPv4Address))
     {
       memcpy (&ip, addr, addr_len);
     }
@@ -116,19 +117,19 @@
               GE_DEBUG | GE_ADMIN | GE_BULK,
               "Rejecting connection (invalid address length %u)\n", addr_len);
 #endif
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (ip.addr == 0)
-    return SYSERR;
-  MUTEX_LOCK (tcpblacklistlock);
-  ret = check_ipv4_listed (filteredNetworks_, ip);
-  MUTEX_UNLOCK (tcpblacklistlock);
+    return GNUNET_SYSERR;
+  GNUNET_mutex_lock (tcpblacklistlock);
+  ret = GNUNET_check_ipv4_listed (filteredNetworks_, ip);
+  GNUNET_mutex_unlock (tcpblacklistlock);
 #if DEBUG_TCP
-  if (ret != NO)
+  if (ret != GNUNET_NO)
     GE_LOG (ectx,
             GE_DEBUG | GE_ADMIN | GE_BULK,
             "Rejecting connection from address %u.%u.%u.%u (blacklisted)\n",
-            PRIP (ntohl (*(int *) addr)));
+            GNUNET_PRIP (ntohl (*(int *) addr)));
 #endif
   return ret;
 }
@@ -139,14 +140,15 @@
 static int
 isWhitelisted (const void *addr, unsigned int addr_len)
 {
-  IPaddr ip;
+  GNUNET_IPv4Address ip;
   int ret;
 
   if (addr_len == sizeof (struct sockaddr_in))
     {
-      memcpy (&ip, &((struct sockaddr_in *) addr)->sin_addr, sizeof (IPaddr));
+      memcpy (&ip, &((struct sockaddr_in *) addr)->sin_addr,
+              sizeof (GNUNET_IPv4Address));
     }
-  else if (addr_len == sizeof (IPaddr))
+  else if (addr_len == sizeof (GNUNET_IPv4Address))
     {
       memcpy (&ip, addr, addr_len);
     }
@@ -157,20 +159,20 @@
               GE_DEBUG | GE_ADMIN | GE_BULK,
               "Rejecting connection (invalid address length %u)\n", addr_len);
 #endif
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  ret = YES;
-  MUTEX_LOCK (tcpblacklistlock);
+  ret = GNUNET_YES;
+  GNUNET_mutex_lock (tcpblacklistlock);
   if (allowedNetworks_ != NULL)
-    ret = check_ipv4_listed (allowedNetworks_, ip);
-  MUTEX_UNLOCK (tcpblacklistlock);
-  if (ret != YES)
+    ret = GNUNET_check_ipv4_listed (allowedNetworks_, ip);
+  GNUNET_mutex_unlock (tcpblacklistlock);
+  if (ret != GNUNET_YES)
     {
 #if DEBUG_TCP
       GE_LOG (ectx,
               GE_DEBUG | GE_ADMIN | GE_BULK,
               "Rejecting HELLO from address %u.%u.%u.%u (not whitelisted)\n",
-              PRIP (ntohl (*(int *) addr)));
+              GNUNET_PRIP (ntohl (*(int *) addr)));
 #endif
     }
   return ret;
@@ -179,11 +181,11 @@
 static int
 isRejected (const void *addr, unsigned int addr_len)
 {
-  if ((NO != isBlacklisted (addr,
-                            addr_len)) ||
-      (YES != isWhitelisted (addr, addr_len)))
-    return YES;
-  return NO;
+  if ((GNUNET_NO != isBlacklisted (addr,
+                                   addr_len)) ||
+      (GNUNET_YES != isWhitelisted (addr, addr_len)))
+    return GNUNET_YES;
+  return GNUNET_NO;
 }
 
 /**
@@ -216,47 +218,47 @@
  * success.
  * @param hello the Hello message to verify
  *        (the signature/crc have been verified before)
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
-verifyHello (const P2P_hello_MESSAGE * hello)
+verifyHello (const GNUNET_MessageHello * hello)
 {
   HostAddress *haddr;
 
   haddr = (HostAddress *) & hello[1];
   if ((ntohs (hello->senderAddressSize) != sizeof (HostAddress)) ||
-      (ntohs (hello->header.size) != P2P_hello_MESSAGE_size (hello)) ||
+      (ntohs (hello->header.size) != GNUNET_sizeof_hello (hello)) ||
       (ntohs (hello->header.type) != p2p_PROTO_hello) ||
       (ntohs (hello->protocol) != TCP_PROTOCOL_NUMBER) ||
-      (YES == isBlacklisted (&haddr->ip,
-                             sizeof (IPaddr))) ||
-      (YES != isWhitelisted (&haddr->ip, sizeof (IPaddr))))
+      (GNUNET_YES == isBlacklisted (&haddr->ip,
+                                    sizeof (GNUNET_IPv4Address))) ||
+      (GNUNET_YES != isWhitelisted (&haddr->ip, sizeof (GNUNET_IPv4Address))))
     {
 #if DEBUG_TCP
-      EncName enc;
+      GNUNET_EncName enc;
 
-      hash2enc (&hello->senderIdentity.hashPubKey, &enc);
+      GNUNET_hash_to_enc (&hello->senderIdentity.hashPubKey, &enc);
       GE_LOG (ectx,
               GE_DEBUG | GE_ADMIN | GE_BULK,
               "Rejecting HELLO from `%s'\n", &enc);
 #endif
-      return SYSERR;            /* obviously invalid */
+      return GNUNET_SYSERR;     /* obviously invalid */
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Create a hello-Message for the current node. The hello is
  * created without signature and without a timestamp. The
- * GNUnet core will sign the message and add an expiration time.
+ * GNUnet core will GNUNET_RSA_sign the message and add an expiration time.
  *
  * @return hello on success, NULL on error
  */
-static P2P_hello_MESSAGE *
+static GNUNET_MessageHello *
 createhello ()
 {
   static HostAddress last_addr;
-  P2P_hello_MESSAGE *msg;
+  GNUNET_MessageHello *msg;
   HostAddress *haddr;
   unsigned short port;
 
@@ -275,16 +277,16 @@
         }
       return NULL;              /* TCP transport is configured SEND-only! */
     }
-  msg = MALLOC (sizeof (P2P_hello_MESSAGE) + sizeof (HostAddress));
+  msg = GNUNET_malloc (sizeof (GNUNET_MessageHello) + sizeof (HostAddress));
   haddr = (HostAddress *) & msg[1];
 
   if (!(((upnp != NULL) &&
-         (OK == upnp->get_ip (port,
-                              "TCP",
-                              &haddr->ip))) ||
-        (SYSERR != getPublicIPAddress (cfg, ectx, &haddr->ip))))
+         (GNUNET_OK == upnp->get_ip (port,
+                                     "TCP",
+                                     &haddr->ip))) ||
+        (GNUNET_SYSERR != getPublicIPAddress (cfg, ectx, &haddr->ip))))
     {
-      FREE (msg);
+      GNUNET_free (msg);
       GE_LOG (ectx,
               GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
               _("TCP: Could not determine my public IP address.\n"));
@@ -297,7 +299,7 @@
       GE_LOG (ectx,
               GE_DEBUG | GE_USER | GE_BULK,
               "TCP uses IP address %u.%u.%u.%u.\n",
-              PRIP (ntohl (*(int *) &haddr->ip)));
+              GNUNET_PRIP (ntohl (*(int *) &haddr->ip)));
       last_addr = *haddr;
     }
   msg->senderAddressSize = htons (sizeof (HostAddress));
@@ -311,58 +313,60 @@
  *
  * @param hello the hello-Message for the target node
  * @param tsessionPtr the session handle that is set
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
-tcpConnect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr,
+tcpConnect (const GNUNET_MessageHello * hello, TSession ** tsessionPtr,
             int may_reuse)
 {
   static int zero = 0;
   HostAddress *haddr;
   int sock;
   struct sockaddr_in soaddr;
-  struct SocketHandle *s;
+  struct GNUNET_SocketHandle *s;
   int i;
   TCPSession *session;
 
   if (selector == NULL)
-    return SYSERR;
-  if (may_reuse != NO)
+    return GNUNET_SYSERR;
+  if (may_reuse != GNUNET_NO)
     {
-      MUTEX_LOCK (tcplock);
+      GNUNET_mutex_lock (tcplock);
       session = sessions;
       while (session != NULL)
         {
           if (0 == memcmp (&session->sender,
-                           &hello->senderIdentity, sizeof (PeerIdentity)))
+                           &hello->senderIdentity,
+                           sizeof (GNUNET_PeerIdentity)))
             {
-              MUTEX_LOCK (session->lock);
+              GNUNET_mutex_lock (session->lock);
               if (session->in_select)
                 {
                   session->users++;
-                  MUTEX_UNLOCK (session->lock);
-                  MUTEX_UNLOCK (tcplock);
+                  GNUNET_mutex_unlock (session->lock);
+                  GNUNET_mutex_unlock (tcplock);
                   *tsessionPtr = session->tsession;
-                  return OK;
+                  return GNUNET_OK;
                 }
-              MUTEX_UNLOCK (session->lock);
+              GNUNET_mutex_unlock (session->lock);
             }
           session = session->next;
         }
-      MUTEX_UNLOCK (tcplock);
+      GNUNET_mutex_unlock (tcplock);
     }
   haddr = (HostAddress *) & hello[1];
 #if DEBUG_TCP
   GE_LOG (ectx,
           GE_DEBUG | GE_USER | GE_BULK,
           "Creating TCP connection to %u.%u.%u.%u:%u.\n",
-          PRIP (ntohl (*(int *) &haddr->ip.addr)), ntohs (haddr->port));
+          GNUNET_PRIP (ntohl (*(int *) &haddr->ip.addr)),
+          ntohs (haddr->port));
 #endif
   sock = SOCKET (PF_INET, SOCK_STREAM, 6);      /* 6: TCP */
   if (sock == -1)
     {
       GE_LOG_STRERROR (ectx, GE_ERROR | GE_ADMIN | GE_BULK, "socket");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   s = socket_create (ectx, coreAPI->load_monitor, sock);
 #if TCP_SYNCNT
@@ -370,16 +374,16 @@
      if that does not work, abort instantly */
   setsockopt (sock, IPPROTO_TCP, TCP_SYNCNT, &zero, sizeof (zero));
 #endif
-  if (-1 == socket_set_blocking (s, NO))
+  if (-1 == GNUNET_socket_set_blocking (s, GNUNET_NO))
     {
-      socket_destroy (s);
-      return SYSERR;
+      GNUNET_socket_destroy (s);
+      return GNUNET_SYSERR;
     }
   memset (&soaddr, 0, sizeof (soaddr));
   soaddr.sin_family = AF_INET;
 
-  GE_ASSERT (ectx, sizeof (struct in_addr) == sizeof (IPaddr));
-  memcpy (&soaddr.sin_addr, &haddr->ip, sizeof (IPaddr));
+  GE_ASSERT (ectx, sizeof (struct in_addr) == sizeof (GNUNET_IPv4Address));
+  memcpy (&soaddr.sin_addr, &haddr->ip, sizeof (GNUNET_IPv4Address));
   soaddr.sin_port = haddr->port;
   i = CONNECT (sock, (struct sockaddr *) &soaddr, sizeof (soaddr));
   if ((i < 0) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK))
@@ -387,23 +391,23 @@
       GE_LOG (ectx,
               GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
               _("Cannot connect to %u.%u.%u.%u:%u: %s\n"),
-              PRIP (ntohl (*(int *) &haddr->ip)),
+              GNUNET_PRIP (ntohl (*(int *) &haddr->ip)),
               ntohs (haddr->port), STRERROR (errno));
-      socket_destroy (s);
-      return SYSERR;
+      GNUNET_socket_destroy (s);
+      return GNUNET_SYSERR;
     }
 #if DEBUG_TCP
   GE_LOG (ectx,
           GE_DEBUG | GE_DEVELOPER | GE_USER | GE_BULK,
           "Establishing connection to %u.%u.%u.%u:%u\n",
-          PRIP (ntohl (*(int *) &haddr->ip)), ntohs (haddr->port));
+          GNUNET_PRIP (ntohl (*(int *) &haddr->ip)), ntohs (haddr->port));
 #endif
   return tcpConnectHelper (hello, s, tcpAPI.protocolNumber, tsessionPtr);
 }
 
 /**
  * Start the server process to receive inbound traffic.
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
 startTransportServer ()
@@ -416,7 +420,7 @@
   if (selector != NULL)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   port = getGNUnetTCPPort ();
   if (port != 0)
@@ -425,7 +429,7 @@
       if (s < 0)
         {
           GE_LOG_STRERROR (ectx, GE_ERROR | GE_ADMIN | GE_BULK, "socket");
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (SETSOCKOPT (s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0)
         GE_DIE_STRERROR (ectx,
@@ -445,28 +449,28 @@
             GE_LOG_STRERROR (ectx,
                              GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
                              "close");
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
     }
   else
     {
       s = -1;                   /* no listening! */
     }
-  selector = select_create ("tcp",
-                            NO,
-                            ectx,
-                            coreAPI->load_monitor,
-                            s,
-                            sizeof (struct sockaddr_in),
-                            TCP_FAST_TIMEOUT,
-                            &select_message_handler,
-                            NULL,
-                            &select_accept_handler,
-                            &isRejected,
-                            &select_close_handler,
-                            NULL, 128 * 1024 /* max memory */ ,
-                            128 /* max sockets */ );
-  return OK;
+  selector = GNUNET_select_create ("tcp",
+                                   GNUNET_NO,
+                                   ectx,
+                                   coreAPI->load_monitor,
+                                   s,
+                                   sizeof (struct sockaddr_in),
+                                   TCP_FAST_TIMEOUT,
+                                   &select_message_handler,
+                                   NULL,
+                                   &select_accept_handler,
+                                   &isRejected,
+                                   &select_close_handler,
+                                   NULL, 128 * 1024 /* max memory */ ,
+                                   128 /* max sockets */ );
+  return GNUNET_OK;
 }
 
 /**
@@ -484,21 +488,21 @@
   if (0 != strcmp (section, "TCP"))
     return 0;                   /* fast path */
 
-  MUTEX_LOCK (tcpblacklistlock);
-  FREENONNULL (filteredNetworks_);
-  FREENONNULL (allowedNetworks_);
+  GNUNET_mutex_lock (tcpblacklistlock);
+  GNUNET_free_non_null (filteredNetworks_);
+  GNUNET_free_non_null (allowedNetworks_);
   ch = NULL;
   GC_get_configuration_value_string (cfg, "TCP", "BLACKLIST", "", &ch);
-  filteredNetworks_ = parse_ipv4_network_specification (ectx, ch);
-  FREE (ch);
+  filteredNetworks_ = GNUNET_parse_ipv4_network_specification (ectx, ch);
+  GNUNET_free (ch);
   ch = NULL;
   GC_get_configuration_value_string (cfg, "TCP", "WHITELIST", "", &ch);
   if (strlen (ch) > 0)
-    allowedNetworks_ = parse_ipv4_network_specification (ectx, ch);
+    allowedNetworks_ = GNUNET_parse_ipv4_network_specification (ectx, ch);
   else
     allowedNetworks_ = NULL;
-  FREE (ch);
-  MUTEX_UNLOCK (tcpblacklistlock);
+  GNUNET_free (ch);
+  GNUNET_mutex_unlock (tcpblacklistlock);
   /* TODO: error handling! */
   return 0;
 }
@@ -507,20 +511,20 @@
  * Convert TCP hello to IP address
  */
 static int
-helloToAddress (const P2P_hello_MESSAGE * hello,
+helloToAddress (const GNUNET_MessageHello * hello,
                 void **sa, unsigned int *sa_len)
 {
   const HostAddress *haddr = (const HostAddress *) &hello[1];
   struct sockaddr_in *serverAddr;
 
   *sa_len = sizeof (struct sockaddr_in);
-  serverAddr = MALLOC (sizeof (struct sockaddr_in));
+  serverAddr = GNUNET_malloc (sizeof (struct sockaddr_in));
   *sa = serverAddr;
   memset (serverAddr, 0, sizeof (struct sockaddr_in));
   serverAddr->sin_family = AF_INET;
-  memcpy (&serverAddr->sin_addr, haddr, sizeof (IPaddr));
+  memcpy (&serverAddr->sin_addr, haddr, sizeof (GNUNET_IPv4Address));
   serverAddr->sin_port = haddr->port;
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -536,20 +540,21 @@
   ectx = core->ectx;
   cfg = core->cfg;
   GE_ASSERT (ectx, sizeof (HostAddress) == 8);
-  GE_ASSERT (ectx, sizeof (MESSAGE_HEADER) == 4);
+  GE_ASSERT (ectx, sizeof (GNUNET_MessageHeader) == 4);
   GE_ASSERT (ectx, sizeof (TCPWelcome) == 68);
-  tcplock = MUTEX_CREATE (YES);
-  tcpblacklistlock = MUTEX_CREATE (YES);
+  tcplock = GNUNET_mutex_create (GNUNET_YES);
+  tcpblacklistlock = GNUNET_mutex_create (GNUNET_YES);
   if (0 != GC_attach_change_listener (cfg, &reloadConfiguration, NULL))
     {
-      MUTEX_DESTROY (tcplock);
-      MUTEX_DESTROY (tcpblacklistlock);
+      GNUNET_mutex_destroy (tcplock);
+      GNUNET_mutex_destroy (tcpblacklistlock);
       tcplock = NULL;
       tcpblacklistlock = NULL;
       return NULL;
     }
   coreAPI = core;
-  if (GC_get_configuration_value_yesno (cfg, "TCP", "UPNP", YES) == YES)
+  if (GC_get_configuration_value_yesno (cfg, "TCP", "UPNP", GNUNET_YES) ==
+      GNUNET_YES)
     {
       upnp = coreAPI->requestService ("upnp");
 
@@ -603,10 +608,10 @@
       coreAPI->releaseService (upnp);
       upnp = NULL;
     }
-  FREENONNULL (filteredNetworks_);
-  FREENONNULL (allowedNetworks_);
-  MUTEX_DESTROY (tcplock);
-  MUTEX_DESTROY (tcpblacklistlock);
+  GNUNET_free_non_null (filteredNetworks_);
+  GNUNET_free_non_null (allowedNetworks_);
+  GNUNET_mutex_destroy (tcplock);
+  GNUNET_mutex_destroy (tcpblacklistlock);
 }
 
 /* end of tcp.c */

Modified: GNUnet/src/transports/tcp6.c
===================================================================
--- GNUnet/src/transports/tcp6.c        2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/tcp6.c        2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,7 +32,7 @@
 #include "ip.h"
 #include "ip6.h"
 
-#define DEBUG_TCP6 NO
+#define DEBUG_TCP6 GNUNET_NO
 
 /**
  * after how much time of the core not being associated with a tcp6
@@ -41,7 +41,7 @@
  * Needs to be larger than SECONDS_INACTIVE_DROP in
  * core's connection.s
  */
-#define TCP_TIMEOUT 600 * cronSECONDS
+#define TCP_TIMEOUT 600 * GNUNET_CRON_SECONDS
 
 /**
  * after how much time of the core not being associated with a tcp
@@ -50,7 +50,7 @@
  * Needs to be larger than SECONDS_INACTIVE_DROP in
  * core's connection.s
  */
-#define TCP_FAST_TIMEOUT (5 * cronSECONDS)
+#define TCP_FAST_TIMEOUT (5 * GNUNET_CRON_SECONDS)
 
 #define TARGET_BUFFER_SIZE 4092
 
@@ -64,7 +64,7 @@
   /**
    * claimed IP of the sender, network byte order
    */
-  IP6addr ip;
+  GNUNET_IPv6Address ip;
 
   /**
    * claimed port of the sender, network byte order
@@ -82,13 +82,13 @@
 
 static TransportAPI tcp6API;
 
-static struct CIDR6Network *filteredNetworks_;
+static struct GNUNET_IPv6NetworkSet *filteredNetworks_;
 
-static struct CIDR6Network *allowedNetworks_;
+static struct GNUNET_IPv6NetworkSet *allowedNetworks_;
 
 static struct GC_Configuration *cfg;
 
-static struct MUTEX *tcpblacklistlock;
+static struct GNUNET_Mutex *tcpblacklistlock;
 
 /* ******************** helper functions *********************** */
 
@@ -98,25 +98,26 @@
 static int
 isBlacklisted (const void *addr, unsigned int addr_len)
 {
-  IP6addr ip;
+  GNUNET_IPv6Address ip;
   int ret;
 
-  if (addr_len == sizeof (IP6addr))
+  if (addr_len == sizeof (GNUNET_IPv6Address))
     {
-      memcpy (&ip, addr, sizeof (IP6addr));
+      memcpy (&ip, addr, sizeof (GNUNET_IPv6Address));
     }
   else if (addr_len == sizeof (struct sockaddr_in6))
     {
       memcpy (&ip,
-              &((struct sockaddr_in6 *) addr)->sin6_addr, sizeof (IP6addr));
+              &((struct sockaddr_in6 *) addr)->sin6_addr,
+              sizeof (GNUNET_IPv6Address));
     }
   else
     {
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  MUTEX_LOCK (tcpblacklistlock);
-  ret = check_ipv6_listed (filteredNetworks_, ip);
-  MUTEX_UNLOCK (tcpblacklistlock);
+  GNUNET_mutex_lock (tcpblacklistlock);
+  ret = GNUNET_check_ipv6_listed (filteredNetworks_, ip);
+  GNUNET_mutex_unlock (tcpblacklistlock);
   return ret;
 }
 
@@ -126,38 +127,39 @@
 static int
 isWhitelisted (const void *addr, unsigned int addr_len)
 {
-  IP6addr ip;
+  GNUNET_IPv6Address ip;
   int ret;
 
-  if (addr_len == sizeof (IP6addr))
+  if (addr_len == sizeof (GNUNET_IPv6Address))
     {
-      memcpy (&ip, addr, sizeof (IP6addr));
+      memcpy (&ip, addr, sizeof (GNUNET_IPv6Address));
     }
   else if (addr_len == sizeof (struct sockaddr_in6))
     {
       memcpy (&ip,
-              &((struct sockaddr_in6 *) addr)->sin6_addr, sizeof (IP6addr));
+              &((struct sockaddr_in6 *) addr)->sin6_addr,
+              sizeof (GNUNET_IPv6Address));
     }
   else
     {
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  ret = OK;
-  MUTEX_LOCK (tcpblacklistlock);
+  ret = GNUNET_OK;
+  GNUNET_mutex_lock (tcpblacklistlock);
   if (allowedNetworks_ != NULL)
-    ret = check_ipv6_listed (filteredNetworks_, ip);
-  MUTEX_UNLOCK (tcpblacklistlock);
+    ret = GNUNET_check_ipv6_listed (filteredNetworks_, ip);
+  GNUNET_mutex_unlock (tcpblacklistlock);
   return ret;
 }
 
 static int
 isRejected (const void *addr, unsigned int addr_len)
 {
-  if ((YES == isBlacklisted (addr,
-                             addr_len)) ||
-      (YES != isWhitelisted (addr, addr_len)))
-    return YES;
-  return NO;
+  if ((GNUNET_YES == isBlacklisted (addr,
+                                    addr_len)) ||
+      (GNUNET_YES != isWhitelisted (addr, addr_len)))
+    return GNUNET_YES;
+  return GNUNET_NO;
 }
 
 /**
@@ -190,37 +192,37 @@
  * success.
  * @param hello the hello message to verify
  *        (the signature/crc have been verified before)
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 static int
-verifyHello (const P2P_hello_MESSAGE * hello)
+verifyHello (const GNUNET_MessageHello * hello)
 {
   Host6Address *haddr;
 
   haddr = (Host6Address *) & hello[1];
   if ((ntohs (hello->senderAddressSize) != sizeof (Host6Address)) ||
-      (ntohs (hello->header.size) != P2P_hello_MESSAGE_size (hello)) ||
+      (ntohs (hello->header.size) != GNUNET_sizeof_hello (hello)) ||
       (ntohs (hello->header.type) != p2p_PROTO_hello) ||
       (ntohs (hello->protocol) != TCP6_PROTOCOL_NUMBER) ||
-      (YES == isBlacklisted (&haddr->ip,
-                             sizeof (IP6addr))) ||
-      (YES != isWhitelisted (&haddr->ip, sizeof (IP6addr))))
-    return SYSERR;              /* obviously invalid */
+      (GNUNET_YES == isBlacklisted (&haddr->ip,
+                                    sizeof (GNUNET_IPv6Address))) ||
+      (GNUNET_YES != isWhitelisted (&haddr->ip, sizeof (GNUNET_IPv6Address))))
+    return GNUNET_SYSERR;       /* obviously invalid */
   else
-    return OK;
+    return GNUNET_OK;
 }
 
 /**
  * Create a hello-Message for the current node. The hello is
  * created without signature and without a timestamp. The
- * GNUnet core will sign the message and add an expiration time.
+ * GNUnet core will GNUNET_RSA_sign the message and add an expiration time.
  *
  * @return hello on success, NULL on error
  */
-static P2P_hello_MESSAGE *
+static GNUNET_MessageHello *
 createhello ()
 {
-  P2P_hello_MESSAGE *msg;
+  GNUNET_MessageHello *msg;
   Host6Address *haddr;
   unsigned short port;
 
@@ -233,13 +235,13 @@
       return NULL;              /* TCP6 transport is configured SEND-only! */
     }
   msg =
-    (P2P_hello_MESSAGE *) MALLOC (sizeof (P2P_hello_MESSAGE) +
-                                  sizeof (Host6Address));
+    (GNUNET_MessageHello *) GNUNET_malloc (sizeof (GNUNET_MessageHello) +
+                                           sizeof (Host6Address));
   haddr = (Host6Address *) & msg[1];
 
-  if (SYSERR == getPublicIP6Address (cfg, ectx, &haddr->ip))
+  if (GNUNET_SYSERR == getPublicIP6Address (cfg, ectx, &haddr->ip))
     {
-      FREE (msg);
+      GNUNET_free (msg);
       GE_LOG (ectx,
               GE_WARNING | GE_USER | GE_BULK,
               _("Could not determine my public IPv6 address.\n"));
@@ -258,10 +260,10 @@
  *
  * @param hello the hello-Message for the target node
  * @param tsessionPtr the session handle that is set
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
-tcp6Connect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr,
+tcp6Connect (const GNUNET_MessageHello * hello, TSession ** tsessionPtr,
              int may_reuse)
 {
   int i;
@@ -270,35 +272,36 @@
   char hostname[INET6_ADDRSTRLEN];
   struct addrinfo hints, *res, *res0;
   int rtn;
-  struct SocketHandle *s;
+  struct GNUNET_SocketHandle *s;
   TCPSession *session;
 
   if (selector == NULL)
-    return SYSERR;
-  if (NO != may_reuse)
+    return GNUNET_SYSERR;
+  if (GNUNET_NO != may_reuse)
     {
-      MUTEX_LOCK (tcplock);
+      GNUNET_mutex_lock (tcplock);
       session = sessions;
       while (session != NULL)
         {
           if (0 == memcmp (&session->sender,
-                           &hello->senderIdentity, sizeof (PeerIdentity)))
+                           &hello->senderIdentity,
+                           sizeof (GNUNET_PeerIdentity)))
             {
-              MUTEX_LOCK (session->lock);
+              GNUNET_mutex_lock (session->lock);
               if (session->in_select)
                 {
                   session->users++;
-                  MUTEX_UNLOCK (session->lock);
-                  MUTEX_UNLOCK (tcplock);
+                  GNUNET_mutex_unlock (session->lock);
+                  GNUNET_mutex_unlock (tcplock);
                   *tsessionPtr = session->tsession;
-                  return OK;
+                  return GNUNET_OK;
                 }
-              MUTEX_UNLOCK (session->lock);
+              GNUNET_mutex_unlock (session->lock);
             }
           session = session->next;
         }
     }
-  MUTEX_UNLOCK (tcplock);
+  GNUNET_mutex_unlock (tcplock);
   haddr = (Host6Address *) & hello[1];
   memset (&hints, 0, sizeof (hints));
   hints.ai_family = PF_INET6;
@@ -311,7 +314,7 @@
               GE_WARNING | GE_ADMIN | GE_BULK,
               _("`%s': unknown service: %s\n"),
               __FUNCTION__, gai_strerror (rtn));
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
 #if DEBUG_TCP6
@@ -337,18 +340,18 @@
           continue;
         }
       s = socket_create (ectx, coreAPI->load_monitor, sock);
-      if (-1 == socket_set_blocking (s, NO))
+      if (-1 == GNUNET_socket_set_blocking (s, GNUNET_NO))
         {
-          socket_destroy (s);
+          GNUNET_socket_destroy (s);
           freeaddrinfo (res0);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       ((struct sockaddr_in6 *) (res->ai_addr))->sin6_port = haddr->port;
       i = CONNECT (sock, res->ai_addr, res->ai_addrlen);
       if ((i < 0) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK))
         {
           GE_LOG_STRERROR (ectx, GE_WARNING | GE_ADMIN | GE_BULK, "connect");
-          socket_destroy (s);
+          GNUNET_socket_destroy (s);
           s = NULL;
           sock = -1;
           continue;
@@ -357,14 +360,14 @@
     }
   freeaddrinfo (res0);
   if (sock == -1)
-    return SYSERR;
+    return GNUNET_SYSERR;
   GE_ASSERT (ectx, s != NULL);
   return tcpConnectHelper (hello, s, tcp6API.protocolNumber, tsessionPtr);
 }
 
 /**
  * Start the server process to receive inbound traffic.
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
 startTransportServer ()
@@ -377,7 +380,7 @@
   if (selector != NULL)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   port = getGNUnetTCP6Port ();
   if (port != 0)
@@ -386,7 +389,7 @@
       if (s < 0)
         {
           GE_LOG_STRERROR (ectx, GE_ERROR | GE_ADMIN | GE_BULK, "socket");
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (SETSOCKOPT (s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0)
         GE_DIE_STRERROR (ectx,
@@ -407,28 +410,28 @@
             GE_LOG_STRERROR (ectx,
                              GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
                              "close");
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
     }
   else
     {
       s = -1;
     }
-  selector = select_create ("tcp6",
-                            NO,
-                            ectx,
-                            coreAPI->load_monitor,
-                            s,
-                            sizeof (IPaddr),
-                            TCP_FAST_TIMEOUT,
-                            &select_message_handler,
-                            NULL,
-                            &select_accept_handler,
-                            &isRejected,
-                            &select_close_handler,
-                            NULL, 128 * 1024 /* max memory */ ,
-                            128 /* max sockets */ );
-  return OK;
+  selector = GNUNET_select_create ("tcp6",
+                                   GNUNET_NO,
+                                   ectx,
+                                   coreAPI->load_monitor,
+                                   s,
+                                   sizeof (GNUNET_IPv4Address),
+                                   TCP_FAST_TIMEOUT,
+                                   &select_message_handler,
+                                   NULL,
+                                   &select_accept_handler,
+                                   &isRejected,
+                                   &select_close_handler,
+                                   NULL, 128 * 1024 /* max memory */ ,
+                                   128 /* max sockets */ );
+  return GNUNET_OK;
 }
 
 /**
@@ -445,20 +448,20 @@
 
   if (0 != strcmp (section, "TCP6"))
     return 0;                   /* fast path */
-  MUTEX_LOCK (tcpblacklistlock);
-  FREENONNULL (filteredNetworks_);
-  FREENONNULL (allowedNetworks_);
+  GNUNET_mutex_lock (tcpblacklistlock);
+  GNUNET_free_non_null (filteredNetworks_);
+  GNUNET_free_non_null (allowedNetworks_);
   GC_get_configuration_value_string (cfg, "TCP6", "BLACKLIST", "", &ch);
-  filteredNetworks_ = parse_ipv6_network_specification (ectx, ch);
-  FREE (ch);
+  filteredNetworks_ = GNUNET_parse_ipv6_network_specification (ectx, ch);
+  GNUNET_free (ch);
   GC_get_configuration_value_string (cfg, "TCP6", "WHITELIST", "", &ch);
   if (strlen (ch) > 0)
-    allowedNetworks_ = parse_ipv6_network_specification (ectx, ch);
+    allowedNetworks_ = GNUNET_parse_ipv6_network_specification (ectx, ch);
   else
     allowedNetworks_ = NULL;
-  FREE (ch);
+  GNUNET_free (ch);
 
-  MUTEX_UNLOCK (tcpblacklistlock);
+  GNUNET_mutex_unlock (tcpblacklistlock);
   return 0;
 }
 
@@ -466,20 +469,20 @@
  * Convert TCP6  hello to IPv6 address
  */
 static int
-helloToAddress (const P2P_hello_MESSAGE * hello,
+helloToAddress (const GNUNET_MessageHello * hello,
                 void **sa, unsigned int *sa_len)
 {
   const Host6Address *haddr = (const Host6Address *) &hello[1];
   struct sockaddr_in6 *serverAddr;
 
   *sa_len = sizeof (struct sockaddr_in6);
-  serverAddr = MALLOC (sizeof (struct sockaddr_in6));
+  serverAddr = GNUNET_malloc (sizeof (struct sockaddr_in6));
   *sa = serverAddr;
   memset (serverAddr, 0, sizeof (struct sockaddr_in6));
   serverAddr->sin6_family = AF_INET6;
-  memcpy (&serverAddr->sin6_addr, haddr, sizeof (IP6addr));
+  memcpy (&serverAddr->sin6_addr, haddr, sizeof (GNUNET_IPv6Address));
   serverAddr->sin6_port = haddr->port;
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -494,12 +497,12 @@
 {
   ectx = core->ectx;
   cfg = core->cfg;
-  tcplock = MUTEX_CREATE (YES);
-  tcpblacklistlock = MUTEX_CREATE (YES);
+  tcplock = GNUNET_mutex_create (GNUNET_YES);
+  tcpblacklistlock = GNUNET_mutex_create (GNUNET_YES);
   if (0 != GC_attach_change_listener (cfg, &reloadConfiguration, NULL))
     {
-      MUTEX_DESTROY (tcplock);
-      MUTEX_DESTROY (tcpblacklistlock);
+      GNUNET_mutex_destroy (tcplock);
+      GNUNET_mutex_destroy (tcpblacklistlock);
       tcplock = NULL;
       tcpblacklistlock = NULL;
       return NULL;
@@ -537,9 +540,9 @@
   GC_detach_change_listener (cfg, &reloadConfiguration, NULL);
   coreAPI->releaseService (stats);
   stats = NULL;
-  FREENONNULL (filteredNetworks_);
-  MUTEX_DESTROY (tcplock);
-  MUTEX_DESTROY (tcpblacklistlock);
+  GNUNET_free_non_null (filteredNetworks_);
+  GNUNET_mutex_destroy (tcplock);
+  GNUNET_mutex_destroy (tcpblacklistlock);
 }
 
 /* end of tcp6.c */

Modified: GNUnet/src/transports/tcp_helper.c
===================================================================
--- GNUnet/src/transports/tcp_helper.c  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/tcp_helper.c  2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,12 +32,12 @@
  */
 typedef struct
 {
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
    * Identity of the node connecting (TCP client)
    */
-  PeerIdentity clientIdentity;
+  GNUNET_PeerIdentity clientIdentity;
 } TCPWelcome;
 
 /**
@@ -51,7 +51,7 @@
   /**
    * the tcp socket (used to identify this connection with selector)
    */
-  struct SocketHandle *sock;
+  struct GNUNET_SocketHandle *sock;
 
   /**
    * Our tsession.
@@ -61,16 +61,16 @@
   /**
    * mutex for synchronized access to 'users'
    */
-  struct MUTEX *lock;
+  struct GNUNET_Mutex *lock;
 
   /**
    * To whom are we talking to (set to our identity
    * if we are still waiting for the welcome message)
    */
-  PeerIdentity sender;
+  GNUNET_PeerIdentity sender;
 
   /**
-   * Are we still expecting the welcome? (YES/NO)
+   * Are we still expecting the welcome? (GNUNET_YES/GNUNET_NO)
    */
   int expectingWelcome;
 
@@ -105,11 +105,11 @@
 
 static int stat_bytesDropped;
 
-static struct SelectHandle *selector;
+static struct GNUNET_SelectHandle *selector;
 
 static struct GE_Context *ectx;
 
-static struct MUTEX *tcplock;
+static struct GNUNET_Mutex *tcplock;
 
 static struct TCPSession *sessions;
 
@@ -125,8 +125,8 @@
   TCPSession *pos;
   TCPSession *prev;
 
-  MUTEX_DESTROY (tcpsession->lock);
-  FREENONNULL (tcpsession->accept_addr);
+  GNUNET_mutex_destroy (tcpsession->lock);
+  GNUNET_free_non_null (tcpsession->accept_addr);
   pos = sessions;
   prev = NULL;
   while (pos != NULL)
@@ -142,11 +142,11 @@
       prev = pos;
       pos = pos->next;
     }
-  MUTEX_UNLOCK (tcplock);
-  GE_ASSERT (ectx, OK == coreAPI->assertUnused (tcpsession->tsession));
-  MUTEX_LOCK (tcplock);
-  FREE (tcpsession->tsession);
-  FREE (tcpsession);
+  GNUNET_mutex_unlock (tcplock);
+  GE_ASSERT (ectx, GNUNET_OK == coreAPI->assertUnused (tcpsession->tsession));
+  GNUNET_mutex_lock (tcplock);
+  GNUNET_free (tcpsession->tsession);
+  GNUNET_free (tcpsession);
 }
 
 static int
@@ -155,30 +155,31 @@
   TCPSession *tcpsession = tsession->internal;
 
   GE_ASSERT (ectx, selector != NULL);
-  MUTEX_LOCK (tcplock);
-  MUTEX_LOCK (tcpsession->lock);
+  GNUNET_mutex_lock (tcplock);
+  GNUNET_mutex_lock (tcpsession->lock);
   GE_ASSERT (ectx, tcpsession->users > 0);
   tcpsession->users--;
-  if ((tcpsession->users > 0) || (tcpsession->in_select == YES))
+  if ((tcpsession->users > 0) || (tcpsession->in_select == GNUNET_YES))
     {
       if (tcpsession->users == 0)
-        select_change_timeout (selector, tcpsession->sock, TCP_FAST_TIMEOUT);
-      MUTEX_UNLOCK (tcpsession->lock);
-      MUTEX_UNLOCK (tcplock);
-      return OK;
+        GNUNET_select_change_timeout (selector, tcpsession->sock,
+                                      TCP_FAST_TIMEOUT);
+      GNUNET_mutex_unlock (tcpsession->lock);
+      GNUNET_mutex_unlock (tcplock);
+      return GNUNET_OK;
     }
-  MUTEX_UNLOCK (tcpsession->lock);
-  MUTEX_UNLOCK (tcplock);
+  GNUNET_mutex_unlock (tcpsession->lock);
+  GNUNET_mutex_unlock (tcplock);
 #if DEBUG_TCP
   GE_LOG (ectx,
           GE_DEBUG | GE_USER | GE_BULK,
           "TCP disconnect closes socket session.\n");
 #endif
-  select_disconnect (selector, tcpsession->sock);
-  MUTEX_LOCK (tcplock);
+  GNUNET_select_disconnect (selector, tcpsession->sock);
+  GNUNET_mutex_lock (tcplock);
   freeTCPSession (tcpsession);
-  MUTEX_UNLOCK (tcplock);
-  return OK;
+  GNUNET_mutex_unlock (tcplock);
+  return GNUNET_OK;
 }
 
 /**
@@ -189,7 +190,7 @@
  * later, in this case the argument session is NULL. This can be used
  * to test if the connection must be closed by the core or if the core
  * can assume that it is going to be self-managed (if associate
- * returns OK and session was NULL, the transport layer is responsible
+ * returns GNUNET_OK and session was NULL, the transport layer is responsible
  * for eventually freeing resources associated with the tesession). If
  * session is not NULL, the core takes responsbility for eventually
  * calling disconnect.
@@ -197,8 +198,8 @@
  * @param tsession the session handle passed along
  *   from the call to receive that was made by the transport
  *   layer
- * @return OK if the session could be associated,
- *         SYSERR if not.
+ * @return GNUNET_OK if the session could be associated,
+ *         GNUNET_SYSERR if not.
  */
 static int
 tcpAssociate (TSession * tsession)
@@ -207,13 +208,13 @@
 
   GE_ASSERT (ectx, tsession != NULL);
   tcpSession = tsession->internal;
-  MUTEX_LOCK (tcpSession->lock);
-  if ((tcpSession->users == 0) && (tcpSession->in_select == YES))
-    select_change_timeout (selector, tcpSession->sock, TCP_TIMEOUT);
+  GNUNET_mutex_lock (tcpSession->lock);
+  if ((tcpSession->users == 0) && (tcpSession->in_select == GNUNET_YES))
+    GNUNET_select_change_timeout (selector, tcpSession->sock, TCP_TIMEOUT);
   tcpSession->users++;
 
-  MUTEX_UNLOCK (tcpSession->lock);
-  return OK;
+  GNUNET_mutex_unlock (tcpSession->lock);
+  return GNUNET_OK;
 }
 
 /**
@@ -224,9 +225,9 @@
  */
 static int
 select_message_handler (void *mh_cls,
-                        struct SelectHandle *sh,
-                        struct SocketHandle *sock,
-                        void *sock_ctx, const MESSAGE_HEADER * msg)
+                        struct GNUNET_SelectHandle *sh,
+                        struct GNUNET_SocketHandle *sock,
+                        void *sock_ctx, const GNUNET_MessageHeader * msg)
 {
   TSession *tsession = sock_ctx;
   TCPSession *tcpSession;
@@ -234,16 +235,16 @@
   P2P_PACKET *mp;
   const TCPWelcome *welcome;
 
-  if (SYSERR == tcpAssociate (tsession))
+  if (GNUNET_SYSERR == tcpAssociate (tsession))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   len = ntohs (msg->size);
   if (stats != NULL)
     stats->change (stat_bytesReceived, len);
   tcpSession = tsession->internal;
-  if (YES == tcpSession->expectingWelcome)
+  if (GNUNET_YES == tcpSession->expectingWelcome)
     {
       /* at this point, we should be the only user! */
       GE_ASSERT (NULL, tcpSession->users == 1);
@@ -256,9 +257,9 @@
                   _
                   ("Received malformed message instead of welcome message. 
Closing.\n"));
           tcpDisconnect (tsession);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
-      tcpSession->expectingWelcome = NO;
+      tcpSession->expectingWelcome = GNUNET_NO;
       tcpSession->sender = welcome->clientIdentity;
       tsession->peer = welcome->clientIdentity;
       if (tcpSession->accept_addr != NULL)
@@ -268,25 +269,25 @@
   else
     {
       /* send msg to core! */
-      if (len <= sizeof (MESSAGE_HEADER))
+      if (len <= sizeof (GNUNET_MessageHeader))
         {
           GE_LOG (ectx,
                   GE_WARNING | GE_USER | GE_BULK,
                   _
                   ("Received malformed message from tcp-peer connection. 
Closing.\n"));
           tcpDisconnect (tsession);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
-      mp = MALLOC (sizeof (P2P_PACKET));
-      mp->msg = MALLOC (len - sizeof (MESSAGE_HEADER));
-      memcpy (mp->msg, &msg[1], len - sizeof (MESSAGE_HEADER));
+      mp = GNUNET_malloc (sizeof (P2P_PACKET));
+      mp->msg = GNUNET_malloc (len - sizeof (GNUNET_MessageHeader));
+      memcpy (mp->msg, &msg[1], len - sizeof (GNUNET_MessageHeader));
       mp->sender = tcpSession->sender;
-      mp->size = len - sizeof (MESSAGE_HEADER);
+      mp->size = len - sizeof (GNUNET_MessageHeader);
       mp->tsession = tsession;
       coreAPI->receive (mp);
     }
   tcpDisconnect (tsession);
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -297,8 +298,8 @@
  */
 static void *
 select_accept_handler (void *ah_cls,
-                       struct SelectHandle *sh,
-                       struct SocketHandle *sock,
+                       struct GNUNET_SelectHandle *sh,
+                       struct GNUNET_SocketHandle *sock,
                        const void *addr, unsigned int addr_len)
 {
   BlacklistedTester blt = ah_cls;
@@ -306,7 +307,7 @@
   TCPSession *tcpSession;
 
   GE_ASSERT (NULL, sock != NULL);
-  if (NO != blt (addr, addr_len))
+  if (GNUNET_NO != blt (addr, addr_len))
     {
 #if DEBUG_TCP
       GE_LOG (ectx,
@@ -318,26 +319,26 @@
 #if DEBUG_TCP
   GE_LOG (ectx, GE_DEBUG | GE_USER | GE_BULK, "Accepting TCP connection.\n");
 #endif
-  tcpSession = MALLOC (sizeof (TCPSession));
+  tcpSession = GNUNET_malloc (sizeof (TCPSession));
   memset (tcpSession, 0, sizeof (TCPSession));
   tcpSession->sock = sock;
   /* fill in placeholder identity to mark that we
      are waiting for the welcome message */
   tcpSession->sender = *(coreAPI->myIdentity);
-  tcpSession->expectingWelcome = YES;
-  tcpSession->lock = MUTEX_CREATE (YES);
+  tcpSession->expectingWelcome = GNUNET_YES;
+  tcpSession->lock = GNUNET_mutex_create (GNUNET_YES);
   tcpSession->users = 0;
-  tcpSession->in_select = YES;
+  tcpSession->in_select = GNUNET_YES;
 
-  tsession = MALLOC (sizeof (TSession));
+  tsession = GNUNET_malloc (sizeof (TSession));
   memset (tsession, 0, sizeof (TSession));
   tsession->ttype = TCP_PROTOCOL_NUMBER;
   tsession->internal = tcpSession;
   tcpSession->tsession = tsession;
   tsession->peer = *(coreAPI->myIdentity);
-  if (addr_len > sizeof (IPaddr))
+  if (addr_len > sizeof (GNUNET_IPv4Address))
     {
-      tcpSession->accept_addr = MALLOC (addr_len);
+      tcpSession->accept_addr = GNUNET_malloc (addr_len);
       memcpy (tcpSession->accept_addr,
               (struct sockaddr_in *) addr, sizeof (struct sockaddr_in));
       tcpSession->addr_len = addr_len;
@@ -348,44 +349,44 @@
       tcpSession->addr_len = 0;
       tcpSession->accept_addr = NULL;
     }
-  MUTEX_LOCK (tcplock);
+  GNUNET_mutex_lock (tcplock);
   tcpSession->next = sessions;
   sessions = tcpSession;
-  MUTEX_UNLOCK (tcplock);
+  GNUNET_mutex_unlock (tcplock);
   return tsession;
 }
 
 static void
 select_close_handler (void *ch_cls,
-                      struct SelectHandle *sh,
-                      struct SocketHandle *sock, void *sock_ctx)
+                      struct GNUNET_SelectHandle *sh,
+                      struct GNUNET_SocketHandle *sock, void *sock_ctx)
 {
   TSession *tsession = sock_ctx;
   TCPSession *tcpSession = tsession->internal;
 
 #if DEBUG_TCP
-  EncName enc;
+  GNUNET_EncName enc;
 
   IF_GELOG (ectx,
             GE_DEBUG | GE_DEVELOPER | GE_BULK,
-            hash2enc (&tcpSession->sender.hashPubKey, &enc));
+            GNUNET_hash_to_enc (&tcpSession->sender.hashPubKey, &enc));
   GE_LOG (ectx,
           GE_DEBUG | GE_DEVELOPER | GE_BULK,
           "Closed TCP socket of `%s'.\n", &enc);
 #endif
-  MUTEX_LOCK (tcplock);
-  MUTEX_LOCK (tcpSession->lock);
-  tcpSession->in_select = NO;
+  GNUNET_mutex_lock (tcplock);
+  GNUNET_mutex_lock (tcpSession->lock);
+  tcpSession->in_select = GNUNET_NO;
   if (tcpSession->users == 0)
     {
-      MUTEX_UNLOCK (tcpSession->lock);
+      GNUNET_mutex_unlock (tcpSession->lock);
       freeTCPSession (tcpSession);
     }
   else
     {
-      MUTEX_UNLOCK (tcpSession->lock);
+      GNUNET_mutex_unlock (tcpSession->lock);
     }
-  MUTEX_UNLOCK (tcplock);
+  GNUNET_mutex_unlock (tcplock);
 }
 
 /**
@@ -394,36 +395,36 @@
  * @param tsession the handle identifying the remote node
  * @param msg the message
  * @param size the size of the message
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 static int
 tcpSend (TSession * tsession,
          const void *msg, unsigned int size, int important)
 {
   TCPSession *tcpSession;
-  MESSAGE_HEADER *mp;
+  GNUNET_MessageHeader *mp;
   int ok;
 
   tcpSession = tsession->internal;
-  if (size >= MAX_BUFFER_SIZE - sizeof (MESSAGE_HEADER))
+  if (size >= GNUNET_MAX_BUFFER_SIZE - sizeof (GNUNET_MessageHeader))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;            /* too big */
+      return GNUNET_SYSERR;     /* too big */
     }
-  if (tcpSession->in_select == NO)
+  if (tcpSession->in_select == GNUNET_NO)
     {
 #if DEBUG_TCP
-      EncName enc;
+      GNUNET_EncName enc;
 
       IF_GELOG (ectx,
                 GE_DEBUG | GE_DEVELOPER | GE_BULK,
-                hash2enc (&tcpSession->sender.hashPubKey, &enc));
+                GNUNET_hash_to_enc (&tcpSession->sender.hashPubKey, &enc));
       GE_LOG (ectx,
               GE_DEBUG | GE_DEVELOPER | GE_BULK,
               "Cannot send message - TCP socket of `%s' already closed!\n",
               &enc);
 #endif
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (selector == NULL)
     {
@@ -434,12 +435,12 @@
               GE_DEBUG | GE_USER | GE_BULK,
               "Could not sent TCP message -- tcp transport is down.\n");
 #endif
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (size == 0)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (tcpSession->sock == NULL)
     {
@@ -450,10 +451,10 @@
               GE_DEBUG | GE_USER | GE_BULK,
               "Could not sent TCP message -- other side closed connection.\n");
 #endif
-      return SYSERR;            /* other side closed connection */
+      return GNUNET_SYSERR;     /* other side closed connection */
     }
-  mp = MALLOC (sizeof (MESSAGE_HEADER) + size);
-  mp->size = htons (size + sizeof (MESSAGE_HEADER));
+  mp = GNUNET_malloc (sizeof (GNUNET_MessageHeader) + size);
+  mp->size = htons (size + sizeof (GNUNET_MessageHeader));
   mp->type = 0;
   memcpy (&mp[1], msg, size);
 #if DEBUG_TCP
@@ -461,11 +462,13 @@
           GE_DEBUG | GE_DEVELOPER | GE_BULK,
           "Transport asks select to queue message of size %u\n", size);
 #endif
-  ok = select_write (selector, tcpSession->sock, mp, NO, important);
-  if ((OK == ok) && (stats != NULL))
-    stats->change (stat_bytesSent, size + sizeof (MESSAGE_HEADER));
+  ok =
+    GNUNET_select_write (selector, tcpSession->sock, mp, GNUNET_NO,
+                         important);
+  if ((GNUNET_OK == ok) && (stats != NULL))
+    stats->change (stat_bytesSent, size + sizeof (GNUNET_MessageHeader));
 
-  FREE (mp);
+  GNUNET_free (mp);
   return ok;
 }
 
@@ -477,31 +480,32 @@
  * even bother to construct (and encrypt) this kind
  * of message.
  *
- * @return YES if the transport would try (i.e. queue
+ * @return GNUNET_YES if the transport would try (i.e. queue
  *         the message or call the OS to send),
- *         NO if the transport would just drop the message,
- *         SYSERR if the size/session is invalid
+ *         GNUNET_NO if the transport would just drop the message,
+ *         GNUNET_SYSERR if the size/session is invalid
  */
 static int
 tcpTestWouldTry (TSession * tsession, const unsigned int size, int important)
 {
   TCPSession *tcpSession = tsession->internal;
 
-  if (size >= MAX_BUFFER_SIZE - sizeof (MESSAGE_HEADER))
+  if (size >= GNUNET_MAX_BUFFER_SIZE - sizeof (GNUNET_MessageHeader))
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (selector == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   if (size == 0)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (tcpSession->sock == NULL)
-    return SYSERR;              /* other side closed connection */
-  return select_would_try (selector, tcpSession->sock, size, NO, important);
+    return GNUNET_SYSERR;       /* other side closed connection */
+  return GNUNET_select_test_write_now (selector, tcpSession->sock, size,
+                                       GNUNET_NO, important);
 }
 
 
@@ -510,43 +514,46 @@
  *
  * @param helo the hello-Message for the target node
  * @param tsessionPtr the session handle that is set
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
-tcpConnectHelper (const P2P_hello_MESSAGE * hello,
-                  struct SocketHandle *s,
+tcpConnectHelper (const GNUNET_MessageHello * hello,
+                  struct GNUNET_SocketHandle *s,
                   unsigned int protocolNumber, TSession ** tsessionPtr)
 {
   TCPWelcome welcome;
   TSession *tsession;
   TCPSession *tcpSession;
 
-  tcpSession = MALLOC (sizeof (TCPSession));
+  tcpSession = GNUNET_malloc (sizeof (TCPSession));
   memset (tcpSession, 0, sizeof (TCPSession));
   tcpSession->addr_len = 0;
   tcpSession->accept_addr = NULL;
   tcpSession->sock = s;
-  tsession = MALLOC (sizeof (TSession));
+  tsession = GNUNET_malloc (sizeof (TSession));
   memset (tsession, 0, sizeof (TSession));
   tsession->internal = tcpSession;
   tsession->ttype = protocolNumber;
   tsession->peer = hello->senderIdentity;
   tcpSession->tsession = tsession;
-  tcpSession->lock = MUTEX_CREATE (YES);
+  tcpSession->lock = GNUNET_mutex_create (GNUNET_YES);
   tcpSession->users = 1;        /* caller */
-  tcpSession->in_select = NO;
+  tcpSession->in_select = GNUNET_NO;
   tcpSession->sender = hello->senderIdentity;
-  tcpSession->expectingWelcome = NO;
-  MUTEX_LOCK (tcplock);
-  if (OK == select_connect (selector, tcpSession->sock, tsession))
-    tcpSession->in_select = YES;
+  tcpSession->expectingWelcome = GNUNET_NO;
+  GNUNET_mutex_lock (tcplock);
+  if (GNUNET_OK ==
+      GNUNET_select_connect (selector, tcpSession->sock, tsession))
+    tcpSession->in_select = GNUNET_YES;
 
   /* send our node identity to the other side to fully establish the
      connection! */
   welcome.header.size = htons (sizeof (TCPWelcome));
   welcome.header.type = htons (0);
   welcome.clientIdentity = *(coreAPI->myIdentity);
-  if (OK != select_write (selector, s, &welcome.header, NO, YES))
+  if (GNUNET_OK !=
+      GNUNET_select_write (selector, s, &welcome.header, GNUNET_NO,
+                           GNUNET_YES))
     {
 #if DEBUG_TCP
       GE_LOG (ectx,
@@ -555,16 +562,16 @@
 #endif
       /* disconnect caller -- error! */
       tcpDisconnect (tsession);
-      MUTEX_UNLOCK (tcplock);
-      return SYSERR;
+      GNUNET_mutex_unlock (tcplock);
+      return GNUNET_SYSERR;
     }
   else if (stats != NULL)
     stats->change (stat_bytesSent, sizeof (TCPWelcome));
   tcpSession->next = sessions;
   sessions = tcpSession;
-  MUTEX_UNLOCK (tcplock);
+  GNUNET_mutex_unlock (tcplock);
   *tsessionPtr = tsession;
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -576,10 +583,10 @@
 {
   if (selector != NULL)
     {
-      select_destroy (selector);
+      GNUNET_select_destroy (selector);
       selector = NULL;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /* end of tcp_helper.c */

Modified: GNUnet/src/transports/test.c
===================================================================
--- GNUnet/src/transports/test.c        2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/test.c        2007-11-23 11:51:54 UTC (rev 5742)
@@ -77,8 +77,8 @@
 /**
  * No options.
  */
-static struct CommandLineOption testOptions[] = {
-  COMMAND_LINE_OPTION_END,
+static struct GNUNET_CommandLineOption testOptions[] = {
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 static void *
@@ -93,7 +93,7 @@
 static int
 assertUnused (TSession * tsession)
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -105,7 +105,7 @@
 {
   unsigned int retries;
   TSession *tsession;
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
 
   if (pid == 0)
     {
@@ -118,19 +118,21 @@
           /* HACK hello -- change port! */
           ((unsigned short *) &hello[1])[2] =
             htons (ntohs (((unsigned short *) &hello[1])[2]) - OFFSET);
-          if (OK != transport->connect (hello, &tsession, NO))
+          if (GNUNET_OK != transport->connect (hello, &tsession, GNUNET_NO))
             {
-              FREE (hello);
-              FREE (mp->msg);
-              FREE (mp);
+              GNUNET_free (hello);
+              GNUNET_free (mp->msg);
+              GNUNET_free (mp);
               error_count++;
               return;
             }
-          FREE (hello);
+          GNUNET_free (hello);
         }
-      while (NO == transport->send (tsession,
-                                    mp->msg,
-                                    mp->size, retries > 6 ? YES : NO))
+      while (GNUNET_NO == transport->send (tsession,
+                                           mp->msg,
+                                           mp->size,
+                                           retries >
+                                           6 ? GNUNET_YES : GNUNET_NO))
         {
           if (retries > 10)
             {
@@ -155,23 +157,23 @@
       else
         msg_count++;
     }
-  FREE (mp->msg);
-  FREE (mp);
+  GNUNET_free (mp->msg);
+  GNUNET_free (mp);
 }
 
 int
 main (int argc, char *const *argv)
 {
   CoreAPIForTransport api;
-  struct PluginHandle *plugin;
+  struct GNUNET_PluginHandle *plugin;
   TransportMainMethod init;
   void (*done) ();
-  PeerIdentity me;
+  GNUNET_PeerIdentity me;
   char *trans;
   int res;
   int pos;
   TSession *tsession;
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
 
   memset (&api, 0, sizeof (CoreAPIForTransport));
   pid = fork ();
@@ -182,7 +184,7 @@
   if (res == -1)
     goto cleanup;
 
-  expectedValue = MALLOC (expectedSize);
+  expectedValue = GNUNET_malloc (expectedSize);
   pos = expectedSize;
   expectedValue[--pos] = '\0';
   while (pos-- > 0)
@@ -225,19 +227,20 @@
                                      4447 + pos);
   GC_set_configuration_value_number (api.cfg, api.ectx, "HTTP", "PORT",
                                      4448 + pos);
-  makeRandomId (&me.hashPubKey);
-  plugin = os_plugin_load (api.ectx, "libgnunettransport_", trans);
-  FREE (trans);
+  GNUNET_create_random_hash (&me.hashPubKey);
+  plugin = GNUNET_plugin_load (api.ectx, "libgnunettransport_", trans);
+  GNUNET_free (trans);
   if (plugin == NULL)
     {
       fprintf (stderr, "Error loading plugin...\n");
       goto cleanup;
     }
-  init = os_plugin_resolve_function (plugin, "inittransport_", YES);
+  init =
+    GNUNET_plugin_resolve_function (plugin, "inittransport_", GNUNET_YES);
   if (init == NULL)
     {
       fprintf (stderr, "Error resolving init method...\n");
-      os_plugin_unload (plugin);
+      GNUNET_plugin_unload (plugin);
       goto cleanup;
     }
   api.cron = cron_create (api.ectx);
@@ -246,22 +249,22 @@
   api.requestService = &requestService;
   api.releaseService = NULL;    /* not needed */
   api.assertUnused = &assertUnused;
-  cron_start (api.cron);
-  res = OK;
+  GNUNET_cron_start (api.cron);
+  res = GNUNET_OK;
   transport = init (&api);
   if (transport == NULL)
     {
       fprintf (stderr, "Error initializing plugin...\n");
-      os_plugin_unload (plugin);
+      GNUNET_plugin_unload (plugin);
       goto cleanup;
     }
   transport->startTransportServer ();
   GE_ASSERT (NULL, (transport->mtu >= expectedSize) || (transport->mtu == 0));
-  PTHREAD_SLEEP (50 * cronMILLIS);      /* give other process time to start */
+  GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);  /* give other process 
time to start */
   if (pid == 0)
     {
       /* server - wait for requests */
-      GNUNET_SHUTDOWN_WAITFOR ();
+      GNUNET_shutdown_wait_for ();
     }
   else
     {
@@ -270,30 +273,32 @@
       /* HACK hello -- change port! */
       ((unsigned short *) &hello[1])[2] =
         htons (ntohs (((unsigned short *) &hello[1])[2]) + OFFSET);
-      if (OK != transport->connect (hello, &tsession, NO))
+      if (GNUNET_OK != transport->connect (hello, &tsession, GNUNET_NO))
         {
-          FREE (hello);
+          GNUNET_free (hello);
           transport->stopTransportServer ();
-          os_plugin_unload (plugin);
+          GNUNET_plugin_unload (plugin);
           goto cleanup;
         }
-      FREE (hello);
+      GNUNET_free (hello);
       pos = 0;
       while (pos < ROUNDS)
         {
-          if (OK == transport->send (tsession,
-                                     expectedValue,
-                                     expectedSize,
-                                     pos > ROUNDS / 2 ? YES : NO))
+          if (GNUNET_OK == transport->send (tsession,
+                                            expectedValue,
+                                            expectedSize,
+                                            pos >
+                                            ROUNDS /
+                                            2 ? GNUNET_YES : GNUNET_NO))
             pos++;
         }
       pos = 0;
       while ((pos++ < 100) && (msg_count < ROUNDS))
-        PTHREAD_SLEEP (50 * cronMILLIS);
+        GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
       if (msg_count < ROUNDS)
         {
           if (NULL == strstr (argv[0], "udp"))
-            res = SYSERR;
+            res = GNUNET_SYSERR;
           else
             fprintf (stderr,
                      "WARNING: only %u/%u messages received (maybe ok, try 
again?)\n",
@@ -303,7 +308,7 @@
     }
 
   transport->stopTransportServer ();
-  done = os_plugin_resolve_function (plugin, "donetransport_", NO);
+  done = GNUNET_plugin_resolve_function (plugin, "donetransport_", GNUNET_NO);
   if (done != NULL)
     done ();
   if (pid != 0)
@@ -311,16 +316,16 @@
       kill (pid, SIGTERM);
       waitpid (pid, &pos, 0);
       if (WEXITSTATUS (pos) != 0)
-        res = SYSERR;
+        res = GNUNET_SYSERR;
     }
-  os_plugin_unload (plugin);
-  cron_stop (api.cron);
-  cron_destroy (api.cron);
+  GNUNET_plugin_unload (plugin);
+  GNUNET_cron_stop (api.cron);
+  GNUNET_cron_destroy (api.cron);
   GNUNET_fini (api.ectx, api.cfg);
-  FREE (expectedValue);
+  GNUNET_free (expectedValue);
   if (error_count > 0)
-    res = SYSERR;
-  if (res != OK)
+    res = GNUNET_SYSERR;
+  if (res != GNUNET_OK)
     {
       fprintf (stderr,
                "Test failed (%u/%u %s)!\n",
@@ -336,7 +341,7 @@
       kill (pid, SIGTERM);
       waitpid (pid, &res, 0);
     }
-  FREE (expectedValue);
+  GNUNET_free (expectedValue);
   return 1;
 }
 

Modified: GNUnet/src/transports/test_repeat.c
===================================================================
--- GNUnet/src/transports/test_repeat.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/test_repeat.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -79,8 +79,8 @@
 /**
  * No options.
  */
-static struct CommandLineOption testOptions[] = {
-  COMMAND_LINE_OPTION_END,
+static struct GNUNET_CommandLineOption testOptions[] = {
+  GNUNET_COMMAND_LINE_OPTION_END,
 };
 
 static void *
@@ -95,7 +95,7 @@
 static int
 assertUnused (TSession * tsession)
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -107,7 +107,7 @@
 {
   unsigned int retries;
   TSession *tsession;
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
 
   if (pid == 0)
     {
@@ -120,19 +120,21 @@
           /* HACK hello -- change port! */
           ((unsigned short *) &hello[1])[2] =
             htons (ntohs (((unsigned short *) &hello[1])[2]) - OFFSET);
-          if (OK != transport->connect (hello, &tsession, NO))
+          if (GNUNET_OK != transport->connect (hello, &tsession, GNUNET_NO))
             {
-              FREE (hello);
-              FREE (mp->msg);
-              FREE (mp);
+              GNUNET_free (hello);
+              GNUNET_free (mp->msg);
+              GNUNET_free (mp);
               error_count++;
               return;
             }
-          FREE (hello);
+          GNUNET_free (hello);
         }
-      while (NO == transport->send (tsession,
-                                    mp->msg,
-                                    mp->size, retries > 6 ? YES : NO))
+      while (GNUNET_NO == transport->send (tsession,
+                                           mp->msg,
+                                           mp->size,
+                                           retries >
+                                           6 ? GNUNET_YES : GNUNET_NO))
         {
           if (retries > 10)
             {
@@ -157,23 +159,23 @@
       else
         msg_count++;
     }
-  FREE (mp->msg);
-  FREE (mp);
+  GNUNET_free (mp->msg);
+  GNUNET_free (mp);
 }
 
 int
 main (int argc, char *const *argv)
 {
   CoreAPIForTransport api;
-  struct PluginHandle *plugin;
+  struct GNUNET_PluginHandle *plugin;
   TransportMainMethod init;
   void (*done) ();
-  PeerIdentity me;
+  GNUNET_PeerIdentity me;
   char *trans;
   int res;
   int pos;
   TSession *tsession;
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
   int xround;
 
   memset (&api, 0, sizeof (CoreAPIForTransport));
@@ -185,7 +187,7 @@
   if (res == -1)
     goto cleanup;
 
-  expectedValue = MALLOC (expectedSize);
+  expectedValue = GNUNET_malloc (expectedSize);
   pos = expectedSize;
   expectedValue[--pos] = '\0';
   while (pos-- > 0)
@@ -228,19 +230,20 @@
                                      4447 + pos);
   GC_set_configuration_value_number (api.cfg, api.ectx, "HTTP", "PORT",
                                      4448 + pos);
-  makeRandomId (&me.hashPubKey);
-  plugin = os_plugin_load (api.ectx, "libgnunettransport_", trans);
-  FREE (trans);
+  GNUNET_create_random_hash (&me.hashPubKey);
+  plugin = GNUNET_plugin_load (api.ectx, "libgnunettransport_", trans);
+  GNUNET_free (trans);
   if (plugin == NULL)
     {
       fprintf (stderr, "Error loading plugin...\n");
       goto cleanup;
     }
-  init = os_plugin_resolve_function (plugin, "inittransport_", YES);
+  init =
+    GNUNET_plugin_resolve_function (plugin, "inittransport_", GNUNET_YES);
   if (init == NULL)
     {
       fprintf (stderr, "Error resolving init method...\n");
-      os_plugin_unload (plugin);
+      GNUNET_plugin_unload (plugin);
       goto cleanup;
     }
   api.cron = cron_create (api.ectx);
@@ -249,22 +252,22 @@
   api.requestService = &requestService;
   api.releaseService = NULL;    /* not needed */
   api.assertUnused = &assertUnused;
-  cron_start (api.cron);
-  res = OK;
+  GNUNET_cron_start (api.cron);
+  res = GNUNET_OK;
   transport = init (&api);
   if (transport == NULL)
     {
       fprintf (stderr, "Error initializing plugin...\n");
-      os_plugin_unload (plugin);
+      GNUNET_plugin_unload (plugin);
       goto cleanup;
     }
   transport->startTransportServer ();
   GE_ASSERT (NULL, (transport->mtu >= expectedSize) || (transport->mtu == 0));
-  PTHREAD_SLEEP (50 * cronMILLIS);      /* give other process time to start */
+  GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);  /* give other process 
time to start */
   if (pid == 0)
     {
       /* server - wait for requests */
-      GNUNET_SHUTDOWN_WAITFOR ();
+      GNUNET_shutdown_wait_for ();
     }
   else
     {
@@ -276,30 +279,32 @@
           /* HACK hello -- change port! */
           ((unsigned short *) &hello[1])[2] =
             htons (ntohs (((unsigned short *) &hello[1])[2]) + OFFSET);
-          if (OK != transport->connect (hello, &tsession, NO))
+          if (GNUNET_OK != transport->connect (hello, &tsession, GNUNET_NO))
             {
-              FREE (hello);
+              GNUNET_free (hello);
               transport->stopTransportServer ();
-              os_plugin_unload (plugin);
+              GNUNET_plugin_unload (plugin);
               goto cleanup;
             }
-          FREE (hello);
+          GNUNET_free (hello);
           pos = 0;
           while (pos < ROUNDS)
             {
-              if (OK == transport->send (tsession,
-                                         expectedValue,
-                                         expectedSize,
-                                         pos > ROUNDS / 2 ? YES : NO))
+              if (GNUNET_OK == transport->send (tsession,
+                                                expectedValue,
+                                                expectedSize,
+                                                pos >
+                                                ROUNDS /
+                                                2 ? GNUNET_YES : GNUNET_NO))
                 pos++;
             }
           pos = 0;
           while ((pos++ < 100) && (msg_count < ROUNDS * (xround + 1)))
-            PTHREAD_SLEEP (50 * cronMILLIS);
+            GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
           if (msg_count < ROUNDS * (xround + 1))
             {
               if (NULL == strstr (argv[0], "udp"))
-                res = SYSERR;
+                res = GNUNET_SYSERR;
               else
                 fprintf (stderr,
                          "WARNING: only %u/%u messages received (maybe ok, try 
again?)\n",
@@ -316,7 +321,7 @@
     }
 
   transport->stopTransportServer ();
-  done = os_plugin_resolve_function (plugin, "donetransport_", NO);
+  done = GNUNET_plugin_resolve_function (plugin, "donetransport_", GNUNET_NO);
   if (done != NULL)
     done ();
   if (pid != 0)
@@ -324,16 +329,16 @@
       kill (pid, SIGTERM);
       waitpid (pid, &pos, 0);
       if (WEXITSTATUS (pos) != 0)
-        res = SYSERR;
+        res = GNUNET_SYSERR;
     }
-  os_plugin_unload (plugin);
-  cron_stop (api.cron);
-  cron_destroy (api.cron);
+  GNUNET_plugin_unload (plugin);
+  GNUNET_cron_stop (api.cron);
+  GNUNET_cron_destroy (api.cron);
   GNUNET_fini (api.ectx, api.cfg);
-  FREE (expectedValue);
+  GNUNET_free (expectedValue);
   if (error_count > 0)
-    res = SYSERR;
-  if (res != OK)
+    res = GNUNET_SYSERR;
+  if (res != GNUNET_OK)
     {
       fprintf (stderr,
                "Test failed (%u/%u %s)!\n",
@@ -350,7 +355,7 @@
       kill (pid, SIGTERM);
       waitpid (pid, &res, 0);
     }
-  FREE (expectedValue);
+  GNUNET_free (expectedValue);
   return 1;
 }
 

Modified: GNUnet/src/transports/udp.c
===================================================================
--- GNUnet/src/transports/udp.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/udp.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,7 +32,7 @@
 #include "ip.h"
 #include "platform.h"
 
-#define DEBUG_UDP NO
+#define DEBUG_UDP GNUNET_NO
 
 static UPnP_ServiceAPI *upnp;
 
@@ -46,7 +46,7 @@
   /**
    * claimed IP of the sender, network byte order
    */
-  IPaddr ip;
+  GNUNET_IPv4Address ip;
 
   /**
    * claimed port of the sender, network byte order
@@ -62,13 +62,13 @@
 
 static struct GC_Configuration *cfg;
 
-static struct LoadMonitor *load_monitor;
+static struct GNUNET_LoadMonitor *load_monitor;
 
-static struct CIDRNetwork *filteredNetworks_;
+static struct GNUNET_IPv4NetworkSet *filteredNetworks_;
 
-static struct CIDRNetwork *allowedNetworks_;
+static struct GNUNET_IPv4NetworkSet *allowedNetworks_;
 
-static struct MUTEX *configLock;
+static struct GNUNET_Mutex *configLock;
 
 /**
  * Get the GNUnet UDP port from the configuration, or from
@@ -141,24 +141,25 @@
 static int
 isBlacklisted (const void *addr, unsigned int addr_len)
 {
-  IPaddr ip;
+  GNUNET_IPv4Address ip;
   int ret;
 
   if (addr_len == sizeof (struct sockaddr_in))
     {
-      memcpy (&ip, &((struct sockaddr_in *) addr)->sin_addr, sizeof (IPaddr));
+      memcpy (&ip, &((struct sockaddr_in *) addr)->sin_addr,
+              sizeof (GNUNET_IPv4Address));
     }
-  else if (addr_len == sizeof (IPaddr))
+  else if (addr_len == sizeof (GNUNET_IPv4Address))
     {
       memcpy (&ip, addr, addr_len);
     }
   else
     {
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  MUTEX_LOCK (configLock);
-  ret = check_ipv4_listed (filteredNetworks_, ip);
-  MUTEX_UNLOCK (configLock);
+  GNUNET_mutex_lock (configLock);
+  ret = GNUNET_check_ipv4_listed (filteredNetworks_, ip);
+  GNUNET_mutex_unlock (configLock);
   return ret;
 }
 
@@ -168,45 +169,46 @@
 static int
 isWhitelisted (const void *addr, unsigned int addr_len)
 {
-  IPaddr ip;
+  GNUNET_IPv4Address ip;
   int ret;
 
   if (addr_len == sizeof (struct sockaddr_in))
     {
-      memcpy (&ip, &((struct sockaddr_in *) addr)->sin_addr, sizeof (IPaddr));
+      memcpy (&ip, &((struct sockaddr_in *) addr)->sin_addr,
+              sizeof (GNUNET_IPv4Address));
     }
-  else if (addr_len == sizeof (IPaddr))
+  else if (addr_len == sizeof (GNUNET_IPv4Address))
     {
       memcpy (&ip, addr, addr_len);
     }
   else
     {
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  ret = OK;
-  MUTEX_LOCK (configLock);
+  ret = GNUNET_OK;
+  GNUNET_mutex_lock (configLock);
   if (allowedNetworks_ != NULL)
-    ret = check_ipv4_listed (allowedNetworks_, ip);
-  MUTEX_UNLOCK (configLock);
+    ret = GNUNET_check_ipv4_listed (allowedNetworks_, ip);
+  GNUNET_mutex_unlock (configLock);
   return ret;
 }
 
 static int
 isRejected (const void *addr, unsigned int addr_len)
 {
-  if ((YES == isBlacklisted (addr,
-                             addr_len)) ||
-      (YES != isWhitelisted (addr, addr_len)))
+  if ((GNUNET_YES == isBlacklisted (addr,
+                                    addr_len)) ||
+      (GNUNET_YES != isWhitelisted (addr, addr_len)))
     {
 #if DEBUG_UDP
       GE_LOG (ectx,
               GE_DEBUG | GE_USER | GE_BULK,
               "Rejecting traffic from %u.%u.%u.%u.\n",
-              PRIP (ntohl (*(int *) addr)));
+              GNUNET_PRIP (ntohl (*(int *) addr)));
 #endif
-      return YES;
+      return GNUNET_YES;
     }
-  return NO;
+  return GNUNET_NO;
 }
 
 
@@ -217,54 +219,56 @@
  *
  * @param helo the hello message to verify
  *        (the signature/crc have been verified before)
- * @return OK on success, SYSERR on failure
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
 static int
-verifyHello (const P2P_hello_MESSAGE * hello)
+verifyHello (const GNUNET_MessageHello * hello)
 {
   const HostAddress *haddr;
 
   haddr = (const HostAddress *) &hello[1];
   if ((ntohs (hello->senderAddressSize) != sizeof (HostAddress)) ||
-      (ntohs (hello->header.size) != P2P_hello_MESSAGE_size (hello)) ||
+      (ntohs (hello->header.size) != GNUNET_sizeof_hello (hello)) ||
       (ntohs (hello->header.type) != p2p_PROTO_hello))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  if ((YES == isBlacklisted (&haddr->ip,
-                             sizeof (IPaddr))) ||
-      (YES != isWhitelisted (&haddr->ip, sizeof (IPaddr))))
+  if ((GNUNET_YES == isBlacklisted (&haddr->ip,
+                                    sizeof (GNUNET_IPv4Address))) ||
+      (GNUNET_YES != isWhitelisted (&haddr->ip, sizeof (GNUNET_IPv4Address))))
     {
 #if DEBUG_UDP
       GE_LOG (ectx,
               GE_DEBUG | GE_USER | GE_BULK,
               "Rejecting UDP HELLO from %u.%u.%u.%u:%u due to 
configuration.\n",
-              PRIP (ntohl (*(int *) &haddr->ip.addr)), ntohs (haddr->port));
+              GNUNET_PRIP (ntohl (*(int *) &haddr->ip.addr)),
+              ntohs (haddr->port));
 #endif
-      return SYSERR;            /* obviously invalid */
+      return GNUNET_SYSERR;     /* obviously invalid */
     }
 #if DEBUG_UDP
   GE_LOG (ectx,
           GE_DEBUG | GE_USER | GE_BULK,
           "Verified UDP HELLO from %u.%u.%u.%u:%u.\n",
-          PRIP (ntohl (*(int *) &haddr->ip.addr)), ntohs (haddr->port));
+          GNUNET_PRIP (ntohl (*(int *) &haddr->ip.addr)),
+          ntohs (haddr->port));
 #endif
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Create a hello-Message for the current node. The hello is created
  * without signature and without a timestamp. The GNUnet core will
- * sign the message and add an expiration time.
+ * GNUNET_RSA_sign the message and add an expiration time.
  *
  * @return hello on success, NULL on error
  */
-static P2P_hello_MESSAGE *
+static GNUNET_MessageHello *
 createhello ()
 {
   static HostAddress last_addr;
-  P2P_hello_MESSAGE *msg;
+  GNUNET_MessageHello *msg;
   HostAddress *haddr;
   unsigned short port;
 
@@ -272,17 +276,17 @@
   if (port == 0)
     return NULL;                /* UDP transport configured send-only */
 
-  msg = MALLOC (sizeof (P2P_hello_MESSAGE) + sizeof (HostAddress));
+  msg = GNUNET_malloc (sizeof (GNUNET_MessageHello) + sizeof (HostAddress));
   haddr = (HostAddress *) & msg[1];
 
 
   if (!(((upnp != NULL) &&
-         (OK == upnp->get_ip (port,
-                              "UDP",
-                              &haddr->ip))) ||
-        (SYSERR != getPublicIPAddress (cfg, ectx, &haddr->ip))))
+         (GNUNET_OK == upnp->get_ip (port,
+                                     "UDP",
+                                     &haddr->ip))) ||
+        (GNUNET_SYSERR != getPublicIPAddress (cfg, ectx, &haddr->ip))))
     {
-      FREE (msg);
+      GNUNET_free (msg);
       GE_LOG (ectx,
               GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
               _("UDP: Could not determine my public IP address.\n"));
@@ -295,7 +299,7 @@
       GE_LOG (ectx,
               GE_DEBUG | GE_USER | GE_BULK,
               "UDP uses IP address %u.%u.%u.%u.\n",
-              PRIP (ntohl (*(int *) &haddr->ip)));
+              GNUNET_PRIP (ntohl (*(int *) &haddr->ip)));
       last_addr = *haddr;
     }
   msg->senderAddressSize = htons (sizeof (HostAddress));
@@ -307,17 +311,17 @@
 /**
  * Send a message to the specified remote node.
  *
- * @param tsession the P2P_hello_MESSAGE identifying the remote node
+ * @param tsession the GNUNET_MessageHello identifying the remote node
  * @param message what to send
  * @param size the size of the message
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 static int
 udpSend (TSession * tsession,
          const void *message, const unsigned int size, int important)
 {
   UDPMessage *mp;
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
   HostAddress *haddr;
   struct sockaddr_in sin;       /* an Internet endpoint address */
   int ok;
@@ -326,53 +330,55 @@
 
   GE_ASSERT (NULL, tsession != NULL);
   if (udp_sock == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   if (size == 0)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (size > udpAPI.mtu)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  hello = (P2P_hello_MESSAGE *) tsession->internal;
+  hello = (GNUNET_MessageHello *) tsession->internal;
   if (hello == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
 
   haddr = (HostAddress *) & hello[1];
   ssize = size + sizeof (UDPMessage);
-  mp = MALLOC (ssize);
+  mp = GNUNET_malloc (ssize);
   mp->header.size = htons (ssize);
   mp->header.type = 0;
   mp->sender = *(coreAPI->myIdentity);
   memcpy (&mp[1], message, size);
-  ok = SYSERR;
+  ok = GNUNET_SYSERR;
   memset (&sin, 0, sizeof (sin));
   sin.sin_family = AF_INET;
   sin.sin_port = haddr->port;
 
-  GE_ASSERT (ectx, sizeof (struct in_addr) == sizeof (IPaddr));
-  memcpy (&sin.sin_addr, &haddr->ip, sizeof (IPaddr));
+  GE_ASSERT (ectx, sizeof (struct in_addr) == sizeof (GNUNET_IPv4Address));
+  memcpy (&sin.sin_addr, &haddr->ip, sizeof (GNUNET_IPv4Address));
 #if DEBUG_UDP
   GE_LOG (ectx,
           GE_DEBUG | GE_USER | GE_BULK,
           "Sending message of %d bytes via UDP to %u.%u.%u.%u:%u.\n",
-          ssize, PRIP (ntohl (*(int *) &sin.sin_addr)), ntohs (sin.sin_port));
+          ssize, GNUNET_PRIP (ntohl (*(int *) &sin.sin_addr)),
+          ntohs (sin.sin_port));
 #endif
 #ifndef MINGW
-  if (YES == socket_send_to (udp_sock,
-                             NC_Nonblocking,
-                             mp,
-                             ssize, &sent, (const char *) &sin, sizeof (sin)))
+  if (GNUNET_YES == GNUNET_socket_send_to (udp_sock,
+                                           GNUNET_NC_NONBLOCKING,
+                                           mp,
+                                           ssize, &sent, (const char *) &sin,
+                                           sizeof (sin)))
 #else
   sent =
     win_ols_sendto (udp_sock, mp, ssize, (const char *) &sin, sizeof (sin));
   if (sent != SOCKET_ERROR)
 #endif
     {
-      ok = OK;
+      ok = GNUNET_OK;
       if (stats != NULL)
         stats->change (stat_bytesSent, sent);
     }
@@ -382,19 +388,19 @@
               GE_WARNING | GE_ADMIN | GE_BULK,
               _
               ("Failed to send message of size %d via UDP to %u.%u.%u.%u:%u: 
%s\n"),
-              ssize, PRIP (ntohl (*(int *) &sin.sin_addr)),
+              ssize, GNUNET_PRIP (ntohl (*(int *) &sin.sin_addr)),
               ntohs (sin.sin_port), STRERROR (errno));
       if (stats != NULL)
         stats->change (stat_bytesDropped, ssize);
     }
-  FREE (mp);
+  GNUNET_free (mp);
   return ok;
 }
 
 /**
  * Start the server process to receive inbound traffic.
  *
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
 startTransportServer ()
@@ -409,16 +415,17 @@
     {
       sock = listensock (port);
       if (sock == -1)
-        return SYSERR;
-      selector = select_create ("udp", YES, ectx, load_monitor, sock, sizeof 
(struct sockaddr_in), 0,   /* timeout */
-                                &select_message_handler,
-                                NULL,
-                                &select_accept_handler,
-                                &isRejected,
-                                &select_close_handler,
-                                NULL, 64 * 1024, 16 /* max sockets */ );
+        return GNUNET_SYSERR;
+      selector = GNUNET_select_create ("udp", GNUNET_YES, ectx, load_monitor, 
sock, sizeof (struct sockaddr_in), 0,     /* timeout */
+                                       &select_message_handler,
+                                       NULL,
+                                       &select_accept_handler,
+                                       &isRejected,
+                                       &select_close_handler,
+                                       NULL, 64 * 1024,
+                                       16 /* max sockets */ );
       if (selector == NULL)
-        return SYSERR;
+        return GNUNET_SYSERR;
     }
 #ifndef MINGW
   sock = SOCKET (PF_INET, SOCK_DGRAM, 17);
@@ -428,13 +435,13 @@
   if (sock == -1)
     {
       GE_LOG_STRERROR (ectx, GE_ERROR | GE_ADMIN | GE_BULK, "socket");
-      select_destroy (selector);
+      GNUNET_select_destroy (selector);
       selector = NULL;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   udp_sock = socket_create (ectx, load_monitor, sock);
   GE_ASSERT (ectx, udp_sock != NULL);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -445,21 +452,21 @@
 {
   char *ch;
 
-  MUTEX_LOCK (configLock);
-  FREENONNULL (filteredNetworks_);
-  FREENONNULL (allowedNetworks_);
+  GNUNET_mutex_lock (configLock);
+  GNUNET_free_non_null (filteredNetworks_);
+  GNUNET_free_non_null (allowedNetworks_);
   ch = NULL;
   GC_get_configuration_value_string (cfg, "UDP", "BLACKLIST", "", &ch);
-  filteredNetworks_ = parse_ipv4_network_specification (ectx, ch);
-  FREE (ch);
+  filteredNetworks_ = GNUNET_parse_ipv4_network_specification (ectx, ch);
+  GNUNET_free (ch);
   ch = NULL;
   GC_get_configuration_value_string (cfg, "UDP", "WHITELIST", "", &ch);
   if (strlen (ch) > 0)
-    allowedNetworks_ = parse_ipv4_network_specification (ectx, ch);
+    allowedNetworks_ = GNUNET_parse_ipv4_network_specification (ectx, ch);
   else
     allowedNetworks_ = NULL;
-  FREE (ch);
-  MUTEX_UNLOCK (configLock);
+  GNUNET_free (ch);
+  GNUNET_mutex_unlock (configLock);
   return 0;
 }
 
@@ -467,20 +474,20 @@
  * Convert UDP hello to IP address
  */
 static int
-helloToAddress (const P2P_hello_MESSAGE * hello,
+helloToAddress (const GNUNET_MessageHello * hello,
                 void **sa, unsigned int *sa_len)
 {
   const HostAddress *haddr = (const HostAddress *) &hello[1];
   struct sockaddr_in *serverAddr;
 
   *sa_len = sizeof (struct sockaddr_in);
-  serverAddr = MALLOC (sizeof (struct sockaddr_in));
+  serverAddr = GNUNET_malloc (sizeof (struct sockaddr_in));
   *sa = serverAddr;
   memset (serverAddr, 0, sizeof (struct sockaddr_in));
   serverAddr->sin_family = AF_INET;
-  memcpy (&serverAddr->sin_addr, haddr, sizeof (IPaddr));
+  memcpy (&serverAddr->sin_addr, haddr, sizeof (GNUNET_IPv4Address));
   serverAddr->sin_port = haddr->port;
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -509,8 +516,9 @@
                                                "MTU",
                                                sizeof (UDPMessage)
                                                + P2P_MESSAGE_OVERHEAD
-                                               + sizeof (MESSAGE_HEADER) + 32,
-                                               65500, MESSAGE_SIZE, &mtu))
+                                               +
+                                               sizeof (GNUNET_MessageHeader) +
+                                               32, 65500, MESSAGE_SIZE, &mtu))
     {
       return NULL;
     }
@@ -518,7 +526,8 @@
     GE_LOG (ectx,
             GE_ERROR | GE_USER | GE_IMMEDIATE,
             _("MTU %llu for `%s' is probably too low!\n"), mtu, "UDP");
-  if (GC_get_configuration_value_yesno (cfg, "UDP", "UPNP", YES) == YES)
+  if (GC_get_configuration_value_yesno (cfg, "UDP", "UPNP", GNUNET_YES) ==
+      GNUNET_YES)
     {
       upnp = coreAPI->requestService ("upnp");
 
@@ -539,7 +548,7 @@
       stat_udpConnected
         = stats->create (gettext_noop ("# UDP connections (right now)"));
     }
-  configLock = MUTEX_CREATE (NO);
+  configLock = GNUNET_mutex_create (GNUNET_NO);
   reloadConfiguration ();
   udpAPI.protocolNumber = UDP_PROTOCOL_NUMBER;
   udpAPI.mtu = mtu - sizeof (UDPMessage);
@@ -571,9 +580,9 @@
       coreAPI->releaseService (upnp);
       upnp = NULL;
     }
-  MUTEX_DESTROY (configLock);
+  GNUNET_mutex_destroy (configLock);
   configLock = NULL;
-  FREENONNULL (filteredNetworks_);
+  GNUNET_free_non_null (filteredNetworks_);
   coreAPI = NULL;
 }
 

Modified: GNUnet/src/transports/udp6.c
===================================================================
--- GNUnet/src/transports/udp6.c        2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/udp6.c        2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,7 +32,7 @@
 #include "ip.h"
 #include "ip6.h"
 
-#define DEBUG_UDP6 NO
+#define DEBUG_UDP6 GNUNET_NO
 
 #include "udp_helper.c"
 
@@ -44,7 +44,7 @@
   /**
    * claimed IP of the sender, network byte order
    */
-  IP6addr ip;
+  GNUNET_IPv6Address ip;
 
   /**
    * claimed port of the sender, network byte order
@@ -62,13 +62,13 @@
 
 static struct GC_Configuration *cfg;
 
-static struct LoadMonitor *load_monitor;
+static struct GNUNET_LoadMonitor *load_monitor;
 
-static struct CIDR6Network *filteredNetworks_;
+static struct GNUNET_IPv6NetworkSet *filteredNetworks_;
 
-static struct CIDR6Network *allowedNetworks_;
+static struct GNUNET_IPv6NetworkSet *allowedNetworks_;
 
-static struct MUTEX *configLock;
+static struct GNUNET_Mutex *configLock;
 
 /**
  * Get the GNUnet UDP6 port from the configuration, or from
@@ -114,7 +114,7 @@
       memset (&sin, 0, sizeof (sin));
       sin.sin6_family = AF_INET6;
       sin.sin6_port = htons (port);
-      memcpy (&sin.sin6_addr, &in6addr_any, sizeof (IP6addr));
+      memcpy (&sin.sin6_addr, &in6addr_any, sizeof (GNUNET_IPv6Address));
       if (BIND (sock, (struct sockaddr *) &sin, sizeof (sin)) < 0)
         {
           GE_LOG_STRERROR (ectx, GE_FATAL | GE_ADMIN | GE_IMMEDIATE, "bind");
@@ -133,25 +133,26 @@
 static int
 isBlacklisted (const void *addr, unsigned int addr_len)
 {
-  IP6addr ip;
+  GNUNET_IPv6Address ip;
   int ret;
 
-  if (addr_len == sizeof (IP6addr))
+  if (addr_len == sizeof (GNUNET_IPv6Address))
     {
-      memcpy (&ip, addr, sizeof (IP6addr));
+      memcpy (&ip, addr, sizeof (GNUNET_IPv6Address));
     }
   else if (addr_len == sizeof (struct sockaddr_in6))
     {
       memcpy (&ip,
-              &((struct sockaddr_in6 *) addr)->sin6_addr, sizeof (IP6addr));
+              &((struct sockaddr_in6 *) addr)->sin6_addr,
+              sizeof (GNUNET_IPv6Address));
     }
   else
     {
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  MUTEX_LOCK (configLock);
-  ret = check_ipv6_listed (filteredNetworks_, ip);
-  MUTEX_UNLOCK (configLock);
+  GNUNET_mutex_lock (configLock);
+  ret = GNUNET_check_ipv6_listed (filteredNetworks_, ip);
+  GNUNET_mutex_unlock (configLock);
   return ret;
 }
 
@@ -161,27 +162,28 @@
 static int
 isWhitelisted (const void *addr, unsigned int addr_len)
 {
-  IP6addr ip;
+  GNUNET_IPv6Address ip;
   int ret;
 
-  if (addr_len == sizeof (IP6addr))
+  if (addr_len == sizeof (GNUNET_IPv6Address))
     {
-      memcpy (&ip, addr, sizeof (IP6addr));
+      memcpy (&ip, addr, sizeof (GNUNET_IPv6Address));
     }
   else if (addr_len == sizeof (struct sockaddr_in6))
     {
       memcpy (&ip,
-              &((struct sockaddr_in6 *) addr)->sin6_addr, sizeof (IP6addr));
+              &((struct sockaddr_in6 *) addr)->sin6_addr,
+              sizeof (GNUNET_IPv6Address));
     }
   else
     {
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  ret = OK;
-  MUTEX_LOCK (configLock);
+  ret = GNUNET_OK;
+  GNUNET_mutex_lock (configLock);
   if (allowedNetworks_ != NULL)
-    ret = check_ipv6_listed (filteredNetworks_, ip);
-  MUTEX_UNLOCK (configLock);
+    ret = GNUNET_check_ipv6_listed (filteredNetworks_, ip);
+  GNUNET_mutex_unlock (configLock);
   return ret;
 }
 
@@ -189,11 +191,11 @@
 static int
 isRejected (const void *addr, unsigned int addr_len)
 {
-  if ((YES == isBlacklisted (addr,
-                             addr_len)) ||
-      (YES != isWhitelisted (addr, addr_len)))
-    return YES;
-  return NO;
+  if ((GNUNET_YES == isBlacklisted (addr,
+                                    addr_len)) ||
+      (GNUNET_YES != isWhitelisted (addr, addr_len)))
+    return GNUNET_YES;
+  return GNUNET_NO;
 }
 
 
@@ -206,21 +208,21 @@
  *
  * @param hello the hello message to verify
  *        (the signature/crc have been verified before)
- * @return OK on success, SYSERR on failure
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
 static int
-verifyHello (const P2P_hello_MESSAGE * hello)
+verifyHello (const GNUNET_MessageHello * hello)
 {
   Host6Address *haddr;
 
   haddr = (Host6Address *) & hello[1];
   if ((ntohs (hello->senderAddressSize) != sizeof (Host6Address)) ||
-      (ntohs (hello->header.size) != P2P_hello_MESSAGE_size (hello)) ||
+      (ntohs (hello->header.size) != GNUNET_sizeof_hello (hello)) ||
       (ntohs (hello->header.type) != p2p_PROTO_hello) ||
-      (YES == isBlacklisted (&haddr->ip,
-                             sizeof (IP6addr))) ||
-      (YES != isWhitelisted (&haddr->ip, sizeof (IP6addr))))
-    return SYSERR;              /* obviously invalid */
+      (GNUNET_YES == isBlacklisted (&haddr->ip,
+                                    sizeof (GNUNET_IPv6Address))) ||
+      (GNUNET_YES != isWhitelisted (&haddr->ip, sizeof (GNUNET_IPv6Address))))
+    return GNUNET_SYSERR;       /* obviously invalid */
   else
     {
 #if DEBUG_UDP6
@@ -231,21 +233,21 @@
                          &haddr->ip,
                          inet6, INET6_ADDRSTRLEN), ntohs (haddr->port));
 #endif
-      return OK;
+      return GNUNET_OK;
     }
 }
 
 /**
  * Create a hello-Message for the current node. The hello is created
  * without signature and without a timestamp. The GNUnet core will
- * sign the message and add an expiration time.
+ * GNUNET_RSA_sign the message and add an expiration time.
  *
  * @return hello on success, NULL on error
  */
-static P2P_hello_MESSAGE *
+static GNUNET_MessageHello *
 createhello ()
 {
-  P2P_hello_MESSAGE *msg;
+  GNUNET_MessageHello *msg;
   Host6Address *haddr;
   unsigned short port;
 
@@ -253,12 +255,12 @@
   if (port == 0)
     return NULL;                /* UDP6 transport configured send-only */
 
-  msg = MALLOC (sizeof (P2P_hello_MESSAGE) + sizeof (Host6Address));
+  msg = GNUNET_malloc (sizeof (GNUNET_MessageHello) + sizeof (Host6Address));
   haddr = (Host6Address *) & msg[1];
 
-  if (SYSERR == getPublicIP6Address (cfg, ectx, &haddr->ip))
+  if (GNUNET_SYSERR == getPublicIP6Address (cfg, ectx, &haddr->ip))
     {
-      FREE (msg);
+      GNUNET_free (msg);
       GE_LOG (ectx,
               GE_WARNING,
               _("UDP6: Could not determine my public IPv6 address.\n"));
@@ -275,17 +277,17 @@
 /**
  * Send a message to the specified remote node.
  *
- * @param tsession the P2P_hello_MESSAGE identifying the remote node
+ * @param tsession the GNUNET_MessageHello identifying the remote node
  * @param message what to send
  * @param size the size of the message
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 static int
 udp6Send (TSession * tsession,
           const void *message, const unsigned int size, int importance)
 {
   UDPMessage *mp;
-  P2P_hello_MESSAGE *hello;
+  GNUNET_MessageHello *hello;
   Host6Address *haddr;
   struct sockaddr_in6 sin;      /* an Internet endpoint address */
   int ok;
@@ -295,33 +297,33 @@
 #endif
 
   if (udp_sock == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   if (size == 0)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (size > udpAPI.mtu)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  hello = (P2P_hello_MESSAGE *) tsession->internal;
+  hello = (GNUNET_MessageHello *) tsession->internal;
   if (hello == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
 
   haddr = (Host6Address *) & hello[1];
   ssize = size + sizeof (UDPMessage);
-  mp = MALLOC (ssize);
+  mp = GNUNET_malloc (ssize);
   mp->header.size = htons (ssize);
   mp->header.type = 0;
   mp->sender = *coreAPI->myIdentity;
   memcpy (&mp[1], message, size);
-  ok = SYSERR;
+  ok = GNUNET_SYSERR;
   memset (&sin, 0, sizeof (sin));
   sin.sin6_family = AF_INET6;
   sin.sin6_port = haddr->port;
-  memcpy (&sin.sin6_addr, &haddr->ip.addr, sizeof (IP6addr));
+  memcpy (&sin.sin6_addr, &haddr->ip.addr, sizeof (GNUNET_IPv6Address));
 #if DEBUG_UDP6
   GE_LOG (ectx,
           GE_DEBUG,
@@ -330,13 +332,14 @@
           inet_ntop (AF_INET6,
                      &sin, inet6, INET6_ADDRSTRLEN), ntohs (sin.sin_port));
 #endif
-  if (YES == socket_send_to (udp_sock,
-                             NC_Nonblocking,
-                             mp,
-                             ssize,
-                             &ssize, (const char *) &sin, sizeof (sin)))
+  if (GNUNET_YES == GNUNET_socket_send_to (udp_sock,
+                                           GNUNET_NC_NONBLOCKING,
+                                           mp,
+                                           ssize,
+                                           &ssize, (const char *) &sin,
+                                           sizeof (sin)))
     {
-      ok = OK;
+      ok = GNUNET_OK;
       if (stats != NULL)
         stats->change (stat_bytesSent, ssize);
     }
@@ -346,14 +349,14 @@
       if (stats != NULL)
         stats->change (stat_bytesDropped, ssize);
     }
-  FREE (mp);
+  GNUNET_free (mp);
   return ok;
 }
 
 /**
  * Start the server process to receive inbound traffic.
  *
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
 startTransportServer ()
@@ -367,27 +370,28 @@
     {
       sock = passivesock (port);
       if (sock == -1)
-        return SYSERR;
-      selector = select_create ("udp6", YES, ectx, load_monitor, sock, sizeof 
(struct sockaddr_in6), 0, /* timeout */
-                                &select_message_handler,
-                                NULL,
-                                &select_accept_handler,
-                                &isRejected,
-                                &select_close_handler,
-                                NULL, 64 * 1024, 16 /* max sockets */ );
+        return GNUNET_SYSERR;
+      selector = GNUNET_select_create ("udp6", GNUNET_YES, ectx, load_monitor, 
sock, sizeof (struct sockaddr_in6), 0,   /* timeout */
+                                       &select_message_handler,
+                                       NULL,
+                                       &select_accept_handler,
+                                       &isRejected,
+                                       &select_close_handler,
+                                       NULL, 64 * 1024,
+                                       16 /* max sockets */ );
       if (selector == NULL)
-        return SYSERR;
+        return GNUNET_SYSERR;
     }
   sock = SOCKET (PF_INET, SOCK_DGRAM, 17);
   if (sock == -1)
     {
       GE_LOG_STRERROR (ectx, GE_ERROR | GE_ADMIN | GE_BULK, "socket");
-      select_destroy (selector);
+      GNUNET_select_destroy (selector);
       selector = NULL;
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   udp_sock = socket_create (ectx, load_monitor, sock);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -398,18 +402,18 @@
 {
   char *ch;
 
-  MUTEX_LOCK (configLock);
-  FREENONNULL (filteredNetworks_);
+  GNUNET_mutex_lock (configLock);
+  GNUNET_free_non_null (filteredNetworks_);
   GC_get_configuration_value_string (cfg, "UDP6", "BLACKLIST", "", &ch);
-  filteredNetworks_ = parse_ipv6_network_specification (ectx, ch);
-  FREE (ch);
+  filteredNetworks_ = GNUNET_parse_ipv6_network_specification (ectx, ch);
+  GNUNET_free (ch);
   GC_get_configuration_value_string (cfg, "UDP6", "WHITELIST", "", &ch);
   if (strlen (ch) > 0)
-    allowedNetworks_ = parse_ipv6_network_specification (ectx, ch);
+    allowedNetworks_ = GNUNET_parse_ipv6_network_specification (ectx, ch);
   else
     allowedNetworks_ = NULL;
-  FREE (ch);
-  MUTEX_UNLOCK (configLock);
+  GNUNET_free (ch);
+  GNUNET_mutex_unlock (configLock);
   return 0;
 }
 
@@ -417,20 +421,20 @@
  * Convert UDP6 hello to IPv6 address
  */
 static int
-helloToAddress (const P2P_hello_MESSAGE * hello,
+helloToAddress (const GNUNET_MessageHello * hello,
                 void **sa, unsigned int *sa_len)
 {
   const Host6Address *haddr = (const Host6Address *) &hello[1];
   struct sockaddr_in6 *serverAddr;
 
   *sa_len = sizeof (struct sockaddr_in6);
-  serverAddr = MALLOC (sizeof (struct sockaddr_in6));
+  serverAddr = GNUNET_malloc (sizeof (struct sockaddr_in6));
   *sa = serverAddr;
   memset (serverAddr, 0, sizeof (struct sockaddr_in6));
   serverAddr->sin6_family = AF_INET6;
-  memcpy (&serverAddr->sin6_addr, haddr, sizeof (IP6addr));
+  memcpy (&serverAddr->sin6_addr, haddr, sizeof (GNUNET_IPv6Address));
   serverAddr->sin6_port = haddr->port;
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -452,7 +456,7 @@
   coreAPI = core;
   ectx = core->ectx;
   cfg = core->cfg;
-  configLock = MUTEX_CREATE (NO);
+  configLock = GNUNET_mutex_create (GNUNET_NO);
 
   reloadConfiguration ();
   if (-1 == GC_get_configuration_value_number (cfg,
@@ -460,8 +464,8 @@
                                                "MTU",
                                                sizeof (UDPMessage) +
                                                P2P_MESSAGE_OVERHEAD +
-                                               sizeof (MESSAGE_HEADER) + 32,
-                                               65500, MESSAGE_SIZE, &mtu))
+                                               sizeof (GNUNET_MessageHeader) +
+                                               32, 65500, MESSAGE_SIZE, &mtu))
     {
       return NULL;
     }
@@ -505,8 +509,8 @@
       coreAPI->releaseService (stats);
       stats = NULL;
     }
-  MUTEX_DESTROY (configLock);
-  FREENONNULL (filteredNetworks_);
+  GNUNET_mutex_destroy (configLock);
+  GNUNET_free_non_null (filteredNetworks_);
 }
 
 /* end of udp6.c */

Modified: GNUnet/src/transports/udp_helper.c
===================================================================
--- GNUnet/src/transports/udp_helper.c  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/udp_helper.c  2007-11-23 11:51:54 UTC (rev 5742)
@@ -34,12 +34,12 @@
   /**
    * size of the message, in bytes, including this header.
    */
-  MESSAGE_HEADER header;
+  GNUNET_MessageHeader header;
 
   /**
-   * What is the identity of the sender (hash of public key)
+   * What is the identity of the sender (GNUNET_hash of public key)
    */
-  PeerIdentity sender;
+  GNUNET_PeerIdentity sender;
 
 } UDPMessage;
 
@@ -64,12 +64,12 @@
 /**
  * thread that listens for inbound messages
  */
-static struct SelectHandle *selector;
+static struct GNUNET_SelectHandle *selector;
 
 /**
  * the socket that we transmit all data with
  */
-static struct SocketHandle *udp_sock;
+static struct GNUNET_SocketHandle *udp_sock;
 
 /**
  * The socket of session has data waiting, process!
@@ -79,9 +79,9 @@
  */
 static int
 select_message_handler (void *mh_cls,
-                        struct SelectHandle *sh,
-                        struct SocketHandle *sock,
-                        void *sock_ctx, const MESSAGE_HEADER * msg)
+                        struct GNUNET_SelectHandle *sh,
+                        struct GNUNET_SocketHandle *sock,
+                        void *sock_ctx, const GNUNET_MessageHeader * msg)
 {
   unsigned int len;
   P2P_PACKET *mp;
@@ -94,15 +94,15 @@
               GE_WARNING | GE_USER | GE_BULK,
               _
               ("Received malformed message from udp-peer connection. 
Closing.\n"));
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 #if DEBUG_UDP
   GE_LOG (ectx,
           GE_DEBUG | GE_USER | GE_BULK, "Received %d bytes via UDP\n", len);
 #endif
   um = (const UDPMessage *) msg;
-  mp = MALLOC (sizeof (P2P_PACKET));
-  mp->msg = MALLOC (len - sizeof (UDPMessage));
+  mp = GNUNET_malloc (sizeof (P2P_PACKET));
+  mp->msg = GNUNET_malloc (len - sizeof (UDPMessage));
   memcpy (mp->msg, &um[1], len - sizeof (UDPMessage));
   mp->sender = um->sender;
   mp->size = len - sizeof (UDPMessage);
@@ -110,18 +110,18 @@
   coreAPI->receive (mp);
   if (stats != NULL)
     stats->change (stat_bytesReceived, len);
-  return OK;
+  return GNUNET_OK;
 }
 
 static void *
 select_accept_handler (void *ah_cls,
-                       struct SelectHandle *sh,
-                       struct SocketHandle *sock,
+                       struct GNUNET_SelectHandle *sh,
+                       struct GNUNET_SocketHandle *sock,
                        const void *addr, unsigned int addr_len)
 {
   static int nonnullpointer;
   BlacklistedTester blt = ah_cls;
-  if (NO != blt (addr, addr_len))
+  if (GNUNET_NO != blt (addr, addr_len))
     return NULL;
   return &nonnullpointer;
 }
@@ -132,8 +132,8 @@
  */
 static void
 select_close_handler (void *ch_cls,
-                      struct SelectHandle *sh,
-                      struct SocketHandle *sock, void *sock_ctx)
+                      struct GNUNET_SelectHandle *sh,
+                      struct GNUNET_SocketHandle *sock, void *sock_ctx)
 {
   /* do nothing */
 }
@@ -143,24 +143,24 @@
  *
  * @param hello the hello-Message for the target node
  * @param tsessionPtr the session handle that is to be set
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
-udpConnect (const P2P_hello_MESSAGE * hello, TSession ** tsessionPtr,
+udpConnect (const GNUNET_MessageHello * hello, TSession ** tsessionPtr,
             int may_reuse)
 {
   TSession *tsession;
 
-  tsession = MALLOC (sizeof (TSession));
+  tsession = GNUNET_malloc (sizeof (TSession));
   memset (tsession, 0, sizeof (TSession));
-  tsession->internal = MALLOC (P2P_hello_MESSAGE_size (hello));
-  memcpy (tsession->internal, hello, P2P_hello_MESSAGE_size (hello));
+  tsession->internal = GNUNET_malloc (GNUNET_sizeof_hello (hello));
+  memcpy (tsession->internal, hello, GNUNET_sizeof_hello (hello));
   tsession->ttype = udpAPI.protocolNumber;
   tsession->peer = hello->senderIdentity;
   *tsessionPtr = tsession;
   if (stats != NULL)
     stats->change (stat_udpConnected, 1);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -171,20 +171,20 @@
  * @param tsession the session handle passed along
  *   from the call to receive that was made by the transport
  *   layer
- * @return OK if the session could be associated,
- *         SYSERR if not.
+ * @return GNUNET_OK if the session could be associated,
+ *         GNUNET_SYSERR if not.
  */
 int
 udpAssociate (TSession * tsession)
 {
-  return SYSERR;                /* UDP connections can never be associated */
+  return GNUNET_SYSERR;         /* UDP connections can never be associated */
 }
 
 /**
  * Disconnect from a remote node.
  *
  * @param tsession the session that is closed
- * @return OK on success, SYSERR if the operation failed
+ * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed
  */
 static int
 udpDisconnect (TSession * tsession)
@@ -192,12 +192,12 @@
   if (tsession != NULL)
     {
       if (tsession->internal != NULL)
-        FREE (tsession->internal);
-      FREE (tsession);
+        GNUNET_free (tsession->internal);
+      GNUNET_free (tsession);
       if (stats != NULL)
         stats->change (stat_udpConnected, -1);
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -210,12 +210,12 @@
   GE_ASSERT (ectx, udp_sock != NULL);
   if (selector != NULL)
     {
-      select_destroy (selector);
+      GNUNET_select_destroy (selector);
       selector = NULL;
     }
-  socket_destroy (udp_sock);
+  GNUNET_socket_destroy (udp_sock);
   udp_sock = NULL;
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -226,32 +226,32 @@
  * even bother to construct (and encrypt) this kind
  * of message.
  *
- * @return YES if the transport would try (i.e. queue
+ * @return GNUNET_YES if the transport would try (i.e. queue
  *         the message or call the OS to send),
- *         NO if the transport would just drop the message,
- *         SYSERR if the size/session is invalid
+ *         GNUNET_NO if the transport would just drop the message,
+ *         GNUNET_SYSERR if the size/session is invalid
  */
 static int
 testWouldTry (TSession * tsession, unsigned int size, int important)
 {
-  const P2P_hello_MESSAGE *hello;
+  const GNUNET_MessageHello *hello;
 
   if (udp_sock == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   if (size == 0)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (size > udpAPI.mtu)
     {
       GE_BREAK (ectx, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  hello = (const P2P_hello_MESSAGE *) tsession->internal;
+  hello = (const GNUNET_MessageHello *) tsession->internal;
   if (hello == NULL)
-    return SYSERR;
-  return YES;
+    return GNUNET_SYSERR;
+  return GNUNET_YES;
 }
 
 

Modified: GNUnet/src/transports/upnp/Makefile.am
===================================================================
--- GNUnet/src/transports/upnp/Makefile.am      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/transports/upnp/Makefile.am      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -24,8 +24,7 @@
  @LIBCURL_CPPFLAGS@ @XML_CPPFLAGS@
 libgnunetmodule_upnp_la_LIBADD = \
  @EXT_LIB_PATH@ @EXT_LIBS@ @XML_LIBS@ @LIBCURL@ \
- $(top_builddir)/src/util/libgnunetutil.la  \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la 
+ $(top_builddir)/src/util/libgnunetutil.la  
 
 check_PROGRAMS = \
  upnptest 
@@ -35,8 +34,6 @@
 upnptest_SOURCES = \
  upnptest.c 
 upnptest_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 

Modified: GNUnet/src/transports/upnp/init.c
===================================================================
--- GNUnet/src/transports/upnp/init.c   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/upnp/init.c   2007-11-23 11:51:54 UTC (rev 5742)
@@ -35,9 +35,9 @@
 
 static struct GC_Configuration *cfg;
 
-static struct CronManager *cron;
+static struct GNUNET_CronManager *cron;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 typedef struct
 {
@@ -49,24 +49,24 @@
 
 static unsigned int maps_size;
 
-static struct PTHREAD *discovery;
+static struct GNUNET_ThreadHandle *discovery;
 
 static int discovery_socket;
 
 /**
  * Obtain the public/external IP address.
  *
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 static int
-gnunet_upnp_get_public_ip (IPaddr * address)
+gnunet_upnp_get_public_ip (GNUNET_IPv4Address * address)
 {
   const char *ip;
 
   ip = gaim_upnp_get_public_ip ();
   if (ip == NULL)
-    return SYSERR;
-  return get_host_by_name (ectx, ip, address);
+    return GNUNET_SYSERR;
+  return GNUNET_get_host_by_name (ectx, ip, address);
 }
 
 static void
@@ -78,7 +78,7 @@
     {
       SHUTDOWN (discovery_socket, SHUT_RDWR);
       CLOSE (discovery_socket);
-      PTHREAD_JOIN (discovery, &unused);
+      GNUNET_thread_join (discovery, &unused);
       discovery = NULL;
     }
 }
@@ -100,7 +100,7 @@
   discovery_socket = SOCKET (PF_INET, SOCK_DGRAM, 0);
   if (discovery_socket == -1)
     return;
-  discovery = PTHREAD_CREATE (&discover_thread, NULL, 1024 * 128);
+  discovery = GNUNET_thread_create (&discover_thread, NULL, 1024 * 128);
 }
 
 /**
@@ -111,38 +111,39 @@
 {
   unsigned int i;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < maps_size; i++)
     gaim_upnp_change_port_mapping (ectx,
-                                   cfg, NO, maps[i].port, maps[i].proto);
-  MUTEX_UNLOCK (lock);
+                                   cfg, GNUNET_NO, maps[i].port,
+                                   maps[i].proto);
+  GNUNET_mutex_unlock (lock);
 }
 
 
 /**
  * Get the external IP address for the local machine.
  *
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 static int
 gnunet_upnp_get_ip (unsigned short port,
-                    const char *protocol, IPaddr * address)
+                    const char *protocol, GNUNET_IPv4Address * address)
 {
   unsigned int i;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < maps_size; i++)
     if ((0 == strcmp (maps[i].proto, protocol)) && (maps[i].port == port))
       break;
   if (i == maps_size)
     {
       /* new entry! */
-      GROW (maps, maps_size, maps_size + 1);
+      GNUNET_array_grow (maps, maps_size, maps_size + 1);
       maps[i].proto = protocol;
       maps[i].port = port;
-      gaim_upnp_change_port_mapping (ectx, cfg, YES, port, protocol);
+      gaim_upnp_change_port_mapping (ectx, cfg, GNUNET_YES, port, protocol);
     }
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return gnunet_upnp_get_public_ip (address);
 }
 
@@ -158,10 +159,11 @@
   ectx = capi->ectx;
   cfg = capi->cfg;
   cron = cron_create (ectx);
-  lock = MUTEX_CREATE (NO);
-  cron_start (cron);
-  cron_add_job (cron, &discover, 0, 5 * cronMINUTES, NULL);
-  cron_add_job (cron, &portmap, 150 * cronSECONDS, 5 * cronMINUTES, NULL);
+  lock = GNUNET_mutex_create (GNUNET_NO);
+  GNUNET_cron_start (cron);
+  GNUNET_cron_add_job (cron, &discover, 0, 5 * GNUNET_CRON_MINUTES, NULL);
+  GNUNET_cron_add_job (cron, &portmap, 150 * GNUNET_CRON_SECONDS,
+                       5 * GNUNET_CRON_MINUTES, NULL);
   api.get_ip = gnunet_upnp_get_ip;
   return &api;
 }
@@ -175,22 +177,23 @@
   unsigned int i;
 
   if (cron == NULL)
-    return SYSERR;              /* not loaded! */
+    return GNUNET_SYSERR;       /* not loaded! */
   for (i = 0; i < maps_size; i++)
     gaim_upnp_change_port_mapping (ectx,
-                                   cfg, NO, maps[i].port, maps[i].proto);
-  cron_stop (cron);
-  cron_del_job (cron, &discover, 5 * cronMINUTES, NULL);
-  cron_del_job (cron, &portmap, 5 * cronMINUTES, NULL);
-  cron_destroy (cron);
+                                   cfg, GNUNET_NO, maps[i].port,
+                                   maps[i].proto);
+  GNUNET_cron_stop (cron);
+  GNUNET_cron_del_job (cron, &discover, 5 * GNUNET_CRON_MINUTES, NULL);
+  GNUNET_cron_del_job (cron, &portmap, 5 * GNUNET_CRON_MINUTES, NULL);
+  GNUNET_cron_destroy (cron);
   kill_discovery ();
   cron = NULL;
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   lock = NULL;
-  GROW (maps, maps_size, 0);
+  GNUNET_array_grow (maps, maps_size, 0);
   ectx = NULL;
   cfg = NULL;
-  return OK;
+  return GNUNET_OK;
 }
 
 

Modified: GNUnet/src/transports/upnp/ip.c
===================================================================
--- GNUnet/src/transports/upnp/ip.c     2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/upnp/ip.c     2007-11-23 11:51:54 UTC (rev 5742)
@@ -38,9 +38,9 @@
 gaim_upnp_get_internal_ip (struct GC_Configuration *cfg,
                            struct GE_Context *ectx)
 {
-  IPaddr address;
+  GNUNET_IPv4Address address;
 
-  return network_get_local_ip (cfg, ectx, &address);
+  return GNUNET_get_local_ip (cfg, ectx, &address);
 }
 
 

Modified: GNUnet/src/transports/upnp/upnp.c
===================================================================
--- GNUnet/src/transports/upnp/upnp.c   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/upnp/upnp.c   2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,8 +32,8 @@
 
 #include <curl/curl.h>
 
-#define TRUE YES
-#define FALSE NO
+#define TRUE GNUNET_YES
+#define FALSE GNUNET_NO
 #define g_return_if_fail(a) if(!(a)) return;
 #define g_return_val_if_fail(a, val) if(!(a)) return (val);
 
@@ -172,7 +172,7 @@
     return FALSE;
   tmp = xmlnode_get_data (deviceTypeNode);
   ret = !strcasecmp (tmp, deviceType);
-  FREE (tmp);
+  GNUNET_free (tmp);
   return ret;
 }
 
@@ -190,7 +190,7 @@
     return FALSE;
   tmp = xmlnode_get_data (serviceTypeNode);
   ret = !strcasecmp (tmp, serviceType);
-  FREE (tmp);
+  GNUNET_free (tmp);
   return ret;
 }
 
@@ -224,7 +224,7 @@
     }
   else
     {
-      baseURL = STRDUP (httpURL);
+      baseURL = GNUNET_strdup (httpURL);
     }
 
   /* get the serviceType child that has the service type as its data */
@@ -238,14 +238,14 @@
     }
   if (serviceTypeNode == NULL)
     {
-      FREE (baseURL);
+      GNUNET_free (baseURL);
       xmlnode_free (xmlRootNode);
       return NULL;
     }
   serviceTypeNode = xmlnode_get_child (serviceTypeNode, "deviceList");
   if (serviceTypeNode == NULL)
     {
-      FREE (baseURL);
+      GNUNET_free (baseURL);
       xmlnode_free (xmlRootNode);
       return NULL;
     }
@@ -260,14 +260,14 @@
     }
   if (serviceTypeNode == NULL)
     {
-      FREE (baseURL);
+      GNUNET_free (baseURL);
       xmlnode_free (xmlRootNode);
       return NULL;
     }
   serviceTypeNode = xmlnode_get_child (serviceTypeNode, "deviceList");
   if (serviceTypeNode == NULL)
     {
-      FREE (baseURL);
+      GNUNET_free (baseURL);
       xmlnode_free (xmlRootNode);
       return NULL;
     }
@@ -281,14 +281,14 @@
     }
   if (serviceTypeNode == NULL)
     {
-      FREE (baseURL);
+      GNUNET_free (baseURL);
       xmlnode_free (xmlRootNode);
       return NULL;
     }
   serviceTypeNode = xmlnode_get_child (serviceTypeNode, "serviceList");
   if (serviceTypeNode == NULL)
     {
-      FREE (baseURL);
+      GNUNET_free (baseURL);
       xmlnode_free (xmlRootNode);
       return NULL;
     }
@@ -302,10 +302,10 @@
       serviceTypeNode = xmlnode_get_next_twin (serviceTypeNode);
     }
 
-  FREE (service);
+  GNUNET_free (service);
   if (serviceTypeNode == NULL)
     {
-      FREE (baseURL);
+      GNUNET_free (baseURL);
       xmlnode_free (xmlRootNode);
       return NULL;
     }
@@ -314,7 +314,7 @@
   if ((controlURLNode = xmlnode_get_child (serviceTypeNode,
                                            "controlURL")) == NULL)
     {
-      FREE (baseURL);
+      GNUNET_free (baseURL);
       xmlnode_free (xmlRootNode);
       return NULL;
     }
@@ -341,13 +341,13 @@
         {
           controlURL = g_strdup_printf ("%s%s", baseURL, tmp);
         }
-      FREE (tmp);
+      GNUNET_free (tmp);
     }
   else
     {
       controlURL = tmp;
     }
-  FREE (baseURL);
+  GNUNET_free (baseURL);
   xmlnode_free (xmlRootNode);
 
   return controlURL;
@@ -372,7 +372,7 @@
      setting NOSIGNAL results in really weird
      crashes on my system! */
   CURL_EASY_SETOPT (curl, CURLOPT_NOSIGNAL, 1);
-  return OK;
+  return GNUNET_OK;
 }
 
 static int
@@ -391,7 +391,7 @@
 
   GE_ASSERT (NULL, cb != NULL);
   if (0 != curl_global_init (CURL_GLOBAL_WIN32))
-    return SYSERR;
+    return GNUNET_SYSERR;
   /* set the soap message */
   soapMessage = g_strdup_printf (SOAP_ACTION,
                                  actionName,
@@ -434,12 +434,12 @@
   curl_slist_free_all (headers);
   curl_easy_cleanup (curl);
   curl_global_cleanup ();
-  FREE (sizeHeader);
-  FREE (soapMessage);
-  FREE (soapHeader);
+  GNUNET_free (sizeHeader);
+  GNUNET_free (soapMessage);
+  GNUNET_free (soapHeader);
   if (ret != CURLE_OK)
-    return SYSERR;
-  return OK;
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 
@@ -454,7 +454,7 @@
 
   if (len + dd->buf_len > 1024 * 1024 * 4)
     return 0;                   /* refuse to process - too big! */
-  GROW (dd->buf, dd->buf_len, dd->buf_len + len);
+  GNUNET_array_grow (dd->buf, dd->buf_len, dd->buf_len + len);
   memcpy (&dd->buf[dd->buf_len - len], url_data, len);
   if (dd->buf_len == 0)
     return len;
@@ -496,7 +496,7 @@
 
   if (len + dd->buf_len > 1024 * 1024 * 4)
     return len;                 /* refuse to process - too big! */
-  GROW (dd->buf, dd->buf_len, dd->buf_len + len);
+  GNUNET_array_grow (dd->buf, dd->buf_len, dd->buf_len + len);
   memcpy (&dd->buf[dd->buf_len - len], httpResponse, len);
   if (dd->buf_len > 0)
     control_url = gaim_upnp_parse_description_response (dd->buf,
@@ -505,7 +505,7 @@
                                                         dd->service_type);
   control_info.status = control_url ? GAIM_UPNP_STATUS_DISCOVERED
     : GAIM_UPNP_STATUS_UNABLE_TO_DISCOVER;
-  FREENONNULL (control_info.control_url);
+  GNUNET_free_non_null (control_info.control_url);
   control_info.control_url = control_url;
   control_info.service_type = dd->service_type;
   return len;
@@ -518,7 +518,7 @@
   int ret;
 
   if (0 != curl_global_init (CURL_GLOBAL_WIN32))
-    return SYSERR;
+    return GNUNET_SYSERR;
   curl = curl_easy_init ();
   setup_curl (proxy, curl);
   ret = CURLE_OK;
@@ -543,8 +543,8 @@
   curl_easy_cleanup (curl);
   curl_global_cleanup ();
   if (control_info.control_url == NULL)
-    return SYSERR;
-  return OK;
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 int
@@ -567,13 +567,13 @@
 
   memset (&dd, 0, sizeof (UPnPDiscoveryData));
   if (control_info.status == GAIM_UPNP_STATUS_DISCOVERING)
-    return NO;
+    return GNUNET_NO;
   dd.sock = sock;
   hp = gethostbyname (HTTPMU_HOST_ADDRESS);
   if (hp == NULL)
     {
       CLOSE (dd.sock);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   memset (&server, 0, sizeof (struct sockaddr));
   server.sin_family = AF_INET;
@@ -607,13 +607,13 @@
             }
         }
       while (((errno == EINTR) || (errno == EAGAIN)) &&
-             (GNUNET_SHUTDOWN_TEST () == NO));
-      FREE (sendMessage);
+             (GNUNET_shutdown_test () == GNUNET_NO));
+      GNUNET_free (sendMessage);
       if (sentSuccess)
         break;
     }
   if (sentSuccess == FALSE)
-    return SYSERR;
+    return GNUNET_SYSERR;
 
   /* try to read response */
   do
@@ -629,13 +629,13 @@
           continue;
         }
     }
-  while ((errno == EINTR) && (GNUNET_SHUTDOWN_TEST () == NO));
+  while ((errno == EINTR) && (GNUNET_shutdown_test () == GNUNET_NO));
 
   /* parse the response, and see if it was a success */
   if (g_strstr_len (buf, buf_len, HTTP_OK) == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   if ((startDescURL = g_strstr_len (buf, buf_len, "http://";)) == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
 
   endDescURL = g_strstr_len (startDescURL,
                              buf_len - (startDescURL - buf), "\r");
@@ -643,26 +643,27 @@
     endDescURL = g_strstr_len (startDescURL,
                                buf_len - (startDescURL - buf), "\n");
   if (endDescURL == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   if (endDescURL == startDescURL)
-    return SYSERR;
-  dd.full_url = STRNDUP (startDescURL, endDescURL - startDescURL);
+    return GNUNET_SYSERR;
+  dd.full_url = GNUNET_strdup (startDescURL);
+  dd.full_url[endDescURL - startDescURL] = '\0';
   proxy = NULL;
   GC_get_configuration_value_string (cfg,
                                      "GNUNETD", "HTTP-PROXY", "", &proxy);
   ret = gaim_upnp_parse_description (proxy, &dd);
-  FREE (dd.full_url);
-  GROW (dd.buf, dd.buf_len, 0);
-  if (ret == OK)
+  GNUNET_free (dd.full_url);
+  GNUNET_array_grow (dd.buf, dd.buf_len, 0);
+  if (ret == GNUNET_OK)
     {
       ret = gaim_upnp_generate_action_message_and_send (proxy,
                                                         "GetExternalIPAddress",
                                                         "",
                                                         looked_up_public_ip_cb,
                                                         &dd);
-      GROW (dd.buf, dd.buf_len, 0);
+      GNUNET_array_grow (dd.buf, dd.buf_len, 0);
     }
-  FREE (proxy);
+  GNUNET_free (proxy);
   return ret;
 }
 
@@ -688,7 +689,7 @@
   int ret;
 
   if (control_info.status != GAIM_UPNP_STATUS_DISCOVERED)
-    return NO;
+    return GNUNET_NO;
   if (do_add)
     {
       internal_ip = gaim_upnp_get_internal_ip (cfg, ectx);
@@ -696,13 +697,13 @@
         {
           gaim_debug_error ("upnp",
                             "gaim_upnp_set_port_mapping(): couldn't get local 
ip\n");
-          return NO;
+          return GNUNET_NO;
         }
       action_name = "AddPortMapping";
       action_params = g_strdup_printf (ADD_PORT_MAPPING_PARAMS,
                                        portmap,
                                        protocol, portmap, internal_ip);
-      FREE (internal_ip);
+      GNUNET_free (internal_ip);
     }
   else
     {
@@ -718,8 +719,8 @@
                                                     action_params,
                                                     &ignore_response, NULL);
 
-  FREE (action_params);
-  FREE (proxy);
+  GNUNET_free (action_params);
+  GNUNET_free (proxy);
   return ret;
 }
 

Modified: GNUnet/src/transports/upnp/upnp.h
===================================================================
--- GNUnet/src/transports/upnp/upnp.h   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/upnp/upnp.h   2007-11-23 11:51:54 UTC (rev 5742)
@@ -65,7 +65,7 @@
  *
  * @param portmap The port to map to this client
  * @param protocol The protocol to map, either "TCP" or "UDP"
- * @param do_add TRUE/YES to add, FALSE/NO to remove
+ * @param do_add TRUE/GNUNET_YES to add, FALSE/GNUNET_NO to remove
  * @param cb an optional callback function to be notified when the mapping
  *           addition is complete
  * @param cb_data Extra data to be passed to the callback

Modified: GNUnet/src/transports/upnp/upnptest.c
===================================================================
--- GNUnet/src/transports/upnp/upnptest.c       2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/transports/upnp/upnptest.c       2007-11-23 11:51:54 UTC (rev 
5742)
@@ -38,34 +38,34 @@
   static CoreAPIForApplication capi;
   struct GE_Context *ectx;
   struct GC_Configuration *cfg;
-  IPaddr addr;
+  GNUNET_IPv4Address addr;
   int i;
   UPnP_ServiceAPI *upnp;
-  struct PluginHandle *plug;
+  struct GNUNET_PluginHandle *plug;
   ServiceInitMethod init;
   ServiceDoneMethod done;
 
-  ectx = GE_create_context_stderr (NO,
+  ectx = GE_create_context_stderr (GNUNET_NO,
                                    GE_WARNING | GE_ERROR | GE_FATAL |
                                    GE_USER | GE_ADMIN | GE_DEVELOPER |
                                    GE_IMMEDIATE | GE_BULK);
   GE_setDefaultContext (ectx);
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   GE_ASSERT (ectx, cfg != NULL);
-  os_init (ectx);
+  GNUNET_os_init (ectx);
   capi.ectx = ectx;
   capi.cfg = cfg;
-  plug = os_plugin_load (ectx, "libgnunet", "module_upnp");
+  plug = GNUNET_plugin_load (ectx, "libgnunet", "module_upnp");
   if (plug == NULL)
     {
       GC_free (cfg);
       GE_free_context (ectx);
       return 1;
     }
-  init = os_plugin_resolve_function (plug, "provide_", YES);
+  init = GNUNET_plugin_resolve_function (plug, "provide_", GNUNET_YES);
   if (init == NULL)
     {
-      os_plugin_unload (plug);
+      GNUNET_plugin_unload (plug);
       GC_free (cfg);
       GE_free_context (ectx);
       return 1;
@@ -73,16 +73,16 @@
   upnp = init (&capi);
   if (upnp == NULL)
     {
-      os_plugin_unload (plug);
+      GNUNET_plugin_unload (plug);
       GC_free (cfg);
       GE_free_context (ectx);
       return 1;
     }
   for (i = 0; i < 10; i++)
     {
-      if (GNUNET_SHUTDOWN_TEST () != NO)
+      if (GNUNET_shutdown_test () != GNUNET_NO)
         break;
-      if (OK == upnp->get_ip (2086, "TCP", &addr))
+      if (GNUNET_OK == upnp->get_ip (2086, "TCP", &addr))
         {
           printf ("UPnP returned external IP %u.%u.%u.%u\n",
                   PRIP (ntohl (*(int *) &addr)));
@@ -94,12 +94,12 @@
              just because of this! */
           printf ("No UPnP response (yet).\n");
         }
-      PTHREAD_SLEEP (2 * cronSECONDS);
+      GNUNET_thread_sleep (2 * GNUNET_CRON_SECONDS);
     }
-  done = os_plugin_resolve_function (plug, "release_", YES);
+  done = GNUNET_plugin_resolve_function (plug, "release_", GNUNET_YES);
   if (done != NULL)
     done ();
-  os_plugin_unload (plug);
+  GNUNET_plugin_unload (plug);
   GC_free (cfg);
   GE_free_context (ectx);
   return 0;

Modified: GNUnet/src/transports/upnp/util.c
===================================================================
--- GNUnet/src/transports/upnp/util.c   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/transports/upnp/util.c   2007-11-23 11:51:54 UTC (rev 5742)
@@ -59,15 +59,15 @@
            pound != 0 && *(text + 3 + (int) log10 (pound)) == ';')
     {
       char b[7];
-      char *buf = string_convertToUtf8 (NULL,
-                                        (const char *) &pound,
-                                        2,
-                                        "UNICODE");
+      char *buf = GNUNET_convert_string_to_utf8 (NULL,
+                                                 (const char *) &pound,
+                                                 2,
+                                                 "UNICODE");
       if (strlen (buf) > 6)
         buf[6] = '\0';
       strcpy (b, buf);
       pln = b;
-      FREE (buf);
+      GNUNET_free (buf);
       len = 2;
       while (isdigit ((int) text[len]))
         len++;
@@ -79,7 +79,7 @@
 
   if (length)
     *length = len;
-  return STRDUP (pln);
+  return GNUNET_strdup (pln);
 }
 
 char *
@@ -105,7 +105,7 @@
   if (html != NULL)
     {
       const char *c = html;
-      char *ret = STRDUP ("");
+      char *ret = GNUNET_strdup ("");
       char *app;
       while (*c)
         {
@@ -115,22 +115,22 @@
           if ((ent = detect_entity (c, &len)) != NULL)
             {
               app = g_strdup_printf ("%s%s", ret, ent);
-              FREE (ret);
+              GNUNET_free (ret);
               ret = app;
               c += len;
-              FREE (ent);
+              GNUNET_free (ent);
             }
           else if (!strncmp (c, "<br>", 4))
             {
               app = g_strdup_printf ("%s%s", ret, "\n");
-              FREE (ret);
+              GNUNET_free (ret);
               ret = app;
               c += 4;
             }
           else
             {
               app = g_strdup_printf ("%s%c", ret, *c);
-              FREE (ret);
+              GNUNET_free (ret);
               ret = app;
               c++;
             }

Modified: GNUnet/src/transports/upnp/xmlnode.c
===================================================================
--- GNUnet/src/transports/upnp/xmlnode.c        2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/transports/upnp/xmlnode.c        2007-11-23 11:51:54 UTC (rev 
5742)
@@ -43,8 +43,8 @@
 # define NEWLINE_S "\n"
 #endif
 
-#define TRUE YES
-#define FALSE NO
+#define TRUE GNUNET_YES
+#define FALSE GNUNET_NO
 
 #define g_return_if_fail(a) if(!(a)) return;
 #define g_return_val_if_fail(a, val) if(!(a)) return (val);
@@ -79,7 +79,7 @@
   struct _xmlnode *lastchild;  /**< The last child node or @c NULL.*/
   struct _xmlnode *next;        /**< The next node or @c NULL. */
   XMLNodePool *pool;
-  int free_pool;                /* set to YES for the root node, which must 
free the pool */
+  int free_pool;                /* set to GNUNET_YES for the root node, which 
must free the pool */
 };
 
 
@@ -88,7 +88,7 @@
 {
   void *ret;
 
-  ret = MALLOC (s);
+  ret = GNUNET_malloc (s);
   memcpy (ret, data, s);
   return ret;
 }
@@ -99,20 +99,21 @@
   char *ret;
 
   ret = g_strdup_printf ("%s%.*s", prefix, s, data);
-  FREE (prefix);
+  GNUNET_free (prefix);
   return ret;
 }
 
 static xmlnode *
 new_node (const char *name, XMLNodeType type, void *user_data)
 {
-  xmlnode *node = MALLOC (sizeof (xmlnode));
+  xmlnode *node = GNUNET_malloc (sizeof (xmlnode));
 
-  node->name = name == NULL ? NULL : STRDUP (name);
+  node->name = name == NULL ? NULL : GNUNET_strdup (name);
   node->type = type;
   node->pool = user_data;
   if (node->pool->size == node->pool->pos)
-    GROW (node->pool->nodes, node->pool->size, node->pool->size * 2 + 64);
+    GNUNET_array_grow (node->pool->nodes, node->pool->size,
+                       node->pool->size * 2 + 64);
   node->pool->nodes[node->pool->pos++] = node;
   node->free_pool = 0;
   return node;
@@ -211,7 +212,7 @@
   g_return_if_fail (value != NULL);
   xmlnode_remove_attrib (node, attr);
   attrib_node = new_node (attr, XMLNODE_TYPE_ATTRIB, user_data);
-  attrib_node->data = STRDUP (value);
+  attrib_node->data = GNUNET_strdup (value);
   xmlnode_insert_child (node, attrib_node);
 }
 
@@ -219,8 +220,8 @@
 xmlnode_set_namespace (xmlnode * node, const char *xmlns)
 {
   g_return_if_fail (node != NULL);
-  FREENONNULL (node->xmlns);
-  node->xmlns = STRDUP (xmlns);
+  GNUNET_free_non_null (node->xmlns);
+  node->xmlns = GNUNET_strdup (xmlns);
 }
 
 static const char *
@@ -239,20 +240,20 @@
   for (i = 0; i < pool->pos; i++)
     {
       x = pool->nodes[i];
-      FREENONNULL (x->name);
-      FREENONNULL (x->data);
-      FREENONNULL (x->xmlns);
-      FREE (x);
+      GNUNET_free_non_null (x->name);
+      GNUNET_free_non_null (x->data);
+      GNUNET_free_non_null (x->xmlns);
+      GNUNET_free (x);
     }
-  GROW (pool->nodes, pool->size, 0);
-  FREE (pool);
+  GNUNET_array_grow (pool->nodes, pool->size, 0);
+  GNUNET_free (pool);
 }
 
 void
 xmlnode_free (xmlnode * node)
 {
   g_return_if_fail (node != NULL);
-  if (node->free_pool != YES)
+  if (node->free_pool != GNUNET_YES)
     return;
   freePool (node->pool);
 }
@@ -271,7 +272,7 @@
   if (name == NULL)
     return NULL;
 
-  parent_name = STRDUP (name);
+  parent_name = GNUNET_strdup (name);
   child_name = strstr (parent_name, "/");
   if (child_name != NULL)
     {
@@ -298,7 +299,7 @@
   if (child_name && ret)
     ret = xmlnode_get_child (ret, child_name);
 
-  FREE (parent_name);
+  GNUNET_free (parent_name);
   return ret;
 }
 
@@ -321,7 +322,7 @@
       if (c->type == XMLNODE_TYPE_DATA)
         {
           if (!str)
-            str = STRDUP ("");
+            str = GNUNET_strdup ("");
           str = g_string_append_len (str, c->data, c->data_sz);
         }
     }
@@ -361,15 +362,15 @@
     {
       char *txt;
       int attrib_len = attributes[i + 4] - attributes[i + 3];
-      char *attrib = MALLOC (attrib_len + 1);
+      char *attrib = GNUNET_malloc (attrib_len + 1);
       memcpy (attrib, attributes[i + 3], attrib_len);
       attrib[attrib_len] = '\0';
       txt = attrib;
       attrib = gaim_unescape_html (txt);
-      FREE (txt);
+      GNUNET_free (txt);
       xmlnode_set_attrib (node, (const char *) attributes[i], attrib,
                           user_data);
-      FREE (attrib);
+      GNUNET_free (attrib);
     }
   xpd->current = node;
 }
@@ -448,7 +449,7 @@
   g_return_val_if_fail (str != NULL, NULL);
 
   real_size = size < 0 ? strlen (str) : size;
-  xpd = MALLOC (sizeof (XMLNodePool));
+  xpd = GNUNET_malloc (sizeof (XMLNodePool));
   memset (xpd, 0, sizeof (XMLNodePool));
   if (xmlSAXUserParseMemory (&xmlnode_parser_libxml, xpd, str, real_size) < 0)
     {
@@ -456,7 +457,7 @@
       return NULL;
     }
   ret = xpd->current;
-  ret->free_pool = YES;
+  ret->free_pool = GNUNET_YES;
   return ret;
 }
 

Modified: GNUnet/src/util/Makefile.am
===================================================================
--- GNUnet/src/util/Makefile.am 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/Makefile.am 2007-11-23 11:51:54 UTC (rev 5742)
@@ -1,10 +1,19 @@
 SUBDIRS = $(WINSUBDIRS) $(CYGSUBDIRS) \
-  error string config \
-  getopt disk threads \
-  os network . \
-  config_impl cron crypto \
-  containers loggers network_client \
-  boot
+  boot \
+  config \
+  containers \
+  cron \
+  crypto \
+  disk \
+  error \
+  getopt \
+  loggers \
+  network \
+  network_client \
+  os \
+  string \
+  threads \
+  .
 
 INCLUDES = -I$(top_srcdir)/src/include
 
@@ -40,12 +49,18 @@
 lib_LTLIBRARIES = libgnunetutil.la
 
 libgnunetutil_la_LIBADD = $(GCLIBADD) $(CYGLIBADD) $(WINLIBADD) \
+ boot/libboot.la \
  config/libconfig.la \
+ containers/libcontainers.la \
+ cron/libcron.la \
+ crypto/libcrypto.la \
  disk/libdisk.la \
  error/liberror.la \
  getopt/libgetopt.la \
+ loggers/libloggers.la \
  string/libstring.la \
  network/libnetwork.la \
+ network_client/libnetwork_client.la \
  os/libos.la \
  threads/libthreads.la
 
@@ -56,5 +71,5 @@
 
 libgnunetutil_la_LDFLAGS = \
  -export-dynamic $(LIBLTDL) $(LIBGCRYPT_LIBS) $(SOLFLAGS) $(WINFLAGS) $(LIBS) 
-lgmp $(DLFLAG) \
- -version-info 1:0:0
+ -version-info 2:0:0
 

Modified: GNUnet/src/util/README
===================================================================
--- GNUnet/src/util/README      2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/README      2007-11-23 11:51:54 UTC (rev 5742)
@@ -10,21 +10,19 @@
   util/os: process and system abstractions (depends on threads, config)
    util/network: network IO abstractions (depends on threads, config, os)
 
+The following depend on all of the above:
+util/cron: periodic job execution 
+util/config_impl: implementation of config API 
+util/loggers: specific logging implementations
+
 util: main utility library (depends on all of the above)
       => these are all statically linked into gnunetutil.so
 
-util/config_impl: implementation of config API (depends on gnunetutil.so)
-      => linked to gnunetutil_config.so
-
 -------- TODO ----------
-util/cron: periodic job execution (depends on gnunetutil.so)
-      => linked to gnunetutil_cron.so
 util/crypto: implementation of crypto API (depends on gnunetutil.so)
       => linked to gnunetutil_crypto.so
 util/containers: implementation of bloomfilter/vector/hashset (depends on 
gnunetutil.so)
       => linked to gnunetutil_containers.so (also requires 
libgnunetutil_crypto)
-util/loggers: specific logging implementations (depends on gnunetutil.so)
-      => linked to gnunetutil_logging.so
 util/network_client: library for synchronous communiation of clients with 
gnunetd (depends on gnunetutil.so)
       => linked to gnunetutil_network_client.so
 

Modified: GNUnet/src/util/boot/Makefile.am
===================================================================
--- GNUnet/src/util/boot/Makefile.am    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/boot/Makefile.am    2007-11-23 11:51:54 UTC (rev 5742)
@@ -2,14 +2,12 @@
 
 SUBDIRS = .
 
-lib_LTLIBRARIES = \
-  libgnunetutil_boot.la
+noinst_LTLIBRARIES = \
+  libboot.la
 
-libgnunetutil_boot_la_SOURCES = \
+libboot_la_SOURCES = \
   startup.c
 
 libgnunetutil_boot_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la 
+ $(top_builddir)/src/util/libgnunetutil.la 
 

Modified: GNUnet/src/util/boot/startup.c
===================================================================
--- GNUnet/src/util/boot/startup.c      2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/boot/startup.c      2007-11-23 11:51:54 UTC (rev 5742)
@@ -26,7 +26,7 @@
 
 #include "gnunet_directories.h"
 #include "gnunet_util_boot.h"
-#include "gnunet_util_config_impl.h"
+#include "gnunet_util_config.h"
 #include "gnunet_util_error_loggers.h"
 #include "platform.h"
 
@@ -69,6 +69,7 @@
   struct GE_Context *tetx;
   unsigned long long logrotate;
   int dev;
+  char *user;
 
   nctx = NULL;
   admin_log_file = NULL;
@@ -85,7 +86,7 @@
                                        "LOGFILE",
                                        VAR_DAEMON_DIRECTORY "/logs",
                                        &admin_log_file);
-  disk_directory_create_for_file (*ectx, admin_log_file);
+  GNUNET_disk_directory_create_for_file (*ectx, admin_log_file);
   GC_get_configuration_value_string (cfg,
                                      "LOGGING",
                                      "ADMIN-LEVEL",
@@ -94,16 +95,19 @@
                                      "LOGGING",
                                      "USER-LEVEL",
                                      "WARNING", &user_log_level);
-  dev = GC_get_configuration_value_yesno (cfg, "LOGGING", "DEVELOPER", NO);
+  user = NULL;
+  GC_get_configuration_value_string (cfg, "GNUNETD", "USER", NULL, &user);
+  dev =
+    GC_get_configuration_value_yesno (cfg, "LOGGING", "DEVELOPER", GNUNET_NO);
   all = convertLogLevel (admin_log_level);
   ull = convertLogLevel (user_log_level);
-  if (dev == YES)
+  if (dev == GNUNET_YES)
     {
       all |= GE_DEVELOPER | GE_REQUEST;
       ull |= GE_DEVELOPER | GE_REQUEST;
     }
-  FREE (admin_log_level);
-  FREE (user_log_level);
+  GNUNET_free (admin_log_level);
+  GNUNET_free (user_log_level);
   if (all != 0)
     {
       nctx = GE_create_context_logfile (NULL,
@@ -111,12 +115,13 @@
                                         | GE_ADMIN
                                         | GE_BULK
                                         | GE_IMMEDIATE,
-                                        admin_log_file, YES, (int) logrotate);
+                                        admin_log_file,
+                                        user, GNUNET_YES, (int) logrotate);
     }
-  FREE (admin_log_file);
+  GNUNET_free (admin_log_file);
   if (ull != 0)
     {
-      tetx = GE_create_context_stderr (YES,
+      tetx = GE_create_context_stderr (GNUNET_YES,
                                        ull
                                        | GE_USERKIND
                                        | GE_BULK | GE_IMMEDIATE);
@@ -145,7 +150,7 @@
              char *const *argv,
              const char *binaryName,
              char **cfgFileName,
-             const struct CommandLineOption *options,
+             const struct GNUNET_CommandLineOption *options,
              struct GE_Context **ectx, struct GC_Configuration **cfg)
 {
   int i;
@@ -153,52 +158,53 @@
   int is_daemon;
   int ret;
 
-  os_init (NULL);
+  GNUNET_os_init (NULL);
 
 #if ENABLE_NLS
   setlocale (LC_ALL, "");
-  path = os_get_installation_path (IPK_LOCALEDIR);
+  path = GNUNET_get_installation_path (GNUNET_IPK_LOCALEDIR);
   BINDTEXTDOMAIN ("GNUnet", path);
-  FREE (path);
+  GNUNET_free (path);
   textdomain ("GNUnet");
 #endif
   is_daemon = 0 == strcmp (DEFAULT_DAEMON_CONFIG_FILE, *cfgFileName);
 
   /* during startup, log all warnings and higher
      for anybody to stderr */
-  *ectx = GE_create_context_stderr (YES,
+  *ectx = GE_create_context_stderr (GNUNET_YES,
                                     GE_WARNING | GE_ERROR | GE_FATAL |
                                     GE_USER | GE_ADMIN | GE_DEVELOPER |
                                     GE_IMMEDIATE | GE_BULK);
   GE_setDefaultContext (*ectx);
-  os_init (*ectx);
-  *cfg = GC_create_C_impl ();
+  GNUNET_os_init (*ectx);
+  *cfg = GC_create ();
   GE_ASSERT (*ectx, *cfg != NULL);
-  i = gnunet_parse_options (binaryName,
+  i = GNUNET_parse_options (binaryName,
                             *ectx, *cfg, options, (unsigned int) argc, argv);
   if (i == -1)
     return -1;
-  if ((YES != disk_file_test (*ectx, *cfgFileName)) && (!is_daemon))
+  if ((GNUNET_YES != GNUNET_disk_file_test (*ectx, *cfgFileName))
+      && (!is_daemon))
     {
       char *run;
       char *bindir;
       size_t max;
 
-      bindir = os_get_installation_path (IPK_BINDIR);
+      bindir = GNUNET_get_installation_path (GNUNET_IPK_BINDIR);
       max = 128 + strlen (*cfgFileName) + strlen (bindir);
-      run = MALLOC (max);
-      SNPRINTF (run,
-                max,
-                "%sgnunet-setup -c %s generate-defaults",
-                bindir, *cfgFileName);
-      FREE (bindir);
+      run = GNUNET_malloc (max);
+      GNUNET_snprintf (run,
+                       max,
+                       "%sgnunet-setup -c %s generate-defaults",
+                       bindir, *cfgFileName);
+      GNUNET_free (bindir);
       ret = system (run);
       if (0 != ret)
         GE_LOG (*ectx,
                 GE_ERROR | GE_USER | GE_IMMEDIATE,
                 _("Failed to run %s: %s %d\n"),
                 run, strerror (errno), WEXITSTATUS (ret));
-      FREE (run);
+      GNUNET_free (run);
     }
   if (0 != GC_parse_configuration (*cfg, *cfgFileName))
     return -1;
@@ -208,11 +214,11 @@
                                      "PATHS",
                                      "GNUNETD_HOME",
                                      "/var/lib/gnunet", &path);
-  FREE (path);
+  GNUNET_free (path);
   GC_get_configuration_value_string (*cfg,
                                      "PATHS",
                                      "GNUNET_HOME", "~/.gnunet", &path);
-  FREE (path);
+  GNUNET_free (path);
   if (configure_logging (ectx, *cfg) != 0)
     return -1;
   return i;

Modified: GNUnet/src/util/config/Makefile.am
===================================================================
--- GNUnet/src/util/config/Makefile.am  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/config/Makefile.am  2007-11-23 11:51:54 UTC (rev 5742)
@@ -8,3 +8,16 @@
 libconfig_la_SOURCES = \
   config.c
 
+check_PROGRAMS = \
+ configtest 
+
+TESTS = $(check_PROGRAMS)
+
+configtest_SOURCES = \
+ configtest.c
+configtest_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la 
+
+
+EXTRA_DIST = \
+  testconfig.conf 

Modified: GNUnet/src/util/config/config.c
===================================================================
--- GNUnet/src/util/config/config.c     2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/config/config.c     2007-11-23 11:51:54 UTC (rev 5742)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2006 Christian Grothoff (and other contributing authors)
+     (C) 2006, 2007 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -20,122 +20,529 @@
 
 /**
  * @file src/util/config/config.c
- * @brief configuration API
+ * @brief configuration management
  *
  * @author Christian Grothoff
  */
 
-#include "gnunet_util_config_impl.h"
+#include "gnunet_util.h"
 #include "platform.h"
 
+/**
+ * @brief configuration entry
+ */
+typedef struct GC_Entry
+{
+
+  /**
+   * key for this entry
+   */
+  char *key;
+
+  /**
+   * current, commited value
+   */
+  char *val;
+
+  /**
+   * non-null during uncommited update
+   */
+  char *dirty_val;
+} GC_Entry;
+
+/**
+ * @brief configuration section
+ */
+typedef struct GC_Section
+{
+
+  /**
+   * name of the section
+   */
+  char *name;
+
+  /**
+   * number of entries in section
+   */
+  unsigned int size;
+
+  /**
+   * entries in the section
+   */
+  GC_Entry *entries;
+} GC_Section;
+
+/**
+ * @brief GC_ChangeListener and context
+ */
+typedef struct GC_Listener
+{
+
+  /**
+   * Callback.
+   */
+  GC_ChangeListener listener;
+
+  /**
+   * Context for callback.
+   */
+  void *ctx;
+} GC_Listener;
+
+/**
+ * @brief configuration data
+ */
+typedef struct GC_Configuration
+{
+
+  /**
+   * Lock to access the data.
+   */
+  struct GNUNET_Mutex *lock;
+
+  /**
+   * Context for logging errors, maybe NULL.
+   */
+  struct GE_Context *ectx;
+
+  /**
+   * Modification indication since last save
+   * 0 if clean, 1 if dirty, -1 on error (i.e. last save failed)
+   */
+  int dirty;
+
+  /**
+   * How many sections do we have?
+   */
+  unsigned int ssize;
+
+  /**
+   * Array with "ssize" entries.
+   */
+  GC_Section *sections;
+
+  /**
+   * How many listeners do we have?
+   */
+  unsigned int lsize;
+
+  /**
+   * Array with "lsize" entries.
+   */
+  GC_Listener *listeners;
+
+} GC_Configuration;
+
 void
 GC_free (struct GC_Configuration *cfg)
 {
-  cfg->free (cfg);
+  GC_Section *sec;
+  GC_Entry *e;
+  int i;
+  int j;
+
+  for (i = 0; i < cfg->ssize; i++)
+    {
+      sec = &cfg->sections[i];
+      for (j = 0; j < sec->size; j++)
+        {
+          e = &sec->entries[j];
+          GNUNET_free (e->key);
+          GNUNET_free_non_null (e->val);
+          GE_ASSERT (cfg->ectx, e->dirty_val == NULL);
+        }
+      GNUNET_array_grow (sec->entries, sec->size, 0);
+      GNUNET_free (sec->name);
+    }
+  GNUNET_array_grow (cfg->sections, cfg->ssize, 0);
+  GE_ASSERT (cfg->ectx, cfg->listeners == 0);
+  GNUNET_mutex_destroy (cfg->lock);
+  GNUNET_free (cfg);
+  GNUNET_free (cfg);
 }
 
-/**
- * Set the context for reporting configuration IO errors
- * (and errors reported by configuration change notification
- * callbacks when reading a new configuration).
- *
- * Note that for setting options a different context can be
- * used (since failing to change an option may have to be reported
- * in a fundamentally different way to the user).
- *
- * @parm ectx maybe NULL, in that case errors will no longer
- *       be reported
- */
 void
 GC_set_error_context (struct GC_Configuration *cfg, struct GE_Context *ectx)
 {
-  cfg->set_error_context (cfg, ectx);
+  cfg->ectx = ectx;
 }
 
-/**
- * Parse a configuration file, add all of the options in the
- * file to the configuration environment.
- * @return 0 on success, -1 on error
- */
 int
 GC_parse_configuration (struct GC_Configuration *cfg, const char *filename)
 {
-  return cfg->parse_configuration (cfg, filename);
+  int dirty;
+  char line[256];
+  char tag[64];
+  char value[192];
+  FILE *fp;
+  int nr;
+  int i;
+  int emptyline;
+  int ret;
+  char *section;
+  char *fn;
+
+  fn = GNUNET_expand_file_name (NULL, filename);
+  GNUNET_mutex_lock (cfg->lock);
+  dirty = cfg->dirty;           /* back up value! */
+  if (NULL == (fp = FOPEN (fn, "r")))
+    {
+      GE_LOG_STRERROR_FILE (cfg->ectx,
+                            GE_ERROR | GE_USER | GE_IMMEDIATE | GE_BULK |
+                            GE_REQUEST, "fopen", fn);
+      GNUNET_mutex_unlock (cfg->lock);
+      GNUNET_free (fn);
+      return -1;
+    }
+  GNUNET_free (fn);
+  ret = 0;
+  section = GNUNET_strdup ("");
+  memset (line, 0, 256);
+  nr = 0;
+  while (NULL != fgets (line, 255, fp))
+    {
+      nr++;
+      for (i = 0; i < 255; i++)
+        if (line[i] == '\t')
+          line[i] = ' ';
+      if (line[0] == '\n' || line[0] == '#' || line[0] == '%' ||
+          line[0] == '\r')
+        continue;
+      emptyline = 1;
+      for (i = 0; (i < 255 && line[i] != 0); i++)
+        if (line[i] != ' ' && line[i] != '\n' && line[i] != '\r')
+          emptyline = 0;
+      if (emptyline == 1)
+        continue;
+      /* remove tailing whitespace */
+      for (i = strlen (line) - 1; (i >= 0) && (isspace (line[i])); i--)
+        line[i] = '\0';
+      if (1 == sscanf (line, "@INLINE@ %191[^\n]", value))
+        {
+          /* @INLINE@ value */
+          char *expanded = GNUNET_expand_file_name (cfg->ectx,
+                                                    value);
+          if (0 != GC_parse_configuration (cfg, expanded))
+            ret = -1;           /* failed to parse included config */
+        }
+      else if (1 == sscanf (line, "[%99[^]]]", value))
+        {
+          /* [value] */
+          GNUNET_free (section);
+          section = GNUNET_strdup (value);
+        }
+      else if (2 == sscanf (line, " %63[^= ] = %191[^\n]", tag, value))
+        {
+          /* tag = value */
+          /* Strip LF */
+          i = strlen (value) - 1;
+          while ((i >= 0) && (isspace (value[i])))
+            value[i--] = '\0';
+          /* remove quotes */
+          i = 0;
+          if (value[0] == '"')
+            {
+              i = 1;
+              while ((value[i] != '\0') && (value[i] != '"'))
+                i++;
+              if (value[i] == '"')
+                {
+                  value[i] = '\0';
+                  i = 1;
+                }
+              else
+                i = 0;
+            }
+          /* first check if we have this value already;
+             this could happen if the value was changed
+             using a command-line option; only set it
+             if we do not have a value already... */
+          if ((GNUNET_NO == GC_have_configuration_value (cfg,
+                                                         section,
+                                                         tag)) &&
+              (0 != GC_set_configuration_value_string (cfg,
+                                                       cfg->ectx,
+                                                       section,
+                                                       tag, &value[i])))
+            ret = -1;           /* could not set value */
+        }
+      else if (1 == sscanf (line, " %63[^= ] =[^\n]", tag))
+        {
+          /* tag = */
+          /* first check if we have this value already;
+             this could happen if the value was changed
+             using a command-line option; only set it
+             if we do not have a value already... */
+          if ((GNUNET_NO == GC_have_configuration_value (cfg,
+                                                         section,
+                                                         tag)) &&
+              (0 != GC_set_configuration_value_string (cfg,
+                                                       cfg->ectx,
+                                                       section, tag, "")))
+            ret = -1;           /* could not set value */
+        }
+      else
+        {
+          /* parse error */
+          GE_LOG (cfg->ectx,
+                  GE_ERROR | GE_USER | GE_IMMEDIATE | GE_BULK,
+                  _("Syntax error in configuration file `%s' at line %d.\n"),
+                  filename, nr);
+          ret = -1;
+          break;
+        }
+    }
+  if (0 != fclose (fp))
+    {
+      GE_LOG_STRERROR_FILE (cfg->ectx,
+                            GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE |
+                            GE_BULK | GE_REQUEST, "fclose", filename);
+      ret = -1;
+    }
+  /* restore dirty flag - anything we set in the meantime
+     came from disk */
+  cfg->dirty = dirty;
+  GNUNET_mutex_unlock (cfg->lock);
+  GNUNET_free (section);
+  return ret;
 }
 
-/**
- * Test if there are configuration options that were
- * changed since the last save.
- * @return 0 if clean, 1 if dirty, -1 on error (i.e. last save failed)
- */
 int
 GC_test_dirty (struct GC_Configuration *cfg)
 {
-  return cfg->test_dirty (cfg);
+  return cfg->dirty;
 }
 
+int
+GC_write_configuration (struct GC_Configuration *data, const char *filename)
+{
+  GC_Section *sec;
+  GC_Entry *e;
+  int i;
+  int j;
+  FILE *fp;
+  int error;
+  int ret;
+  char *fn;
+  char *val;
+  char *pos;
 
+  fn = GNUNET_expand_file_name (NULL, filename);
+  GNUNET_disk_directory_create_for_file (NULL, fn);
+  if (NULL == (fp = FOPEN (fn, "w")))
+    {
+      GE_LOG_STRERROR_FILE (data->ectx,
+                            GE_ERROR | GE_USER | GE_IMMEDIATE, "fopen", fn);
+      GNUNET_free (fn);
+      return -1;
+    }
+  GNUNET_free (fn);
+  error = 0;
+  ret = 0;
+  GNUNET_mutex_lock (data->lock);
+  for (i = 0; i < data->ssize; i++)
+    {
+      sec = &data->sections[i];
+      if (0 > fprintf (fp, "[%s]\n", sec->name))
+        {
+          error = 1;
+          break;
+        }
+      for (j = 0; j < sec->size; j++)
+        {
+          e = &sec->entries[j];
+          GE_ASSERT (data->ectx, e->dirty_val == NULL);
+          if (e->val != NULL)
+            {
+              val = GNUNET_malloc (strlen (e->val) * 2 + 1);
+              strcpy (val, e->val);
+              while (NULL != (pos = strstr (val, "\n")))
+                {
+                  memmove (&pos[2], &pos[1], strlen (&pos[1]));
+                  pos[0] = '\\';
+                  pos[1] = 'n';
+                }
+              if (0 > fprintf (fp, "%s = %s\n", e->key, val))
+                {
+                  error = 1;
+                  GNUNET_free (val);
+                  break;
+                }
+              GNUNET_free (val);
+            }
+        }
+      if (error != 0)
+        break;
+      if (0 > fprintf (fp, "\n"))
+        {
+          error = 1;
+          break;
+        }
+    }
+  if (error != 0)
+    GE_LOG_STRERROR_FILE (data->ectx,
+                          GE_ERROR | GE_USER | GE_IMMEDIATE | GE_BULK |
+                          GE_REQUEST, "fprintf", filename);
+  if (0 != fclose (fp))
+    {
+      GE_LOG_STRERROR_FILE (data->ectx,
+                            GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE |
+                            GE_BULK | GE_REQUEST, "fclose", filename);
+      error = 1;
+    }
+  if (error == 0)
+    {
+      ret = 0;
+      data->dirty = 0;          /* last write succeeded */
+    }
+  else
+    {
+      ret = -1;
+      data->dirty = -1;         /* last write failed */
+    }
+  GNUNET_mutex_unlock (data->lock);
+  return ret;
+}
+
 /**
- * Write configuration file.
- * @return 0 on success, -1 on error
+ * Call only with lock held!
  */
-int
-GC_write_configuration (struct GC_Configuration *cfg, const char *filename)
+static GC_Section *
+findSection (GC_Configuration * data, const char *section)
 {
-  return cfg->write_configuration (cfg, filename);
+  int i;
+  for (i = data->ssize - 1; i >= 0; i--)
+    if (0 == strcmp (section, data->sections[i].name))
+      return &data->sections[i];
+  return NULL;
 }
 
-
 /**
- * Get a configuration value that should be in a set of
- * "YES" or "NO".
- *
- * @param def default value (use indicated by return value;
- *        will NOT be aliased, maybe NULL)
- * @return YES, NO or SYSERR
+ * Call only with lock held!
  */
+static GC_Entry *
+findEntry (GC_Configuration * data, const char *section, const char *key)
+{
+  int i;
+  GC_Section *sec;
+
+  sec = findSection (data, section);
+  if (sec == NULL)
+    return NULL;
+  for (i = sec->size - 1; i >= 0; i--)
+    if (0 == strcmp (key, sec->entries[i].key))
+      return &sec->entries[i];
+  return NULL;
+}
+
 int
-GC_get_configuration_value_yesno (struct GC_Configuration *cfg,
-                                  const char *section,
-                                  const char *option, int def)
+GC_set_configuration_value_string (struct GC_Configuration *data,
+                                   struct GE_Context *ectx,
+                                   const char *section,
+                                   const char *option, const char *value)
 {
-  static const char *yesno[] = { "YES", "NO", NULL };
-  const char *val;
+  GC_Section *sec;
+  GC_Section nsec;
+  GC_Entry *e;
+  GC_Entry ne;
   int ret;
+  int i;
 
-  ret = GC_get_configuration_value_choice (cfg,
-                                           section,
-                                           option,
-                                           yesno,
-                                           def == YES ? "YES" : "NO", &val);
+  GNUNET_mutex_lock (data->lock);
+  e = findEntry (data, section, option);
+  if (e == NULL)
+    {
+      sec = findSection (data, section);
+      if (sec == NULL)
+        {
+          nsec.name = GNUNET_strdup (section);
+          nsec.size = 0;
+          nsec.entries = NULL;
+          GNUNET_array_append (data->sections, data->ssize, nsec);
+          sec = findSection (data, section);
+        }
+      ne.key = GNUNET_strdup (option);
+      ne.val = NULL;
+      ne.dirty_val = NULL;
+      GNUNET_array_append (sec->entries, sec->size, ne);
+      e = findEntry (data, section, option);
+    }
+  if (e->dirty_val != NULL)
+    {
+      if (0 == strcmp (e->dirty_val, value))
+        {
+          ret = 0;
+        }
+      else
+        {
+          /* recursive update to different value -- not allowed! */
+          GE_BREAK (ectx, 0);
+          ret = -1;
+        }
+    }
+  else
+    {
+      e->dirty_val = GNUNET_strdup (value);
+      i = data->lsize - 1;
+      while (i >= 0)
+        {
+          if (0 != data->listeners[i].listener (data->listeners[i].ctx,
+                                                data, ectx, section, option))
+            break;              /* update refused */
+          i--;
+          e = findEntry (data, section, option);        /* side-effects of 
callback are possible! */
+        }
+      e = findEntry (data, section, option);    /* side-effects of callback 
are possible! */
+      if (i >= 0)
+        {
+          /* update refused, revert! */
+          GNUNET_free (e->dirty_val);
+          e->dirty_val = NULL;
+          i++;                  /* the callback that refused does not need 
refreshing */
+          while (i < data->lsize)
+            {
+              if (0 != data->listeners[i].listener (data->listeners[i].ctx,
+                                                    data,
+                                                    ectx, section, option))
+                GE_ASSERT (ectx, 0);    /* refused the refusal!? */
+              e = findEntry (data, section, option);    /* side-effects of 
callback are possible! */
+              i++;
+            }
+          ret = -1;             /* error -- update refused */
+        }
+      else
+        {
+          /* all confirmed, commit! */
+          if ((e->val == NULL) || (0 != strcmp (e->val, e->dirty_val)))
+            data->dirty = 1;
+          GNUNET_free_non_null (e->val);
+          e->val = e->dirty_val;
+          e->dirty_val = NULL;
+          ret = 0;
+        }
+    }
   if (ret == -1)
-    return SYSERR;
-  if (val == yesno[0])
-    return YES;
-  return NO;
+    GE_LOG (ectx,
+            GE_USER | GE_BULK | GE_WARNING,
+            _
+            ("Setting option `%s' in section `%s' to value `%s' was 
refused.\n"),
+            option, section, value);
+  GNUNET_mutex_unlock (data->lock);
+  return ret;
 }
 
-/**
- * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR"
- * where either in the current section or globally FOO is set to
- * DIRECTORY.
- *
- * @param old string to $-expand (will be freed!)
- * @return $-expanded string
- */
-char *
-GC_configuration_expand_dollar (struct GC_Configuration *cfg, char *old)
+int
+GC_set_configuration_value_number (struct GC_Configuration *cfg,
+                                   struct GE_Context *ectx,
+                                   const char *section,
+                                   const char *option,
+                                   unsigned long long number)
 {
-  return cfg->configuration_expand_dollar (cfg, old);
+  char s[64];
+  GNUNET_snprintf (s, 64, "%llu", number);
+  return GC_set_configuration_value_string (cfg, ectx, section, option, s);
 }
 
-/**
- * Get a configuration value that should be a number.
- * @param min minimal legal value
- * @param max maximal legal value
- * @param def default value (use indicated by return value)
- * @return 0 on success, -1 on error, 1 for default
- */
 int
 GC_get_configuration_value_number (struct GC_Configuration *cfg,
                                    const char *section,
@@ -145,50 +552,90 @@
                                    unsigned long long def,
                                    unsigned long long *number)
 {
-  return cfg->get_configuration_value_number (cfg, section, option, min, max,
-                                              def, number);
+  GC_Entry *e;
+  const char *val;
+  int ret;
+
+  GNUNET_mutex_lock (cfg->lock);
+  e = findEntry (cfg, section, option);
+  if (e != NULL)
+    {
+      val = (e->dirty_val != NULL) ? e->dirty_val : e->val;
+      if (1 == SSCANF (val, "%llu", number))
+        {
+          if ((*number >= min) && (*number <= max))
+            {
+              ret = 0;
+            }
+          else
+            {
+              GE_LOG (cfg->ectx,
+                      GE_ERROR | GE_USER | GE_BULK,
+                      _("Configuration value '%llu' for '%s' "
+                        "in section '%s' is out of legal bounds 
[%llu,%llu]\n"),
+                      *number, option, section, min, max);
+              ret = -1;         /* error */
+            }
+        }
+      else
+        {
+          GE_LOG (cfg->ectx,
+                  GE_ERROR | GE_USER | GE_BULK,
+                  _("Configuration value '%s' for '%s'"
+                    " in section '%s' should be a number\n"),
+                  val, option, section, min, max);
+          ret = -1;             /* error */
+        }
+    }
+  else
+    {
+      *number = def;
+      GC_set_configuration_value_number (cfg,
+                                         cfg->ectx, section, option, def);
+      ret = 1;                  /* default */
+    }
+  GNUNET_mutex_unlock (cfg->lock);
+  return ret;
 }
 
-
-/**
- * Get a configuration value that should be a string.
- * @param def default value (use indicated by return value;
- *        will NOT be aliased, maybe NULL)
- * @param value will be set to a freshly allocated configuration
- *        value, or NULL if option is not specified and no default given
- * @return 0 on success, -1 on error, 1 for default
- */
 int
 GC_get_configuration_value_string (struct GC_Configuration *cfg,
                                    const char *section,
                                    const char *option,
                                    const char *def, char **value)
 {
-  return cfg->get_configuration_value_string (cfg, section, option, def,
-                                              value);
-}
+  GC_Entry *e;
+  const char *val;
+  int ret;
 
-int
-GC_get_configuration_value_filename (struct GC_Configuration *cfg,
-                                     const char *section,
-                                     const char *option,
-                                     const char *def, char **value)
-{
-  return cfg->get_configuration_value_filename (cfg, section, option, def,
-                                                value);
+  GNUNET_mutex_lock (cfg->lock);
+  e = findEntry (cfg, section, option);
+  if (e != NULL)
+    {
+      val = (e->dirty_val != NULL) ? e->dirty_val : e->val;
+      *value = GNUNET_strdup (val);
+      ret = 0;
+    }
+  else
+    {
+      if (def == NULL)
+        {
+          GNUNET_mutex_unlock (cfg->lock);
+          GE_LOG (cfg->ectx,
+                  GE_USER | GE_IMMEDIATE | GE_ERROR,
+                  "Configuration value for option `%s' in section `%s' 
required.\n",
+                  option, section);
+          return -1;
+        }
+      *value = GNUNET_strdup (def);
+      GC_set_configuration_value_string (cfg,
+                                         cfg->ectx, section, option, def);
+      ret = 1;                  /* default */
+    }
+  GNUNET_mutex_unlock (cfg->lock);
+  return ret;
 }
 
-/**
- * Get a configuration value that should be in a set of
- * predefined strings
- * @param choices NULL-terminated list of legal values
- * @param def default value (use indicated by return value;
- *        will NOT be aliased, maybe NULL), must be reference
- *        into set given by choices
- * @param value will be set to an entry in the legal list,
- *        or NULL if option is not specified and no default given
- * @return 0 on success, -1 on error, 1 for default
- */
 int
 GC_get_configuration_value_choice (struct GC_Configuration *cfg,
                                    const char *section,
@@ -196,87 +643,272 @@
                                    const char **choices,
                                    const char *def, const char **value)
 {
-  return cfg->get_configuration_value_choice (cfg, section, option, choices,
-                                              def, value);
+  GC_Entry *e;
+  const char *val;
+  int i;
+  int ret;
+
+  GNUNET_mutex_lock (cfg->lock);
+  e = findEntry (cfg, section, option);
+  if (e != NULL)
+    {
+      val = (e->dirty_val != NULL) ? e->dirty_val : e->val;
+      i = 0;
+      while (choices[i] != NULL)
+        {
+          if (0 == strcasecmp (choices[i], val))
+            break;
+          i++;
+        }
+      if (choices[i] == NULL)
+        {
+          GE_LOG (cfg->ectx,
+                  GE_ERROR | GE_USER | GE_BULK,
+                  _("Configuration value '%s' for '%s'"
+                    " in section '%s' is not in set of legal choices\n"),
+                  val, option, section);
+          ret = -1;             /* error */
+        }
+      else
+        {
+          *value = choices[i];
+          ret = 0;
+        }
+    }
+  else
+    {
+      *value = def;
+      if (def == NULL)
+        ret = -1;
+      else
+        ret = 1;                /* default */
+    }
+  GNUNET_mutex_unlock (cfg->lock);
+  return ret;
 }
 
 /**
- * Set a configuration value that should be a number.
- * @return 0 on success, -1 on error (i.e. out of memory,
- *   or update refused by registered callback)
+ * Test if we have a value for a particular option
+ * @return GNUNET_YES if so, GNUNET_NO if not.
  */
 int
-GC_set_configuration_value_number (struct GC_Configuration *cfg,
-                                   struct GE_Context *ectx,
-                                   const char *section,
-                                   const char *option,
-                                   unsigned long long number)
+GC_have_configuration_value (struct GC_Configuration *cfg,
+                             const char *section, const char *option)
 {
-  return cfg->set_configuration_value_number (cfg, ectx, section, option,
-                                              number);
+  GC_Entry *e;
+  int ret;
+
+  GNUNET_mutex_lock (cfg->lock);
+  e = findEntry (cfg, section, option);
+  if (e == NULL)
+    ret = GNUNET_NO;
+  else
+    ret = GNUNET_YES;
+  GNUNET_mutex_unlock (cfg->lock);
+  return ret;
 }
 
-
 /**
- * Set a configuration value that should be a string.
- * @param value
- * @return 0 on success, -1 on error (i.e. out of memory,
- *   or update refused by registered callback)
+ * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR"
+ * where either in the "PATHS" section or the environtment
+ * "FOO" is set to "DIRECTORY".
+ *
+ * @param old string to $-expand (will be freed!)
+ * @return $-expanded string
  */
-int
-GC_set_configuration_value_string (struct GC_Configuration *cfg,
-                                   struct GE_Context *ectx,
-                                   const char *section,
-                                   const char *option, const char *value)
+char *
+GC_configuration_expand_dollar (struct GC_Configuration *cfg, char *orig)
 {
-  return cfg->set_configuration_value_string (cfg, ectx, section, option,
-                                              value);
+  int i;
+  char *prefix;
+  char *result;
+  const char *post;
+
+  if (orig[0] != '$')
+    return orig;
+  i = 0;
+  while ((orig[i] != '/') && (orig[i] != '\\') && (orig[i] != '\0'))
+    i++;
+  if (orig[i] == '\0')
+    {
+      post = "";
+    }
+  else
+    {
+      orig[i] = '\0';
+      post = &orig[i + 1];
+    }
+  prefix = NULL;
+  if (GNUNET_YES == GC_have_configuration_value (cfg, "PATHS", &orig[1]))
+    {
+      if (0 != GC_get_configuration_value_string (cfg,
+                                                  "PATHS",
+                                                  &orig[1], NULL, &prefix))
+        {
+          GE_BREAK (NULL, 0);
+          return orig;
+        }
+    }
+  else
+    {
+      const char *env = getenv (&orig[1]);
+
+      if (env != NULL)
+        {
+          prefix = GNUNET_strdup (env);
+        }
+      else
+        {
+          orig[i] = DIR_SEPARATOR;
+          return orig;
+        }
+    }
+  result = GNUNET_malloc (strlen (prefix) + strlen (post) + 2);
+  strcpy (result, prefix);
+  if ((strlen (prefix) == 0) ||
+      (prefix[strlen (prefix) - 1] != DIR_SEPARATOR))
+    strcat (result, DIR_SEPARATOR_STR);
+  strcat (result, post);
+  GNUNET_free (prefix);
+  GNUNET_free (orig);
+  return result;
 }
 
 /**
- * Set a configuration value that should be in a set of
- * predefined strings.
- * @param value
- * @return 0 on success, -1 on error (i.e. out of memory,
- *   or update refused by registered callback)
+ * Get a configuration value that should be a string.
+ * @param def default value (use indicated by return value;
+ *        will NOT be aliased, maybe NULL)
+ * @param value will be set to a freshly allocated configuration
+ *        value, or NULL if option is not specified and no default given
+ * @return 0 on success, -1 on error, 1 for default
  */
 int
+GC_get_configuration_value_filename (struct GC_Configuration *data,
+                                     const char *section,
+                                     const char *option,
+                                     const char *def, char **value)
+{
+  int ret;
+  char *tmp;
+
+  tmp = NULL;
+  ret = GC_get_configuration_value_string (data, section, option, def, &tmp);
+  if (tmp != NULL)
+    {
+      tmp = GC_configuration_expand_dollar (data, tmp);
+      *value = GNUNET_expand_file_name (data->ectx, tmp);
+      GNUNET_free (tmp);
+    }
+  else
+    {
+      *value = NULL;
+    }
+  return ret;
+}
+
+int
 GC_set_configuration_value_choice (struct GC_Configuration *cfg,
                                    struct GE_Context *ectx,
                                    const char *section,
                                    const char *option, const char *choice)
 {
-  return cfg->set_configuration_value_choice (cfg, ectx, section, option,
-                                              choice);
+  return GC_set_configuration_value_string (cfg, ectx, section, option,
+                                            choice);
 }
 
-/**
- * Attach a callback that is notified whenever a
- * configuration option changes.
- * @return 0 on success, -1 on error
- */
 int
 GC_attach_change_listener (struct GC_Configuration *cfg,
                            GC_ChangeListener callback, void *ctx)
 {
-  return cfg->attach_change_listener (cfg, callback, ctx);
+  GC_Listener l;
+  int i;
+  int j;
+
+  GNUNET_mutex_lock (cfg->lock);
+  for (i = 0; i < cfg->ssize; i++)
+    {
+      GC_Section *s = &cfg->sections[i];
+      for (j = 0; j < s->size; j++)
+        {
+          GC_Entry *e = &s->entries[j];
+          if (0 != callback (ctx, cfg, cfg->ectx, s->name, e->key))
+            {
+              GNUNET_mutex_unlock (cfg->lock);
+              return -1;
+            }
+          s = &cfg->sections[i];        /* side-effects of callback are 
possible! */
+        }
+    }
+  l.listener = callback;
+  l.ctx = ctx;
+  GNUNET_array_append (cfg->listeners, cfg->lsize, l);
+  GNUNET_mutex_unlock (cfg->lock);
+  return 0;
 }
 
-/**
- * Attach a callback that is notified whenever a
- * configuration option changes.
- * @return 0 on success, -1 on error, 1 for no such handler registered
- */
 int
 GC_detach_change_listener (struct GC_Configuration *cfg,
                            GC_ChangeListener callback, void *ctx)
 {
-  return cfg->detach_change_listener (cfg, callback, ctx);
+  int i;
+  GC_Listener *l;
+
+  GNUNET_mutex_lock (cfg->lock);
+  for (i = cfg->lsize - 1; i >= 0; i--)
+    {
+      l = &cfg->listeners[i];
+      if ((l->listener == callback) && (l->ctx == ctx))
+        {
+          cfg->listeners[i] = cfg->listeners[cfg->lsize - 1];
+          GNUNET_array_grow (cfg->listeners, cfg->lsize, cfg->lsize - 1);
+          GNUNET_mutex_unlock (cfg->lock);
+          return 0;
+        }
+    }
+  GNUNET_mutex_unlock (cfg->lock);
+  return -1;
 }
 
+/**
+ * Create a GC_Configuration.
+ */
+GC_Configuration *
+GC_create ()
+{
+  GC_Configuration *ret;
+
+  ret = GNUNET_malloc (sizeof (GC_Configuration));
+  memset (ret, 0, sizeof (GC_Configuration));
+  ret->lock = GNUNET_mutex_create (GNUNET_YES);
+  return ret;
+}
+
+/**
+ * Get a configuration value that should be in a set of
+ * "GNUNET_YES" or "GNUNET_NO".
+ *
+ * @param def default value (use indicated by return value;
+ *        will NOT be aliased, maybe NULL)
+ * @return GNUNET_YES, GNUNET_NO or GNUNET_SYSERR
+ */
 int
-GC_have_configuration_value (struct GC_Configuration *cfg,
-                             const char *section, const char *option)
+GC_get_configuration_value_yesno (struct GC_Configuration *cfg,
+                                  const char *section,
+                                  const char *option, int def)
 {
-  return cfg->have_configuration_value (cfg, section, option);
+  static const char *yesno[] = { "YES", "NO", NULL };
+  const char *val;
+  int ret;
+
+  ret = GC_get_configuration_value_choice (cfg,
+                                           section,
+                                           option,
+                                           yesno,
+                                           def == GNUNET_YES ? "YES" : "NO",
+                                           &val);
+  if (ret == -1)
+    return GNUNET_SYSERR;
+  if (val == yesno[0])
+    return GNUNET_YES;
+  return GNUNET_NO;
 }

Added: GNUnet/src/util/config/configtest.c
===================================================================
--- GNUnet/src/util/config/configtest.c                         (rev 0)
+++ GNUnet/src/util/config/configtest.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -0,0 +1,80 @@
+/*
+     This file is part of GNUnet.
+     (C) 2003, 2004, 2005, 2006, 2007 Christian Grothoff (and other 
contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file util/config/configtest.c
+ * @brief Test that the configuration module works.
+ * @author Christian Grothoff
+ */
+
+#include "gnunet_util.h"
+#include "platform.h"
+#include "gnunet_util_config.h"
+#include "gnunet_util_error_loggers.h"
+
+static struct GC_Configuration *cfg;
+
+static int
+testConfig ()
+{
+  char *c;
+  unsigned long long l;
+
+  if (0 != GC_get_configuration_value_string (cfg, "test", "b", NULL, &c))
+    return 1;
+  if (0 != strcmp ("b", c))
+    return 1;
+  GNUNET_free (c);
+  if (0 != GC_get_configuration_value_number (cfg,
+                                              "test", "five", 0, 10, 9, &l))
+    return 1;
+  if (5 != l)
+    return 1;
+  GC_set_configuration_value_string (cfg, NULL, "more", "c", "YES");
+  if (GNUNET_NO ==
+      GC_get_configuration_value_yesno (cfg, "more", "c", GNUNET_NO))
+    return 1;
+  return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+  struct GE_Context *ectx;
+  int failureCount = 0;
+
+  ectx = GE_create_context_stderr (GNUNET_NO,
+                                   GE_WARNING | GE_ERROR | GE_FATAL |
+                                   GE_USER | GE_ADMIN | GE_DEVELOPER |
+                                   GE_IMMEDIATE | GE_BULK);
+  GE_setDefaultContext (ectx);
+  cfg = GC_create ();
+  if (0 != GC_parse_configuration (cfg, "testconfig.conf"))
+    {
+      fprintf (stderr, "Failed to parse configuration file\n");
+      return 1;
+    }
+  GE_ASSERT (ectx, cfg != NULL);
+  GNUNET_os_init (ectx);
+  failureCount += testConfig ();
+
+  if (failureCount != 0)
+    return 1;
+  return 0;
+}


Property changes on: GNUnet/src/util/config/configtest.c
___________________________________________________________________
Name: svn:eol-style
   + native

Added: GNUnet/src/util/config/testconfig.conf
===================================================================
--- GNUnet/src/util/config/testconfig.conf                              (rev 0)
+++ GNUnet/src/util/config/testconfig.conf      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -0,0 +1,19 @@
+[GNUNET]
+SUBST=hello
+GNUNET_HOME=/tmp
+
+[test]
+a=a
+b=b
+five=5
+
+[more]
+c=c
+five=42
+
+               
+[last]
+test = $SUBST/world
+boom = "1 2 3 testing"
+trailing = YES 
+

Modified: GNUnet/src/util/config_impl/Makefile.am
===================================================================
--- GNUnet/src/util/config_impl/Makefile.am     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/config_impl/Makefile.am     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -2,16 +2,12 @@
 
 SUBDIRS = .
 
-lib_LTLIBRARIES = \
-  libgnunetutil_config.la
+noinst_LTLIBRARIES = \
+  libconfigimpl.la
 
-libgnunetutil_config_la_SOURCES = \
+libconfigimpl_la_SOURCES = \
   impl.c
 
-libgnunetutil_config_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la 
-
-
 check_PROGRAMS = \
  configtest 
 
@@ -20,9 +16,7 @@
 configtest_SOURCES = \
  configtest.c
 configtest_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la 
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 
 EXTRA_DIST = \

Modified: GNUnet/src/util/config_impl/configtest.c
===================================================================
--- GNUnet/src/util/config_impl/configtest.c    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/config_impl/configtest.c    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2003, 2004, 2005, 2006 Christian Grothoff (and other contributing 
authors)
+     (C) 2003, 2004, 2005, 2006, 2007 Christian Grothoff (and other 
contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -18,14 +18,14 @@
      Boston, MA 02111-1307, USA.
 */
 /**
- * @file util/config_impl/configtest.c
+ * @file util/config/configtest.c
  * @brief Test that the configuration module works.
  * @author Christian Grothoff
  */
 
 #include "gnunet_util.h"
 #include "platform.h"
-#include "gnunet_util_config_impl.h"
+#include "gnunet_util_config.h"
 #include "gnunet_util_error_loggers.h"
 
 static struct GC_Configuration *cfg;
@@ -40,14 +40,15 @@
     return 1;
   if (0 != strcmp ("b", c))
     return 1;
-  FREE (c);
+  GNUNET_free (c);
   if (0 != GC_get_configuration_value_number (cfg,
                                               "test", "five", 0, 10, 9, &l))
     return 1;
   if (5 != l)
     return 1;
   GC_set_configuration_value_string (cfg, NULL, "more", "c", "YES");
-  if (NO == GC_get_configuration_value_yesno (cfg, "more", "c", NO))
+  if (GNUNET_NO ==
+      GC_get_configuration_value_yesno (cfg, "more", "c", GNUNET_NO))
     return 1;
   return 0;
 }
@@ -58,19 +59,19 @@
   struct GE_Context *ectx;
   int failureCount = 0;
 
-  ectx = GE_create_context_stderr (NO,
+  ectx = GE_create_context_stderr (GNUNET_NO,
                                    GE_WARNING | GE_ERROR | GE_FATAL |
                                    GE_USER | GE_ADMIN | GE_DEVELOPER |
                                    GE_IMMEDIATE | GE_BULK);
   GE_setDefaultContext (ectx);
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (0 != GC_parse_configuration (cfg, "testconfig.conf"))
     {
       fprintf (stderr, "Failed to parse configuration file\n");
       return 1;
     }
   GE_ASSERT (ectx, cfg != NULL);
-  os_init (ectx);
+  GNUNET_os_init (ectx);
   failureCount += testConfig ();
 
   if (failureCount != 0)

Modified: GNUnet/src/util/config_impl/impl.c
===================================================================
--- GNUnet/src/util/config_impl/impl.c  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/config_impl/impl.c  2007-11-23 11:51:54 UTC (rev 5742)
@@ -27,882 +27,4 @@
 #include "gnunet_util_config_impl.h"
 #include "gnunet_util_string.h"
 #include "gnunet_util.h"
-#include "platform.h"
-
-/**
- * @brief configuration entry
- */
-typedef struct GC_Entry
-{
-
-  /**
-   * key for this entry
-   */
-  char *key;
-
-  /**
-   * current, commited value
-   */
-  char *val;
-
-  /**
-   * non-null during uncommited update
-   */
-  char *dirty_val;
-} GC_Entry;
-
-/**
- * @brief configuration section
- */
-typedef struct GC_Section
-{
-
-  /**
-   * name of the section
-   */
-  char *name;
-
-  /**
-   * number of entries in section
-   */
-  unsigned int size;
-
-  /**
-   * entries in the section
-   */
-  GC_Entry *entries;
-} GC_Section;
-
-/**
- * @brief GC_ChangeListener and context
- */
-typedef struct GC_Listener
-{
-
-  /**
-   * Callback.
-   */
-  GC_ChangeListener listener;
-
-  /**
-   * Context for callback.
-   */
-  void *ctx;
-} GC_Listener;
-
-/**
- * @brief configuration data
- */
-typedef struct GC_ConfigurationData
-{
-
-  /**
-   * Lock to access the data.
-   */
-  struct MUTEX *lock;
-
-  /**
-   * Context for logging errors, maybe NULL.
-   */
-  struct GE_Context *ectx;
-
-  /**
-   * Modification indication since last save
-   * 0 if clean, 1 if dirty, -1 on error (i.e. last save failed)
-   */
-  int dirty;
-
-  /**
-   * How many sections do we have?
-   */
-  unsigned int ssize;
-
-  /**
-   * Array with "ssize" entries.
-   */
-  GC_Section *sections;
-
-  /**
-   * How many listeners do we have?
-   */
-  unsigned int lsize;
-
-  /**
-   * Array with "lsize" entries.
-   */
-  GC_Listener *listeners;
-
-} GC_ConfigurationData;
-
-static void
-_free (struct GC_Configuration *cfg)
-{
-  GC_Section *sec;
-  GC_Entry *e;
-  int i;
-  int j;
-
-  for (i = 0; i < cfg->data->ssize; i++)
-    {
-      sec = &cfg->data->sections[i];
-      for (j = 0; j < sec->size; j++)
-        {
-          e = &sec->entries[j];
-          FREE (e->key);
-          FREENONNULL (e->val);
-          GE_ASSERT (cfg->data->ectx, e->dirty_val == NULL);
-        }
-      GROW (sec->entries, sec->size, 0);
-      FREE (sec->name);
-    }
-  GROW (cfg->data->sections, cfg->data->ssize, 0);
-  GE_ASSERT (cfg->data->ectx, cfg->data->listeners == 0);
-  MUTEX_DESTROY (cfg->data->lock);
-  FREE (cfg->data);
-  FREE (cfg);
-}
-
-static void
-_set_error_context (struct GC_Configuration *cfg, struct GE_Context *ectx)
-{
-  cfg->data->ectx = ectx;
-}
-
-static int
-_parse_configuration (struct GC_Configuration *cfg, const char *filename)
-{
-  int dirty;
-  char line[256];
-  char tag[64];
-  char value[192];
-  FILE *fp;
-  int nr;
-  int i;
-  int emptyline;
-  int ret;
-  char *section;
-  char *fn;
-
-  fn = string_expandFileName (NULL, filename);
-  MUTEX_LOCK (cfg->data->lock);
-  dirty = cfg->data->dirty;     /* back up value! */
-  if (NULL == (fp = FOPEN (fn, "r")))
-    {
-      GE_LOG_STRERROR_FILE (cfg->data->ectx,
-                            GE_ERROR | GE_USER | GE_IMMEDIATE | GE_BULK |
-                            GE_REQUEST, "fopen", fn);
-      MUTEX_UNLOCK (cfg->data->lock);
-      FREE (fn);
-      return -1;
-    }
-  FREE (fn);
-  ret = 0;
-  section = STRDUP ("");
-  memset (line, 0, 256);
-  nr = 0;
-  while (NULL != fgets (line, 255, fp))
-    {
-      nr++;
-      for (i = 0; i < 255; i++)
-        if (line[i] == '\t')
-          line[i] = ' ';
-      if (line[0] == '\n' || line[0] == '#' || line[0] == '%' ||
-          line[0] == '\r')
-        continue;
-      emptyline = 1;
-      for (i = 0; (i < 255 && line[i] != 0); i++)
-        if (line[i] != ' ' && line[i] != '\n' && line[i] != '\r')
-          emptyline = 0;
-      if (emptyline == 1)
-        continue;
-      /* remove tailing whitespace */
-      for (i = strlen (line) - 1; (i >= 0) && (isspace (line[i])); i--)
-        line[i] = '\0';
-      if (1 == sscanf (line, "@INLINE@ %191[^\n]", value))
-        {
-          /* @INLINE@ value */
-          char *expanded = string_expandFileName (cfg->data->ectx,
-                                                  value);
-          if (0 != _parse_configuration (cfg, expanded))
-            ret = -1;           /* failed to parse included config */
-        }
-      else if (1 == sscanf (line, "[%99[^]]]", value))
-        {
-          /* [value] */
-          FREE (section);
-          section = STRDUP (value);
-        }
-      else if (2 == sscanf (line, " %63[^= ] = %191[^\n]", tag, value))
-        {
-          /* tag = value */
-          /* Strip LF */
-          i = strlen (value) - 1;
-          while ((i >= 0) && (isspace (value[i])))
-            value[i--] = '\0';
-          /* remove quotes */
-          i = 0;
-          if (value[0] == '"')
-            {
-              i = 1;
-              while ((value[i] != '\0') && (value[i] != '"'))
-                i++;
-              if (value[i] == '"')
-                {
-                  value[i] = '\0';
-                  i = 1;
-                }
-              else
-                i = 0;
-            }
-          /* first check if we have this value already;
-             this could happen if the value was changed
-             using a command-line option; only set it
-             if we do not have a value already... */
-          if ((NO == GC_have_configuration_value (cfg,
-                                                  section,
-                                                  tag)) &&
-              (0 != GC_set_configuration_value_string (cfg,
-                                                       cfg->data->ectx,
-                                                       section,
-                                                       tag, &value[i])))
-            ret = -1;           /* could not set value */
-        }
-      else if (1 == sscanf (line, " %63[^= ] =[^\n]", tag))
-        {
-          /* tag = */
-          /* first check if we have this value already;
-             this could happen if the value was changed
-             using a command-line option; only set it
-             if we do not have a value already... */
-          if ((NO == GC_have_configuration_value (cfg,
-                                                  section,
-                                                  tag)) &&
-              (0 != GC_set_configuration_value_string (cfg,
-                                                       cfg->data->ectx,
-                                                       section, tag, "")))
-            ret = -1;           /* could not set value */
-        }
-      else
-        {
-          /* parse error */
-          GE_LOG (cfg->data->ectx,
-                  GE_ERROR | GE_USER | GE_IMMEDIATE | GE_BULK,
-                  _("Syntax error in configuration file `%s' at line %d.\n"),
-                  filename, nr);
-          ret = -1;
-          break;
-        }
-    }
-  if (0 != fclose (fp))
-    {
-      GE_LOG_STRERROR_FILE (cfg->data->ectx,
-                            GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE |
-                            GE_BULK | GE_REQUEST, "fclose", filename);
-      ret = -1;
-    }
-  /* restore dirty flag - anything we set in the meantime
-     came from disk */
-  cfg->data->dirty = dirty;
-  MUTEX_UNLOCK (cfg->data->lock);
-  FREE (section);
-  return ret;
-}
-
-static int
-_test_dirty (struct GC_Configuration *cfg)
-{
-  return cfg->data->dirty;
-}
-
-static int
-_write_configuration (struct GC_Configuration *cfg, const char *filename)
-{
-  GC_ConfigurationData *data;
-  GC_Section *sec;
-  GC_Entry *e;
-  int i;
-  int j;
-  FILE *fp;
-  int error;
-  int ret;
-  char *fn;
-  char *val;
-  char *pos;
-
-  fn = string_expandFileName (NULL, filename);
-  disk_directory_create_for_file (NULL, fn);
-  data = cfg->data;
-  if (NULL == (fp = FOPEN (fn, "w")))
-    {
-      GE_LOG_STRERROR_FILE (data->ectx,
-                            GE_ERROR | GE_USER | GE_IMMEDIATE, "fopen", fn);
-      FREE (fn);
-      return -1;
-    }
-  FREE (fn);
-  error = 0;
-  ret = 0;
-  MUTEX_LOCK (data->lock);
-  for (i = 0; i < data->ssize; i++)
-    {
-      sec = &data->sections[i];
-      if (0 > fprintf (fp, "[%s]\n", sec->name))
-        {
-          error = 1;
-          break;
-        }
-      for (j = 0; j < sec->size; j++)
-        {
-          e = &sec->entries[j];
-          GE_ASSERT (data->ectx, e->dirty_val == NULL);
-          if (e->val != NULL)
-            {
-              val = MALLOC (strlen (e->val) * 2 + 1);
-              strcpy (val, e->val);
-              while (NULL != (pos = strstr (val, "\n")))
-                {
-                  memmove (&pos[2], &pos[1], strlen (&pos[1]));
-                  pos[0] = '\\';
-                  pos[1] = 'n';
-                }
-              if (0 > fprintf (fp, "%s = %s\n", e->key, val))
-                {
-                  error = 1;
-                  FREE (val);
-                  break;
-                }
-              FREE (val);
-            }
-        }
-      if (error != 0)
-        break;
-      if (0 > fprintf (fp, "\n"))
-        {
-          error = 1;
-          break;
-        }
-    }
-  if (error != 0)
-    GE_LOG_STRERROR_FILE (data->ectx,
-                          GE_ERROR | GE_USER | GE_IMMEDIATE | GE_BULK |
-                          GE_REQUEST, "fprintf", filename);
-  if (0 != fclose (fp))
-    {
-      GE_LOG_STRERROR_FILE (data->ectx,
-                            GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE |
-                            GE_BULK | GE_REQUEST, "fclose", filename);
-      error = 1;
-    }
-  if (error == 0)
-    {
-      ret = 0;
-      data->dirty = 0;          /* last write succeeded */
-    }
-  else
-    {
-      ret = -1;
-      data->dirty = -1;         /* last write failed */
-    }
-  MUTEX_UNLOCK (data->lock);
-  return ret;
-}
-
-/**
- * Call only with lock held!
- */
-static GC_Section *
-findSection (GC_ConfigurationData * data, const char *section)
-{
-  int i;
-  for (i = data->ssize - 1; i >= 0; i--)
-    if (0 == strcmp (section, data->sections[i].name))
-      return &data->sections[i];
-  return NULL;
-}
-
-/**
- * Call only with lock held!
- */
-static GC_Entry *
-findEntry (GC_ConfigurationData * data, const char *section, const char *key)
-{
-  int i;
-  GC_Section *sec;
-
-  sec = findSection (data, section);
-  if (sec == NULL)
-    return NULL;
-  for (i = sec->size - 1; i >= 0; i--)
-    if (0 == strcmp (key, sec->entries[i].key))
-      return &sec->entries[i];
-  return NULL;
-}
-
-static int
-_set_configuration_value_string (struct GC_Configuration *cfg,
-                                 struct GE_Context *ectx,
-                                 const char *section,
-                                 const char *option, const char *value)
-{
-  GC_ConfigurationData *data;
-  GC_Section *sec;
-  GC_Section nsec;
-  GC_Entry *e;
-  GC_Entry ne;
-  int ret;
-  int i;
-
-  data = cfg->data;
-  MUTEX_LOCK (data->lock);
-  e = findEntry (data, section, option);
-  if (e == NULL)
-    {
-      sec = findSection (data, section);
-      if (sec == NULL)
-        {
-          nsec.name = STRDUP (section);
-          nsec.size = 0;
-          nsec.entries = NULL;
-          APPEND (data->sections, data->ssize, nsec);
-          sec = findSection (data, section);
-        }
-      ne.key = STRDUP (option);
-      ne.val = NULL;
-      ne.dirty_val = NULL;
-      APPEND (sec->entries, sec->size, ne);
-      e = findEntry (data, section, option);
-    }
-  if (e->dirty_val != NULL)
-    {
-      if (0 == strcmp (e->dirty_val, value))
-        {
-          ret = 0;
-        }
-      else
-        {
-          /* recursive update to different value -- not allowed! */
-          GE_BREAK (ectx, 0);
-          ret = -1;
-        }
-    }
-  else
-    {
-      e->dirty_val = STRDUP (value);
-      i = data->lsize - 1;
-      while (i >= 0)
-        {
-          if (0 != data->listeners[i].listener (data->listeners[i].ctx,
-                                                cfg, ectx, section, option))
-            break;              /* update refused */
-          i--;
-          e = findEntry (data, section, option);        /* side-effects of 
callback are possible! */
-        }
-      e = findEntry (data, section, option);    /* side-effects of callback 
are possible! */
-      if (i >= 0)
-        {
-          /* update refused, revert! */
-          FREE (e->dirty_val);
-          e->dirty_val = NULL;
-          i++;                  /* the callback that refused does not need 
refreshing */
-          while (i < data->lsize)
-            {
-              if (0 != data->listeners[i].listener (data->listeners[i].ctx,
-                                                    cfg,
-                                                    ectx, section, option))
-                GE_ASSERT (ectx, 0);    /* refused the refusal!? */
-              e = findEntry (data, section, option);    /* side-effects of 
callback are possible! */
-              i++;
-            }
-          ret = -1;             /* error -- update refused */
-        }
-      else
-        {
-          /* all confirmed, commit! */
-          if ((e->val == NULL) || (0 != strcmp (e->val, e->dirty_val)))
-            data->dirty = 1;
-          FREENONNULL (e->val);
-          e->val = e->dirty_val;
-          e->dirty_val = NULL;
-          ret = 0;
-        }
-    }
-  if (ret == -1)
-    GE_LOG (ectx,
-            GE_USER | GE_BULK | GE_WARNING,
-            _
-            ("Setting option `%s' in section `%s' to value `%s' was 
refused.\n"),
-            option, section, value);
-  MUTEX_UNLOCK (data->lock);
-  return ret;
-}
-
-static int
-_set_configuration_value_number (struct GC_Configuration *cfg,
-                                 struct GE_Context *ectx,
-                                 const char *section,
-                                 const char *option,
-                                 unsigned long long number)
-{
-  char s[64];
-  SNPRINTF (s, 64, "%llu", number);
-  return _set_configuration_value_string (cfg, ectx, section, option, s);
-}
-
-static int
-_get_configuration_value_number (struct GC_Configuration *cfg,
-                                 const char *section,
-                                 const char *option,
-                                 unsigned long long min,
-                                 unsigned long long max,
-                                 unsigned long long def,
-                                 unsigned long long *number)
-{
-  GC_Entry *e;
-  const char *val;
-  int ret;
-
-  MUTEX_LOCK (cfg->data->lock);
-  e = findEntry (cfg->data, section, option);
-  if (e != NULL)
-    {
-      val = (e->dirty_val != NULL) ? e->dirty_val : e->val;
-      if (1 == SSCANF (val, "%llu", number))
-        {
-          if ((*number >= min) && (*number <= max))
-            {
-              ret = 0;
-            }
-          else
-            {
-              GE_LOG (cfg->data->ectx,
-                      GE_ERROR | GE_USER | GE_BULK,
-                      _("Configuration value '%llu' for '%s' "
-                        "in section '%s' is out of legal bounds 
[%llu,%llu]\n"),
-                      *number, option, section, min, max);
-              ret = -1;         /* error */
-            }
-        }
-      else
-        {
-          GE_LOG (cfg->data->ectx,
-                  GE_ERROR | GE_USER | GE_BULK,
-                  _("Configuration value '%s' for '%s'"
-                    " in section '%s' should be a number\n"),
-                  val, option, section, min, max);
-          ret = -1;             /* error */
-        }
-    }
-  else
-    {
-      *number = def;
-      _set_configuration_value_number (cfg,
-                                       cfg->data->ectx, section, option, def);
-      ret = 1;                  /* default */
-    }
-  MUTEX_UNLOCK (cfg->data->lock);
-  return ret;
-}
-
-static int
-_get_configuration_value_string (struct GC_Configuration *cfg,
-                                 const char *section,
-                                 const char *option,
-                                 const char *def, char **value)
-{
-  GC_Entry *e;
-  const char *val;
-  int ret;
-
-  MUTEX_LOCK (cfg->data->lock);
-  e = findEntry (cfg->data, section, option);
-  if (e != NULL)
-    {
-      val = (e->dirty_val != NULL) ? e->dirty_val : e->val;
-      *value = STRDUP (val);
-      ret = 0;
-    }
-  else
-    {
-      if (def == NULL)
-        {
-          MUTEX_UNLOCK (cfg->data->lock);
-          GE_LOG (cfg->data->ectx,
-                  GE_USER | GE_IMMEDIATE | GE_ERROR,
-                  "Configuration value for option `%s' in section `%s' 
required.\n",
-                  option, section);
-          return -1;
-        }
-      *value = STRDUP (def);
-      _set_configuration_value_string (cfg,
-                                       cfg->data->ectx, section, option, def);
-      ret = 1;                  /* default */
-    }
-  MUTEX_UNLOCK (cfg->data->lock);
-  return ret;
-}
-
-static int
-_get_configuration_value_choice (struct GC_Configuration *cfg,
-                                 const char *section,
-                                 const char *option,
-                                 const char **choices,
-                                 const char *def, const char **value)
-{
-  GC_Entry *e;
-  const char *val;
-  int i;
-  int ret;
-
-  MUTEX_LOCK (cfg->data->lock);
-  e = findEntry (cfg->data, section, option);
-  if (e != NULL)
-    {
-      val = (e->dirty_val != NULL) ? e->dirty_val : e->val;
-      i = 0;
-      while (choices[i] != NULL)
-        {
-          if (0 == strcasecmp (choices[i], val))
-            break;
-          i++;
-        }
-      if (choices[i] == NULL)
-        {
-          GE_LOG (cfg->data->ectx,
-                  GE_ERROR | GE_USER | GE_BULK,
-                  _("Configuration value '%s' for '%s'"
-                    " in section '%s' is not in set of legal choices\n"),
-                  val, option, section);
-          ret = -1;             /* error */
-        }
-      else
-        {
-          *value = choices[i];
-          ret = 0;
-        }
-    }
-  else
-    {
-      *value = def;
-      if (def == NULL)
-        ret = -1;
-      else
-        ret = 1;                /* default */
-    }
-  MUTEX_UNLOCK (cfg->data->lock);
-  return ret;
-}
-
-/**
- * Test if we have a value for a particular option
- * @return YES if so, NO if not.
- */
-static int
-_have_configuration_value (struct GC_Configuration *cfg,
-                           const char *section, const char *option)
-{
-  GC_Entry *e;
-  int ret;
-
-  MUTEX_LOCK (cfg->data->lock);
-  e = findEntry (cfg->data, section, option);
-  if (e == NULL)
-    ret = NO;
-  else
-    ret = YES;
-  MUTEX_UNLOCK (cfg->data->lock);
-  return ret;
-}
-
-/**
- * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR"
- * where either in the "PATHS" section or the environtment
- * "FOO" is set to "DIRECTORY".
- *
- * @param old string to $-expand (will be freed!)
- * @return $-expanded string
- */
-static char *
-_configuration_expand_dollar (struct GC_Configuration *cfg, char *orig)
-{
-  int i;
-  char *prefix;
-  char *result;
-  const char *post;
-
-  if (orig[0] != '$')
-    return orig;
-  i = 0;
-  while ((orig[i] != '/') && (orig[i] != '\\') && (orig[i] != '\0'))
-    i++;
-  if (orig[i] == '\0')
-    {
-      post = "";
-    }
-  else
-    {
-      orig[i] = '\0';
-      post = &orig[i + 1];
-    }
-  prefix = NULL;
-  if (YES == _have_configuration_value (cfg, "PATHS", &orig[1]))
-    {
-      if (0 != _get_configuration_value_string (cfg,
-                                                "PATHS",
-                                                &orig[1], NULL, &prefix))
-        {
-          GE_BREAK (NULL, 0);
-          return orig;
-        }
-    }
-  else
-    {
-      const char *env = getenv (&orig[1]);
-
-      if (env != NULL)
-        {
-          prefix = STRDUP (env);
-        }
-      else
-        {
-          orig[i] = DIR_SEPARATOR;
-          return orig;
-        }
-    }
-  result = MALLOC (strlen (prefix) + strlen (post) + 2);
-  strcpy (result, prefix);
-  if ((strlen (prefix) == 0) ||
-      (prefix[strlen (prefix) - 1] != DIR_SEPARATOR))
-    strcat (result, DIR_SEPARATOR_STR);
-  strcat (result, post);
-  FREE (prefix);
-  FREE (orig);
-  return result;
-}
-
-/**
- * Get a configuration value that should be a string.
- * @param def default value (use indicated by return value;
- *        will NOT be aliased, maybe NULL)
- * @param value will be set to a freshly allocated configuration
- *        value, or NULL if option is not specified and no default given
- * @return 0 on success, -1 on error, 1 for default
- */
-static int
-_get_configuration_value_filename (struct GC_Configuration *cfg,
-                                   const char *section,
-                                   const char *option,
-                                   const char *def, char **value)
-{
-  GC_ConfigurationData *data;
-  int ret;
-  char *tmp;
-
-  data = cfg->data;
-  tmp = NULL;
-  ret = _get_configuration_value_string (cfg, section, option, def, &tmp);
-  if (tmp != NULL)
-    {
-      tmp = _configuration_expand_dollar (cfg, tmp);
-      *value = string_expandFileName (data->ectx, tmp);
-      FREE (tmp);
-    }
-  else
-    {
-      *value = NULL;
-    }
-  return ret;
-}
-
-static int
-_set_configuration_value_choice (struct GC_Configuration *cfg,
-                                 struct GE_Context *ectx,
-                                 const char *section,
-                                 const char *option, const char *choice)
-{
-  return _set_configuration_value_string (cfg, ectx, section, option, choice);
-}
-
-static int
-_attach_change_listener (struct GC_Configuration *cfg,
-                         GC_ChangeListener callback, void *ctx)
-{
-  GC_Listener l;
-  int i;
-  int j;
-
-  MUTEX_LOCK (cfg->data->lock);
-  for (i = 0; i < cfg->data->ssize; i++)
-    {
-      GC_Section *s = &cfg->data->sections[i];
-      for (j = 0; j < s->size; j++)
-        {
-          GC_Entry *e = &s->entries[j];
-          if (0 != callback (ctx, cfg, cfg->data->ectx, s->name, e->key))
-            {
-              MUTEX_UNLOCK (cfg->data->lock);
-              return -1;
-            }
-          s = &cfg->data->sections[i];  /* side-effects of callback are 
possible! */
-        }
-    }
-  l.listener = callback;
-  l.ctx = ctx;
-  APPEND (cfg->data->listeners, cfg->data->lsize, l);
-  MUTEX_UNLOCK (cfg->data->lock);
-  return 0;
-}
-
-static int
-_detach_change_listener (struct GC_Configuration *cfg,
-                         GC_ChangeListener callback, void *ctx)
-{
-  int i;
-  GC_Listener *l;
-
-  MUTEX_LOCK (cfg->data->lock);
-  for (i = cfg->data->lsize - 1; i >= 0; i--)
-    {
-      l = &cfg->data->listeners[i];
-      if ((l->listener == callback) && (l->ctx == ctx))
-        {
-          cfg->data->listeners[i]
-            = cfg->data->listeners[cfg->data->lsize - 1];
-          GROW (cfg->data->listeners, cfg->data->lsize, cfg->data->lsize - 1);
-          MUTEX_UNLOCK (cfg->data->lock);
-          return 0;
-        }
-    }
-  MUTEX_UNLOCK (cfg->data->lock);
-  return -1;
-}
-
-/**
- * Create a GC_Configuration (C implementation).
- */
-GC_Configuration *
-GC_create_C_impl ()
-{
-  GC_Configuration *ret;
-
-  ret = MALLOC (sizeof (GC_Configuration));
-  ret->data = MALLOC (sizeof (GC_ConfigurationData));
-  memset (ret->data, 0, sizeof (GC_ConfigurationData));
-  ret->data->lock = MUTEX_CREATE (YES);
-  ret->free = &_free;
-  ret->set_error_context = &_set_error_context;
-  ret->parse_configuration = &_parse_configuration;
-  ret->test_dirty = &_test_dirty;
-  ret->write_configuration = &_write_configuration;
-  ret->get_configuration_value_number = &_get_configuration_value_number;
-  ret->get_configuration_value_string = &_get_configuration_value_string;
-  ret->get_configuration_value_filename = &_get_configuration_value_filename;
-  ret->get_configuration_value_choice = &_get_configuration_value_choice;
-  ret->configuration_expand_dollar = &_configuration_expand_dollar;
-  ret->set_configuration_value_number = &_set_configuration_value_number;
-  ret->set_configuration_value_string = &_set_configuration_value_string;
-  ret->set_configuration_value_choice = &_set_configuration_value_choice;
-  ret->attach_change_listener = &_attach_change_listener;
-  ret->detach_change_listener = &_detach_change_listener;
-  ret->have_configuration_value = &_have_configuration_value;
-  return ret;
-}
+#incl

Modified: GNUnet/src/util/containers/Makefile.am
===================================================================
--- GNUnet/src/util/containers/Makefile.am      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/containers/Makefile.am      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -2,23 +2,14 @@
 
 INCLUDES = -I$(top_srcdir)/src/include
 
-lib_LTLIBRARIES = libgnunetutil_containers.la
+noinst_LTLIBRARIES = libcontainers.la
 
-libgnunetutil_containers_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la 
-
-libgnunetutil_containers_la_LDFLAGS = \
- -version-info 0:0:0
-
-libgnunetutil_containers_la_SOURCES = \
+libcontainers_la_SOURCES = \
  bloomfilter.c \
- hashtable.c \
  vector.c 
 
 check_PROGRAMS = \
  bloomtest \
- hashtabletest \
  vectortest 
 
 TESTS = $(check_PROGRAMS)
@@ -26,18 +17,10 @@
 bloomtest_SOURCES = \
  bloomtest.c
 bloomtest_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/containers/libgnunetutil_containers.la 
+ $(top_builddir)/src/util/libgnunetutil.la 
 
-hashtabletest_SOURCES = \
- hashtabletest.c
-hashtabletest_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la  \
- $(top_builddir)/src/util/containers/libgnunetutil_containers.la 
-
 vectortest_SOURCES = \
  vectortest.c
 vectortest_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la  \
- $(top_builddir)/src/util/containers/libgnunetutil_containers.la   
+ $(top_builddir)/src/util/libgnunetutil.la 
 

Modified: GNUnet/src/util/containers/bloomfilter.c
===================================================================
--- GNUnet/src/util/containers/bloomfilter.c    2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/containers/bloomfilter.c    2007-11-23 11:51:54 UTC (rev 
5742)
@@ -43,13 +43,13 @@
 #include "gnunet_util_containers.h"
 #include "platform.h"
 
-typedef struct Bloomfilter
+typedef struct GNUNET_BloomFilter
 {
 
   /**
    * Concurrency control
    */
-  struct MUTEX *lock;
+  struct GNUNET_Mutex *lock;
 
   /**
    * The actual bloomfilter bit array
@@ -125,7 +125,7 @@
  *
  * @param bitArray memory area to set the bit in
  * @param bitIdx which bit to test
- * @return YES if the bit is set, NO if not.
+ * @return GNUNET_YES if the bit is set, GNUNET_NO if not.
  */
 static int
 testBit (char *bitArray, unsigned int bitIdx)
@@ -136,9 +136,9 @@
   slot = bitIdx / 8;
   targetBit = (1L << (bitIdx % 8));
   if (bitArray[slot] & targetBit)
-    return YES;
+    return GNUNET_YES;
   else
-    return NO;
+    return GNUNET_NO;
 }
 
 /**
@@ -258,7 +258,7 @@
  *
  * @param fd the file handle
  * @param size the size of the file
- * @return OK if created ok, SYSERR otherwise
+ * @return GNUNET_OK if created ok, GNUNET_SYSERR otherwise
  */
 static int
 makeEmptyFile (int fd, unsigned int size)
@@ -268,8 +268,8 @@
   int res = 0;
 
   if (fd == -1)
-    return SYSERR;
-  buffer = MALLOC (BUFFSIZE);
+    return GNUNET_SYSERR;
+  buffer = GNUNET_malloc (BUFFSIZE);
   memset (buffer, 0, BUFFSIZE);
   LSEEK (fd, 0, SEEK_SET);
 
@@ -290,15 +290,15 @@
           GE_DIE_STRERROR (NULL,
                            GE_ADMIN | GE_USER | GE_FATAL | GE_IMMEDIATE,
                            "write");
-          FREE (buffer);
-          return SYSERR;
+          GNUNET_free (buffer);
+          return GNUNET_SYSERR;
         }
     }
-  FREE (buffer);
-  return OK;
+  GNUNET_free (buffer);
+  return GNUNET_OK;
 }
 
-/* ************** Bloomfilter hash iterator ********* */
+/* ************** GNUNET_BloomFilter GNUNET_hash iterator ********* */
 
 /**
  * Iterator (callback) method to be called by the
@@ -322,19 +322,19 @@
  */
 static void
 iterateBits (Bloomfilter * bf,
-             BitIterator callback, void *arg, const HashCode512 * key)
+             BitIterator callback, void *arg, const GNUNET_HashCode * key)
 {
-  HashCode512 tmp[2];
+  GNUNET_HashCode tmp[2];
   int bitCount;
   int round;
   unsigned int slot = 0;
 
   bitCount = bf->addressesPerElement;
-  memcpy (&tmp[0], key, sizeof (HashCode512));
+  memcpy (&tmp[0], key, sizeof (GNUNET_HashCode));
   round = 0;
   while (bitCount > 0)
     {
-      while (slot < (sizeof (HashCode512) / sizeof (unsigned int)))
+      while (slot < (sizeof (GNUNET_HashCode) / sizeof (unsigned int)))
         {
           callback (bf,
                     (((unsigned int *) &tmp[round & 1])[slot]) &
@@ -346,7 +346,8 @@
         }
       if (bitCount > 0)
         {
-          hash (&tmp[round & 1], sizeof (HashCode512), &tmp[(round + 1) & 1]);
+          GNUNET_hash (&tmp[round & 1], sizeof (GNUNET_HashCode),
+                       &tmp[(round + 1) & 1]);
           round++;
           slot = 0;
         }
@@ -384,14 +385,14 @@
  *
  * @param bf the filter
  * @param bit the bit to test
- * @param arg pointer set to NO if bit is not set
+ * @param arg pointer set to GNUNET_NO if bit is not set
  */
 static void
 testBitCallback (Bloomfilter * bf, unsigned int bit, void *cls)
 {
   int *arg = cls;
-  if (NO == testBit (bf->bitArray, bit))
-    *arg = NO;
+  if (GNUNET_NO == testBit (bf->bitArray, bit))
+    *arg = GNUNET_NO;
 }
 
 /* *********************** INTERFACE **************** */
@@ -402,13 +403,14 @@
  * @param filename the name of the file (or the prefix)
  * @param size the size of the bloom-filter (number of
  *        bytes of storage space to use)
- * @param k the number of hash-functions to apply per
+ * @param k the number of GNUNET_hash-functions to apply per
  *        element (number of bits set per element in the set)
  * @return the bloomfilter
  */
 Bloomfilter *
-loadBloomfilter (struct GE_Context *ectx,
-                 const char *filename, unsigned int size, unsigned int k)
+GNUNET_bloomfilter_load (struct GE_Context *ectx,
+                         const char *filename, unsigned int size,
+                         unsigned int k)
 {
   Bloomfilter *bf;
   char *rbuff;
@@ -425,25 +427,26 @@
     ui *= 2;
   size = ui;                    /* make sure it's a power of 2 */
 
-  bf = MALLOC (sizeof (Bloomfilter));
+  bf = GNUNET_malloc (sizeof (Bloomfilter));
   bf->ectx = ectx;
   /* Try to open a bloomfilter file */
   if (filename != NULL)
     {
 #ifndef _MSC_VER
-      bf->fd = disk_file_open (ectx,
-                               filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+      bf->fd = GNUNET_disk_file_open (ectx,
+                                      filename, O_RDWR | O_CREAT,
+                                      S_IRUSR | S_IWUSR);
 #else
-      bf->fd = disk_file_open (ectx,
-                               filename,
-                               O_WRONLY | O_CREAT, S_IREAD | S_IWRITE);
+      bf->fd = GNUNET_disk_file_open (ectx,
+                                      filename,
+                                      O_WRONLY | O_CREAT, S_IREAD | S_IWRITE);
 #endif
       if (-1 == bf->fd)
         {
-          FREE (bf);
+          GNUNET_free (bf);
           return NULL;
         }
-      bf->filename = STRDUP (filename);
+      bf->filename = GNUNET_strdup (filename);
     }
   else
     {
@@ -451,8 +454,8 @@
       bf->filename = NULL;
     }
   /* Alloc block */
-  bf->lock = MUTEX_CREATE (YES);
-  bf->bitArray = MALLOC_LARGE (size);
+  bf->lock = GNUNET_mutex_create (GNUNET_YES);
+  bf->bitArray = GNUNET_malloc_large (size);
   bf->bitArraySize = size;
   bf->addressesPerElement = k;
   memset (bf->bitArray, 0, bf->bitArraySize);
@@ -460,7 +463,7 @@
   if (bf->fd != -1)
     {
       /* Read from the file what bits we can */
-      rbuff = MALLOC (BUFFSIZE);
+      rbuff = GNUNET_malloc (BUFFSIZE);
       pos = 0;
       while (pos < size * 8)
         {
@@ -480,7 +483,7 @@
             break;
           pos += BUFFSIZE * 2;  /* 2 bits per byte in the buffer */
         }
-      FREE (rbuff);
+      GNUNET_free (rbuff);
     }
   return bf;
 }
@@ -493,16 +496,16 @@
  * @param bf the filter
  */
 void
-freeBloomfilter (Bloomfilter * bf)
+GNUNET_bloomfilter_free (Bloomfilter * bf)
 {
   if (NULL == bf)
     return;
-  MUTEX_DESTROY (bf->lock);
+  GNUNET_mutex_destroy (bf->lock);
   if (bf->fd != -1)
-    disk_file_close (bf->ectx, bf->filename, bf->fd);
-  FREENONNULL (bf->filename);
-  FREE (bf->bitArray);
-  FREE (bf);
+    GNUNET_disk_file_close (bf->ectx, bf->filename, bf->fd);
+  GNUNET_free_non_null (bf->filename);
+  GNUNET_free (bf->bitArray);
+  GNUNET_free (bf);
 }
 
 /**
@@ -511,16 +514,16 @@
  * @param bf the filter
  */
 void
-resetBloomfilter (Bloomfilter * bf)
+GNUNET_bloomfilter_clear (Bloomfilter * bf)
 {
   if (NULL == bf)
     return;
 
-  MUTEX_LOCK (bf->lock);
+  GNUNET_mutex_lock (bf->lock);
   memset (bf->bitArray, 0, bf->bitArraySize);
   if (bf->fd != -1)
     makeEmptyFile (bf->fd, bf->bitArraySize * 4);
-  MUTEX_UNLOCK (bf->lock);
+  GNUNET_mutex_unlock (bf->lock);
 }
 
 
@@ -529,19 +532,19 @@
  *
  * @param e the element
  * @param bf the filter
- * @return YES if the element is in the filter, NO if not
+ * @return GNUNET_YES if the element is in the filter, GNUNET_NO if not
  */
 int
-testBloomfilter (Bloomfilter * bf, const HashCode512 * e)
+GNUNET_bloomfilter_test (Bloomfilter * bf, const GNUNET_HashCode * e)
 {
   int res;
 
   if (NULL == bf)
-    return YES;
-  MUTEX_LOCK (bf->lock);
-  res = YES;
+    return GNUNET_YES;
+  GNUNET_mutex_lock (bf->lock);
+  res = GNUNET_YES;
   iterateBits (bf, &testBitCallback, &res, e);
-  MUTEX_UNLOCK (bf->lock);
+  GNUNET_mutex_unlock (bf->lock);
   return res;
 }
 
@@ -552,14 +555,14 @@
  * @param e the element
  */
 void
-addToBloomfilter (Bloomfilter * bf, const HashCode512 * e)
+GNUNET_bloomfilter_add (Bloomfilter * bf, const GNUNET_HashCode * e)
 {
 
   if (NULL == bf)
     return;
-  MUTEX_LOCK (bf->lock);
+  GNUNET_mutex_lock (bf->lock);
   iterateBits (bf, &incrementBitCallback, NULL, e);
-  MUTEX_UNLOCK (bf->lock);
+  GNUNET_mutex_unlock (bf->lock);
 }
 
 /**
@@ -569,13 +572,13 @@
  * @param e the element to remove
  */
 void
-delFromBloomfilter (Bloomfilter * bf, const HashCode512 * e)
+GNUNET_bloomfilter_remove (Bloomfilter * bf, const GNUNET_HashCode * e)
 {
   if (NULL == bf)
     return;
-  MUTEX_LOCK (bf->lock);
+  GNUNET_mutex_lock (bf->lock);
   iterateBits (bf, &decrementBitCallback, NULL, e);
-  MUTEX_UNLOCK (bf->lock);
+  GNUNET_mutex_unlock (bf->lock);
 }
 
 /**
@@ -587,36 +590,37 @@
  * @param iterator an iterator over all elements stored in the BF
  * @param iterator_arg argument to the iterator function
  * @param size the new size for the filter
- * @param k the new number of hash-function to apply per element
+ * @param k the new number of GNUNET_hash-function to apply per element
  */
 void
-resizeBloomfilter (Bloomfilter * bf,
-                   ElementIterator iterator,
-                   void *iterator_arg, unsigned int size, unsigned int k)
+GNUNET_bloomfilter_resize (Bloomfilter * bf,
+                           GNUNET_HashCodeIterator iterator,
+                           void *iterator_arg, unsigned int size,
+                           unsigned int k)
 {
-  HashCode512 *e;
+  GNUNET_HashCode *e;
   unsigned int i;
 
-  MUTEX_LOCK (bf->lock);
-  FREE (bf->bitArray);
+  GNUNET_mutex_lock (bf->lock);
+  GNUNET_free (bf->bitArray);
   i = 1;
   while (i < size)
     i *= 2;
   size = i;                     /* make sure it's a power of 2 */
 
   bf->bitArraySize = size;
-  bf->bitArray = MALLOC (size);
+  bf->bitArray = GNUNET_malloc (size);
   memset (bf->bitArray, 0, bf->bitArraySize);
   if (bf->fd != -1)
     makeEmptyFile (bf->fd, bf->bitArraySize * 4);
   e = iterator (iterator_arg);
   while (e != NULL)
     {
-      addToBloomfilter (bf, e);
-      FREE (e);
+      GNUNET_bloomfilter_add (bf, e);
+      GNUNET_free (e);
       e = iterator (iterator_arg);
     }
-  MUTEX_UNLOCK (bf->lock);
+  GNUNET_mutex_unlock (bf->lock);
 }
 
 /* ******************** end of bloomfilter.c *********** */

Modified: GNUnet/src/util/containers/bloomtest.c
===================================================================
--- GNUnet/src/util/containers/bloomtest.c      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/containers/bloomtest.c      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -35,35 +35,35 @@
  * Generate a random hashcode.
  */
 static void
-nextHC (HashCode512 * hc)
+nextHC (GNUNET_HashCode * hc)
 {
-  makeRandomId (hc);
+  GNUNET_create_random_hash (hc);
 }
 
 int
 main (int argc, char *argv[])
 {
-  struct Bloomfilter *bf;
-  HashCode512 tmp;
+  struct GNUNET_BloomFilter *bf;
+  GNUNET_HashCode tmp;
   int i;
   int ok;
   int falseok;
 
   srand (1);
   UNLINK ("/tmp/bloomtest.dat");
-  bf = loadBloomfilter (NULL, "/tmp/bloomtest.dat", SIZE, K);
+  bf = GNUNET_bloomfilter_load (NULL, "/tmp/bloomtest.dat", SIZE, K);
 
   for (i = 0; i < 200; i++)
     {
       nextHC (&tmp);
-      addToBloomfilter (bf, &tmp);
+      GNUNET_bloomfilter_add (bf, &tmp);
     }
   srand (1);
   ok = 0;
   for (i = 0; i < 200; i++)
     {
       nextHC (&tmp);
-      if (testBloomfilter (bf, &tmp) == YES)
+      if (GNUNET_bloomfilter_test (bf, &tmp) == GNUNET_YES)
         ok++;
     }
   if (ok != 200)
@@ -72,17 +72,17 @@
               "200 expected after insertion.\n", ok);
       return -1;
     }
-  freeBloomfilter (bf);
+  GNUNET_bloomfilter_free (bf);
 
 
-  bf = loadBloomfilter (NULL, "/tmp/bloomtest.dat", SIZE, K);
+  bf = GNUNET_bloomfilter_load (NULL, "/tmp/bloomtest.dat", SIZE, K);
 
   srand (1);
   ok = 0;
   for (i = 0; i < 200; i++)
     {
       nextHC (&tmp);
-      if (testBloomfilter (bf, &tmp) == YES)
+      if (GNUNET_bloomfilter_test (bf, &tmp) == GNUNET_YES)
         ok++;
     }
   if (ok != 200)
@@ -96,7 +96,7 @@
   for (i = 0; i < 100; i++)
     {
       nextHC (&tmp);
-      delFromBloomfilter (bf, &tmp);
+      GNUNET_bloomfilter_remove (bf, &tmp);
     }
 
   srand (1);
@@ -105,7 +105,7 @@
   for (i = 0; i < 200; i++)
     {
       nextHC (&tmp);
-      if (testBloomfilter (bf, &tmp) == YES)
+      if (GNUNET_bloomfilter_test (bf, &tmp) == GNUNET_YES)
         ok++;
     }
 
@@ -122,11 +122,11 @@
   for (i = 0; i < 1000; i++)
     {
       nextHC (&tmp);
-      if (testBloomfilter (bf, &tmp) == YES)
+      if (GNUNET_bloomfilter_test (bf, &tmp) == GNUNET_YES)
         falseok++;
     }
 
-  freeBloomfilter (bf);
+  GNUNET_bloomfilter_free (bf);
 
   UNLINK ("/tmp/bloomtest.dat");
   return 0;

Deleted: GNUnet/src/util/containers/hashtable.c
===================================================================
--- GNUnet/src/util/containers/hashtable.c      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/containers/hashtable.c      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -1,510 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2006 Christian Grothoff (and other contributing authors)
-
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-
-     Based on http://www.pomakis.com/hashtable/hashtable.c which is public
-     domain
-*/
-
-/**
- * @brief Hashtable implementation
- * @author Keith Pomakis
- * @author Nils Durner
- * @file util/hashtable.c
- */
-
-#include "gnunet_util.h"
-#include "gnunet_util_containers.h"
-#include "platform.h"
-
-typedef struct KeyValuePair
-{
-  void *key;
-  unsigned long keylen;
-  void *value;
-  unsigned long valuelen;
-  struct KeyValuePair *next;
-} KeyValuePair;
-
-typedef struct HashTable
-{
-  long numOfBuckets;
-  long numOfElements;
-  KeyValuePair **bucketArray;
-  float idealRatio;
-  float lowerRehashThreshold;
-  float upperRehashThreshold;
-} HashTable;
-
-/**
- * @brief Create a cryptographically weak hashcode from a buffer
- * @param z the buffer to hash
- * @param n the size of z
- * @return the hashcode
- */
-static unsigned long long
-weakHash (const char *z, int n)
-{
-  unsigned long long h = 0;
-  while (n > 0)
-    {
-      h = (h << 3) ^ h ^ (unsigned char) *z++;
-      n--;
-    }
-  return h;
-}
-
-
-static int
-isProbablePrime (long oddNumber)
-{
-  long i;
-
-  for (i = 3; i < 51; i += 2)
-    if (oddNumber == i)
-      return 1;
-    else if (oddNumber % i == 0)
-      return 0;
-
-  return 1;                     /* maybe */
-}
-
-static long
-calculateIdealNumOfBuckets (const struct HashTable *hashTable)
-{
-  long idealNumOfBuckets = hashTable->numOfElements / hashTable->idealRatio;
-  if (idealNumOfBuckets < 5)
-    idealNumOfBuckets = 5;
-  else
-    idealNumOfBuckets |= 0x01;  /* make it an odd number */
-  while (!isProbablePrime (idealNumOfBuckets))
-    idealNumOfBuckets += 2;
-
-  return idealNumOfBuckets;
-}
-
-
-/**
- * @brief creates a new HashTable
- * @param numOfBuckets the number of buckets to start the HashTable out with.
- *                     Must be greater than zero, and should be prime.
- *                     Ideally, the number of buckets should between 1/5
- *                     and 1 times the expected number of elements in the
- *                     HashTable.  Values much more or less than this will
- *                     result in wasted memory or decreased performance
- *                     respectively.  The number of buckets in a HashTable
- *                     can be re-calculated to an appropriate number by
- *                     calling the HashTableRehash() function once the
- *                     HashTable has been populated.  The number of buckets
- *                     in a HashTable may also be re-calculated
- *                     automatically if the ratio of elements to buckets
- *                     passes the thresholds set by ht_setIdealRatio().
- * @return a new Hashtable, or NULL on error
- */
-struct HashTable *
-ht_create (long numOfBuckets)
-{
-  struct HashTable *hashTable;
-  int i;
-
-  if (numOfBuckets <= 0)
-    return NULL;
-
-  hashTable = (struct HashTable *) MALLOC (sizeof (struct HashTable));
-  if (hashTable == NULL)
-    return NULL;
-
-  hashTable->bucketArray = (KeyValuePair **)
-    MALLOC (numOfBuckets * sizeof (KeyValuePair *));
-  if (hashTable->bucketArray == NULL)
-    {
-      FREE (hashTable);
-      return NULL;
-    }
-
-  hashTable->numOfBuckets = numOfBuckets;
-  hashTable->numOfElements = 0;
-
-  for (i = 0; i < numOfBuckets; i++)
-    hashTable->bucketArray[i] = NULL;
-
-  hashTable->idealRatio = 3.0;
-  hashTable->lowerRehashThreshold = 0.0;
-  hashTable->upperRehashThreshold = 15.0;
-
-  return hashTable;
-}
-
-/**
- * @brief destroys an existing HashTable
- * @param hashTable the HashTable to destroy
- */
-void
-ht_destroy (struct HashTable *hashTable)
-{
-  int i;
-
-  for (i = 0; i < hashTable->numOfBuckets; i++)
-    {
-      KeyValuePair *pair = hashTable->bucketArray[i];
-      while (pair != NULL)
-        {
-          KeyValuePair *nextPair = pair->next;
-          FREE (pair->key);
-          FREE (pair->value);
-          FREE (pair);
-          pair = nextPair;
-        }
-    }
-
-  FREE (hashTable->bucketArray);
-  FREE (hashTable);
-}
-
-/**
- * @brief checks the existence of a key in a HashTable
- * @param hashTable the HashTable to search
- * @param key the key to search for
- * @return whether or not the specified HashTable contains the
- *         specified key
- */
-int
-ht_containsKey (const struct HashTable *hashTable,
-                const void *key, const unsigned int keylen)
-{
-  void *ret;
-  unsigned int retlen;
-
-  return ht_get (hashTable, key, keylen, &ret, &retlen);
-}
-
-/**
- * @brief checks the existence of a value in a HashTable
- * @param hashTable the HashTable to search
- * @param value the value to search for
- * @return whether or not the specified HashTable contains the
- *         specified value
- */
-int
-ht_containsValue (const struct HashTable *hashTable,
-                  const void *value, const unsigned int valuelen)
-{
-  int i;
-
-  for (i = 0; i < hashTable->numOfBuckets; i++)
-    {
-      KeyValuePair *pair = hashTable->bucketArray[i];
-      while (pair != NULL)
-        {
-          if ((pair->valuelen == valuelen) &&
-              (memcmp (value, pair->value, valuelen) == 0))
-            return 1;
-          pair = pair->next;
-        }
-    }
-
-  return 0;
-}
-
-/**
- * @brief adds a key/value pair to a HashTable
- * @param hashTable the HashTable to add to
- * @param key the key to add or whose value to replace
- * @param value the value associated with the key
- * @return YES if successful, NO if an error was encountered
- */
-int
-ht_put (struct HashTable *hashTable,
-        const void *key,
-        const unsigned int keylen, void *value, const unsigned int valuelen)
-{
-  long hashValue;
-  KeyValuePair *pair;
-
-  if (key == NULL || value == NULL)
-    return NO;
-
-  hashValue = weakHash (key, keylen) % hashTable->numOfBuckets;
-  pair = hashTable->bucketArray[hashValue];
-
-  while (pair)
-    {
-      if (pair->keylen == keylen)
-        if (memcmp (key, pair->key, keylen) == 0)
-          break;
-      pair = pair->next;
-    }
-
-  if (pair)
-    {
-      pair->key = REALLOC (pair->key, keylen);
-      memcpy (pair->key, key, keylen);
-      pair->keylen = keylen;
-
-      pair->key = REALLOC (value, valuelen);
-      memcpy (pair->value, value, valuelen);
-      pair->valuelen = valuelen;
-    }
-  else
-    {
-      KeyValuePair *newPair = MALLOC (sizeof (KeyValuePair));
-      if (newPair == NULL)
-        return NO;
-      else
-        {
-          newPair->key = MALLOC (keylen);
-          memcpy (newPair->key, key, keylen);
-          newPair->keylen = keylen;
-          newPair->value = MALLOC (valuelen);
-          memcpy (newPair->value, value, valuelen);
-          newPair->valuelen = valuelen;
-          newPair->next = hashTable->bucketArray[hashValue];
-          hashTable->bucketArray[hashValue] = newPair;
-          hashTable->numOfElements++;
-
-          if (hashTable->upperRehashThreshold > hashTable->idealRatio)
-            {
-              float elementToBucketRatio = (float) hashTable->numOfElements /
-                (float) hashTable->numOfBuckets;
-              if (elementToBucketRatio > hashTable->upperRehashThreshold)
-                ht_rehash (hashTable, 0);
-            }
-        }
-    }
-
-  return YES;
-}
-
-/**
- * @brief retrieves the value of a key in a HashTable
- * @param hashTable the HashTable to search
- * @param key the key whose value is desired
- * @param value the corresponding value
- * @param valuelen the length of the value
- * @return YES if found, NO otherwise
- */
-int
-ht_get (const struct HashTable *hashTable,
-        const void *key,
-        const unsigned int keylen, void **value, unsigned int *valuelen)
-{
-  long hashValue = weakHash (key, keylen) % hashTable->numOfBuckets;
-  KeyValuePair *pair = hashTable->bucketArray[hashValue];
-
-  while (pair != NULL && keylen != pair->keylen
-         && memcmp (key, pair->key, keylen) != 0)
-    pair = pair->next;
-
-  if (pair != NULL)
-    {
-      *value = pair->value;
-      *valuelen = pair->valuelen;
-    }
-
-  return pair != NULL;
-}
-
-/**
- * @brief removes a key/value pair from a HashTable
- * @param hashTable the HashTable to remove the key/value pair from
- * @param key the key specifying the key/value pair to be removed
- */
-void
-ht_remove (struct HashTable *hashTable,
-           const void *key, const unsigned int keylen)
-{
-  long hashValue = weakHash (key, keylen) % hashTable->numOfBuckets;
-  KeyValuePair *pair = hashTable->bucketArray[hashValue];
-  KeyValuePair *previousPair = NULL;
-
-  while (pair != NULL && pair->keylen != keylen &&
-         memcmp (pair->key, key, keylen) != 0)
-    {
-      previousPair = pair;
-      pair = pair->next;
-    }
-
-  if (pair != NULL)
-    {
-      FREE (pair->key);
-      FREE (pair->value);
-      if (previousPair != NULL)
-        previousPair->next = pair->next;
-      else
-        hashTable->bucketArray[hashValue] = pair->next;
-      FREE (pair);
-      hashTable->numOfElements--;
-
-      if (hashTable->lowerRehashThreshold > 0.0)
-        {
-          float elementToBucketRatio = (float) hashTable->numOfElements /
-            (float) hashTable->numOfBuckets;
-          if (elementToBucketRatio < hashTable->lowerRehashThreshold)
-            ht_rehash (hashTable, 0);
-        }
-    }
-}
-
-/**
- * @brief removes all key/value pairs from a HashTable
- * @param hashTable the HashTable to remove all key/value pairs from
- */
-void
-ht_removeAll (struct HashTable *hashTable)
-{
-  int i;
-
-  for (i = 0; i < hashTable->numOfBuckets; i++)
-    {
-      KeyValuePair *pair = hashTable->bucketArray[i];
-      while (pair != NULL)
-        {
-          KeyValuePair *nextPair = pair->next;
-          FREE (pair->key);
-          FREE (pair->value);
-          FREE (pair);
-          pair = nextPair;
-        }
-      hashTable->bucketArray[i] = NULL;
-    }
-
-  hashTable->numOfElements = 0;
-  ht_rehash (hashTable, 5);
-}
-
-/**
- * @brief returns the number of elements in a HashTable
- * @param hashTable the HashTable whose size is requested
- * @return the number of key/value pairs that are present in
- *         the specified HashTable
- */
-long
-ht_size (const struct HashTable *hashTable)
-{
-  return hashTable->numOfElements;
-}
-
-/**
- * @brief returns the number of buckets in a HashTable
- * @param hashTable the HashTable whose number of buckets is requested
- * @return the number of buckets that are in the specified
- *         HashTable
- */
-long
-ht_buckets (const struct HashTable *hashTable)
-{
-  return hashTable->numOfBuckets;
-}
-
-/**
- * @brief reorganizes a HashTable to be more efficient
- * @param hashTable the HashTable to be reorganized
- * @param numOfBuckets the number of buckets to rehash the HashTable to.
- *                     Should be prime.  Ideally, the number of buckets
- *                     should be between 1/5 and 1 times the expected
- *                     number of elements in the HashTable.  Values much
- *                     more or less than this will result in wasted memory
- *                     or decreased performance respectively.  If 0 is
- *                     specified, an appropriate number of buckets is
- *                     automatically calculated.
- */
-void
-ht_rehash (struct HashTable *hashTable, long numOfBuckets)
-{
-  KeyValuePair **newBucketArray;
-  int i;
-
-  if (numOfBuckets == 0)
-    numOfBuckets = calculateIdealNumOfBuckets (hashTable);
-
-  if (numOfBuckets == hashTable->numOfBuckets)
-    return;                     /* already the right size! */
-
-  newBucketArray = (KeyValuePair **)
-    MALLOC (numOfBuckets * sizeof (KeyValuePair *));
-  if (newBucketArray == NULL)
-    {
-      /* Couldn't allocate memory for the new array.  This isn't a fatal
-       * error; we just can't perform the rehash. */
-      return;
-    }
-
-  for (i = 0; i < numOfBuckets; i++)
-    newBucketArray[i] = NULL;
-
-  for (i = 0; i < hashTable->numOfBuckets; i++)
-    {
-      KeyValuePair *pair = hashTable->bucketArray[i];
-      while (pair != NULL)
-        {
-          KeyValuePair *nextPair = pair->next;
-          long hashValue = weakHash (pair->key, pair->keylen) % numOfBuckets;
-          pair->next = newBucketArray[hashValue];
-          newBucketArray[hashValue] = pair;
-          pair = nextPair;
-        }
-    }
-
-  FREE (hashTable->bucketArray);
-  hashTable->bucketArray = newBucketArray;
-  hashTable->numOfBuckets = numOfBuckets;
-}
-
-/**
- * @brief sets the ideal element-to-bucket ratio of a HashTable
- * @param hashTable a HashTable
- * @param idealRatio the ideal element-to-bucket ratio.  When a rehash
- *                   occurs (either manually via a call to the
- *                   HashTableRehash() function or automatically due the
- *                   the triggering of one of the thresholds below), the
- *                   number of buckets in the HashTable will be
- *                   recalculated to be a prime number that achieves (as
- *                   closely as possible) this ideal ratio.  Must be a
- *                   positive number.
- * @param lowerRehashThreshold the element-to-bucket ratio that is considered
- *                     unacceptably low (i.e., too few elements per bucket).
- *                     If the actual ratio falls below this number, a
- *                     rehash will automatically be performed.  Must be
- *                     lower than the value of idealRatio.  If no ratio
- *                     is considered unacceptably low, a value of 0.0 can
- *                     be specified.
- * @param upperRehashThreshold the element-to-bucket ratio that is considered
- *                     unacceptably high (i.e., too many elements per bucket).
- *                     If the actual ratio rises above this number, a
- *                     rehash will automatically be performed.  Must be
- *                     higher than idealRatio.  However, if no ratio
- *                     is considered unacceptably high, a value of 0.0 can
- *                     be specified.
- */
-void
-ht_setIdealRatio (struct HashTable *hashTable,
-                  float idealRatio,
-                  float lowerRehashThreshold, float upperRehashThreshold)
-{
-
-  if (idealRatio <= 0.0 || lowerRehashThreshold >= idealRatio ||
-      (upperRehashThreshold != 0.0 || upperRehashThreshold <= idealRatio))
-    return;
-
-  hashTable->idealRatio = idealRatio;
-  hashTable->lowerRehashThreshold = lowerRehashThreshold;
-  hashTable->upperRehashThreshold = upperRehashThreshold;
-}
-
-
-/* end of hashtable.c */

Deleted: GNUnet/src/util/containers/hashtabletest.c
===================================================================
--- GNUnet/src/util/containers/hashtabletest.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/containers/hashtabletest.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -1,115 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2006 Christian Grothoff (and other contributing authors)
-
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-*/
-/**
- * @file util/containers/hashtabletest.c
- * @brief testcase for util/containers/hashtable.c
- * @author Nils Durner
- */
-
-#include "gnunet_util.h"
-#include "gnunet_util_containers.h"
-#include "platform.h"
-
-static int
-testHT ()
-{
-  struct HashTable *ht = ht_create (3);
-  void *val;
-  unsigned int vallen;
-
-  if (HT_PUT (ht, "Sweden", "Stockholm") != YES ||
-      HT_PUT (ht, "Germany", "Berlin") != YES ||
-      HT_PUT (ht, "France", "Paris") != YES ||
-      HT_PUT (ht, "Spain", "Madrid") != YES ||
-      HT_PUT (ht, "Italy", "Rome") != YES ||
-      HT_PUT (ht, "USA", "Washington") != YES)
-    {
-      puts ("ht_put failed\n");
-      ht_destroy (ht);
-      return 1;
-    }
-
-  if (HT_CONTAINS_KEY (ht, "France") != YES ||
-      HT_CONTAINS_KEY (ht, "Iceland") != NO)
-    {
-      puts ("ht_contains_key failed!\n");
-      ht_destroy (ht);
-      return 1;
-    }
-
-  if (HT_CONTAINS_VALUE (ht, "Paris") != YES ||
-      HT_CONTAINS_VALUE (ht, "London") != NO)
-    {
-      puts ("ht_contains_value failed!\n");
-      ht_destroy (ht);
-      return 1;
-    }
-
-  if (HT_GET (ht, "USA", &val, &vallen) != YES)
-    {
-      puts ("ht_get failed!\n");
-      ht_destroy (ht);
-      return 1;
-    }
-
-  if (strcmp ((char *) val, "Washington") != 0)
-    {
-      puts ("ht_get result invalid!\n");
-      ht_destroy (ht);
-      return 1;
-    }
-
-  HT_REMOVE (ht, "Spain");
-  if (HT_CONTAINS_KEY (ht, "Spain") != NO)
-    {
-      puts ("ht_remove failed!\n");
-      ht_destroy (ht);
-      return 1;
-    }
-
-  if (ht_size (ht) != 5)
-    {
-      puts ("ht_size failed!\n");
-      ht_destroy (ht);
-      return 1;
-    }
-
-  ht_removeAll (ht);
-  if (ht_size (ht) != 0)
-    {
-      puts ("ht_size#2 failed!\n");
-      ht_destroy (ht);
-      return 1;
-    }
-
-  ht_destroy (ht);
-
-  return 0;
-}
-
-int
-main (int argc, char *argv[])
-{
-  int ret = 0;
-
-  ret = testHT ();
-
-  return ret;
-}

Modified: GNUnet/src/util/containers/hashtest.c
===================================================================
--- GNUnet/src/util/containers/hashtest.c       2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/containers/hashtest.c       2007-11-23 11:51:54 UTC (rev 
5742)
@@ -12,16 +12,16 @@
 static int
 parseCommandLine (int argc, char *argv[])
 {
-  return OK;
+  return GNUNET_OK;
 }
 
 int
 main (int argc, char *argv[])
 {
-  HashCode512 hc;
+  GNUNET_HashCode hc;
 
   initUtil (argc, argv, &parseCommandLine);
-  hash ("TEST", 4, &hc);
+  GNUNET_hash ("TEST", 4, &hc);
   if ((hc.bits[0] != ntohl (2080019878)) ||
       (hc.bits[1] != ntohl (-2003678137)) ||
       (hc.bits[2] != ntohl (-942529663)) ||
@@ -34,7 +34,7 @@
               ntohl (hc.bits[2]), ntohl (hc.bits[3]), ntohl (hc.bits[4]));
       return -1;
     }
-  hash (NULL, 0, &hc);
+  GNUNET_hash (NULL, 0, &hc);
   if ((hc.bits[0] != ntohl (-813440715)) ||
       (hc.bits[1] != ntohl (2129639613)) ||
       (hc.bits[2] != ntohl (-246142896)) ||

Modified: GNUnet/src/util/containers/vector.c
===================================================================
--- GNUnet/src/util/containers/vector.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/containers/vector.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -43,7 +43,7 @@
 #include "gnunet_util.h"
 #include "gnunet_util_containers.h"
 
-typedef struct Vector
+typedef struct GNUNET_Vector
 {
   unsigned int VECTOR_SEGMENT_SIZE;
   struct vector_segment_t *segmentsHead;
@@ -67,7 +67,7 @@
  * sizes of the segments. This currently isn't used.
  */
 void
-vectorDump (Vector * v)
+GNUNET_vector_dump (Vector * v)
 {
   VectorSegment *vs;
   int n;
@@ -119,8 +119,8 @@
   int moveCount;
 
   oldNext = vs->next;
-  vs->next = MALLOC (sizeof (VectorSegment));
-  vs->next->data = MALLOC (v->VECTOR_SEGMENT_SIZE * sizeof (void *));
+  vs->next = GNUNET_malloc (sizeof (VectorSegment));
+  vs->next->data = GNUNET_malloc (v->VECTOR_SEGMENT_SIZE * sizeof (void *));
   vs->next->previous = vs;
   vs->next->next = oldNext;
   if (NULL != oldNext)
@@ -146,8 +146,8 @@
   memcpy (vs->data + vs->size,
           vs->next->data, vs->next->size * sizeof (void *));
   vs->size += vs->next->size;
-  FREE (vs->next->data);
-  FREE (vs->next);
+  GNUNET_free (vs->next->data);
+  GNUNET_free (vs->next);
   vs->next = oldNext;
   if (oldNext != NULL)
     vs->next->previous = vs;
@@ -171,8 +171,8 @@
     vs->next->previous = vs->previous;
   else
     v->segmentsTail = vs->previous;
-  FREE (vs->data);
-  FREE (vs);
+  GNUNET_free (vs->data);
+  GNUNET_free (vs);
 }
 
 
@@ -293,17 +293,17 @@
  * Allocate a new vector structure with a single empty data segment.
  */
 Vector *
-vectorNew (unsigned int vss)
+GNUNET_vector_create (unsigned int vss)
 {
   Vector *rvalue;
 
   if (vss < 2)
     return NULL;                /* invalid! */
-  rvalue = MALLOC (sizeof (Vector));
+  rvalue = GNUNET_malloc (sizeof (Vector));
   rvalue->VECTOR_SEGMENT_SIZE = vss;
   rvalue->size = 0;
-  rvalue->segmentsHead = MALLOC (sizeof (VectorSegment));
-  rvalue->segmentsHead->data = MALLOC (sizeof (void *) * vss);
+  rvalue->segmentsHead = GNUNET_malloc (sizeof (VectorSegment));
+  rvalue->segmentsHead->data = GNUNET_malloc (sizeof (void *) * vss);
   rvalue->segmentsTail = rvalue->segmentsHead;
   rvalue->segmentsHead->next = NULL;
   rvalue->segmentsHead->previous = NULL;
@@ -319,7 +319,7 @@
  * when necessary to avoid memory leakage.
  */
 void
-vectorFree (Vector * v)
+GNUNET_vector_destroy (Vector * v)
 {
   VectorSegment *vs;
   VectorSegment *vsNext;
@@ -328,39 +328,39 @@
   while (vs != NULL)
     {
       vsNext = vs->next;
-      FREE (vs->data);
-      FREE (vs);
+      GNUNET_free (vs->data);
+      GNUNET_free (vs);
       vs = vsNext;
     }
-  FREE (v);
+  GNUNET_free (v);
 }
 
 /**
  * Return the size of the vector.
  */
 size_t
-vectorSize (Vector * v)
+GNUNET_vector_get_size (Vector * v)
 {
   return v->size;
 }
 
 /**
  * Insert a new element in the vector at given index. The return value is
- * OK on success, SYSERR if the index is out of bounds.
+ * GNUNET_OK on success, GNUNET_SYSERR if the index is out of bounds.
  */
 int
-vectorInsertAt (Vector * v, void *object, unsigned int index)
+GNUNET_vector_insert_at (Vector * v, void *object, unsigned int index)
 {
   VectorSegment *segment;
   int segmentIndex;
   int i;
 
   if (index > v->size)
-    return SYSERR;
+    return GNUNET_SYSERR;
   v->iteratorSegment = NULL;
   segmentIndex = vectorFindNewIndex (v, index, &segment);
   if (segmentIndex == -1)
-    return SYSERR;
+    return GNUNET_SYSERR;
   for (i = segment->size; i > segmentIndex; i--)
     segment->data[i] = segment->data[i - 1];
   segment->data[segmentIndex] = object;
@@ -368,14 +368,14 @@
   segment->size++;
   if (segment->size == v->VECTOR_SEGMENT_SIZE)
     vectorSegmentSplit (v, segment);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Insert a new element at the end of the vector.
  */
 void
-vectorInsertLast (Vector * v, void *object)
+GNUNET_vector_insert_last (Vector * v, void *object)
 {
   v->iteratorSegment = NULL;
   v->segmentsTail->data[v->segmentsTail->size++] = object;
@@ -389,7 +389,7 @@
  * of bounds. The iterator is set to point to the returned element.
  */
 void *
-vectorGetAt (Vector * v, unsigned int index)
+GNUNET_vector_get (Vector * v, unsigned int index)
 {
   int ret;
   if ((index < 0) || (index >= v->size))
@@ -407,7 +407,7 @@
  * element.
  */
 void *
-vectorGetFirst (Vector * v)
+GNUNET_vector_get_first (Vector * v)
 {
   if (v->size == 0)
     return NULL;
@@ -421,7 +421,7 @@
  * empty. The iterator of the vector is set to the last element.
  */
 void *
-vectorGetLast (Vector * v)
+GNUNET_vector_get_last (Vector * v)
 {
   if (v->size == 0)
     return NULL;
@@ -436,7 +436,7 @@
  * in the vector or if the iterator has not been set.
  */
 void *
-vectorGetNext (Vector * v)
+GNUNET_vector_get_next (Vector * v)
 {
   if (v->iteratorSegment == NULL)
     return NULL;
@@ -462,7 +462,7 @@
  * elements in the vector or if the iterator has not been set.
  */
 void *
-vectorGetPrevious (Vector * v)
+GNUNET_vector_get_prev (Vector * v)
 {
   if (v->iteratorSegment == NULL)
     return NULL;
@@ -487,7 +487,7 @@
  * out of bounds.
  */
 void *
-vectorRemoveAt (Vector * v, unsigned int index)
+GNUNET_vector_delete_at (Vector * v, unsigned int index)
 {
   VectorSegment *segment;
   int segmentIndex;
@@ -519,7 +519,7 @@
  * is empty.
  */
 void *
-vectorRemoveLast (Vector * v)
+GNUNET_vector_delete_last (Vector * v)
 {
   void *rvalue;
 
@@ -543,7 +543,7 @@
  * is not found.
  */
 void *
-vectorRemoveObject (Vector * v, void *object)
+GNUNET_vector_delete (Vector * v, void *object)
 {
   VectorSegment *segment;
   int segmentIndex;
@@ -572,7 +572,7 @@
  * returned, or NULL if the index is out of bounds.
  */
 void *
-vectorSetAt (Vector * v, void *object, unsigned int index)
+GNUNET_vector_update_at (Vector * v, void *object, unsigned int index)
 {
   VectorSegment *segment;
   int segmentIndex;
@@ -595,7 +595,7 @@
  * The old object is returned, or NULL if it's not found.
  */
 void *
-vectorSetObject (Vector * v, void *object, void *oldObject)
+GNUNET_vector_update (Vector * v, void *object, void *oldObject)
 {
   VectorSegment *segment;
   int segmentIndex;
@@ -612,11 +612,12 @@
 
 
 /**
- * Swaps the contents of index1 and index2. Return value is OK
- * on success, SYSERR if either index is out of bounds.
+ * Swaps the contents of index1 and index2. Return value is GNUNET_OK
+ * on success, GNUNET_SYSERR if either index is out of bounds.
  */
 int
-vectorSwap (Vector * v, unsigned int index1, unsigned int index2)
+GNUNET_vector_swap_elements (Vector * v, unsigned int index1,
+                             unsigned int index2)
 {
   VectorSegment *segment1;
   VectorSegment *segment2;
@@ -625,23 +626,23 @@
   void *temp;
 
   if ((index1 >= v->size) || (index2 >= v->size))
-    return SYSERR;
+    return GNUNET_SYSERR;
   v->iteratorSegment = NULL;
   segmentIndex1 = vectorFindIndex (v, index1, &segment1);
   segmentIndex2 = vectorFindIndex (v, index2, &segment2);
   if ((segmentIndex1 == -1) || (segmentIndex2 == -1))
-    return SYSERR;
+    return GNUNET_SYSERR;
   temp = segment1->data[segmentIndex1];
   segment1->data[segmentIndex1] = segment2->data[segmentIndex2];
   segment2->data[segmentIndex2] = temp;
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * Return the index of given element or -1 if the element is not found.
  */
 unsigned int
-vectorIndexOf (Vector * v, void *object)
+GNUNET_vector_index_of (Vector * v, void *object)
 {
   VectorSegment *segment;
   unsigned int i;
@@ -668,13 +669,13 @@
  * everything in the vector as fast as possible.
  */
 void **
-vectorElements (Vector * v)
+GNUNET_vector_to_array (Vector * v)
 {
   void **rvalue;
   VectorSegment *vs;
   size_t i = 0;
 
-  rvalue = MALLOC_LARGE (v->size * sizeof (void *));
+  rvalue = GNUNET_malloc_large (v->size * sizeof (void *));
   for (vs = v->segmentsHead; vs; vs = vs->next)
     {
       memcpy (rvalue + i, vs->data, vs->size * sizeof (void *));

Modified: GNUnet/src/util/containers/vectortest.c
===================================================================
--- GNUnet/src/util/containers/vectortest.c     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/containers/vectortest.c     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -26,126 +26,126 @@
 #include "gnunet_util_containers.h"
 #include "platform.h"
 
-#define DUMP(v) fprintf(stderr, "At %d: \n", __LINE__); vectorDump(v); 
vectorFree(v);
+#define DUMP(v) fprintf(stderr, "At %d: \n", __LINE__); GNUNET_vector_dump(v); 
GNUNET_vector_destroy(v);
 
 static int
 test (int size)
 {
-  struct Vector *v;
+  struct GNUNET_Vector *v;
 
-  v = vectorNew (size);
-  if (0 != vectorSize (v))
+  v = GNUNET_vector_create (size);
+  if (0 != GNUNET_vector_get_size (v))
     {
       DUMP (v);
       return 1;
     }
-  if (OK != vectorInsertAt (v, "first", 0))
+  if (GNUNET_OK != GNUNET_vector_insert_at (v, "first", 0))
     {
       DUMP (v);
       return 1;
     }
-  if (OK == vectorInsertAt (v, "not", 2))
+  if (GNUNET_OK == GNUNET_vector_insert_at (v, "not", 2))
     {
       DUMP (v);
       return 1;
     }
-  if (OK != vectorInsertAt (v, "zero", 0))
+  if (GNUNET_OK != GNUNET_vector_insert_at (v, "zero", 0))
     {
       DUMP (v);
       return 1;
     }
-  if (OK != vectorInsertAt (v, "second", 2))
+  if (GNUNET_OK != GNUNET_vector_insert_at (v, "second", 2))
     {
       DUMP (v);
       return 1;
     }
-  vectorInsertLast (v, "third");
-  if (4 != vectorSize (v))
+  GNUNET_vector_insert_last (v, "third");
+  if (4 != GNUNET_vector_get_size (v))
     {
       DUMP (v);
       return 1;
     }
-  if (0 != strcmp (vectorGetAt (v, 1), "first"))
+  if (0 != strcmp (GNUNET_vector_get (v, 1), "first"))
     {
       DUMP (v);
       return 1;
     }
-  if (0 != strcmp (vectorGetAt (v, 3), "third"))
+  if (0 != strcmp (GNUNET_vector_get (v, 3), "third"))
     {
       DUMP (v);
       return 1;
     }
-  if (0 != strcmp (vectorGetAt (v, 0), "zero"))
+  if (0 != strcmp (GNUNET_vector_get (v, 0), "zero"))
     {
       DUMP (v);
       return 1;
     }
-  if (0 != strcmp (vectorGetFirst (v), "zero"))
+  if (0 != strcmp (GNUNET_vector_get_first (v), "zero"))
     {
       DUMP (v);
       return 1;
     }
-  if (0 != strcmp (vectorGetLast (v), "third"))
+  if (0 != strcmp (GNUNET_vector_get_last (v), "third"))
     {
       DUMP (v);
       return 1;
     }
-  if (0 != strcmp (vectorRemoveAt (v, 1), "first"))
+  if (0 != strcmp (GNUNET_vector_delete_at (v, 1), "first"))
     {
       DUMP (v);
       return 1;
     }
-  if (0 != strcmp (vectorGetAt (v, 1), "second"))
+  if (0 != strcmp (GNUNET_vector_get (v, 1), "second"))
     {
       DUMP (v);
       return 1;
     }
-  if (NULL != vectorRemoveAt (v, 3))
+  if (NULL != GNUNET_vector_delete_at (v, 3))
     {
       DUMP (v);
       return 1;
     }
-  if (3 != vectorSize (v))
+  if (3 != GNUNET_vector_get_size (v))
     {
       DUMP (v);
       return 1;
     }
-  if (0 != strcmp (vectorRemoveAt (v, 1), "second"))
+  if (0 != strcmp (GNUNET_vector_delete_at (v, 1), "second"))
     {
       DUMP (v);
       return 1;
     }
-  if (0 != strcmp (vectorRemoveObject (v, "third"), "third"))
+  if (0 != strcmp (GNUNET_vector_delete (v, "third"), "third"))
     {
       DUMP (v);
       return 1;
     }
-  if (NULL != vectorRemoveObject (v, "third"))
+  if (NULL != GNUNET_vector_delete (v, "third"))
     {
       DUMP (v);
       return 1;
     }
-  if (0 != strcmp (vectorRemoveLast (v), "zero"))
+  if (0 != strcmp (GNUNET_vector_delete_last (v), "zero"))
     {
       DUMP (v);
       return 1;
     }
-  if (0 != vectorSize (v))
+  if (0 != GNUNET_vector_get_size (v))
     {
       DUMP (v);
       return 1;
     }
-  if (NULL != vectorRemoveLast (v))
+  if (NULL != GNUNET_vector_delete_last (v))
     {
       DUMP (v);
       return 1;
     }
-  if (0 != vectorSize (v))
+  if (0 != GNUNET_vector_get_size (v))
     {
       DUMP (v);
       return 1;
     }
-  vectorFree (v);
+  GNUNET_vector_destroy (v);
   return 0;
 }
 
@@ -153,58 +153,58 @@
 test2 (int size)
 {
   long i;
-  struct Vector *v;
+  struct GNUNET_Vector *v;
 
-  v = vectorNew (size);
+  v = GNUNET_vector_create (size);
 
   for (i = 0; i < 500; i++)
-    if (OK != vectorInsertAt (v, (void *) i, 0))
+    if (GNUNET_OK != GNUNET_vector_insert_at (v, (void *) i, 0))
       {
         DUMP (v);
         return 1;
       }
-  if (500 != vectorSize (v))
+  if (500 != GNUNET_vector_get_size (v))
     {
       DUMP (v);
       return 1;
     }
   for (i = 0; i < 500; i++)
-    if (499 - i != (long) vectorGetAt (v, i))
+    if (499 - i != (long) GNUNET_vector_get (v, i))
       {
         DUMP (v);
         return 1;
       }
-  if (499 != (long) vectorGetFirst (v))
+  if (499 != (long) GNUNET_vector_get_first (v))
     {
       DUMP (v);
       return 1;
     }
   for (i = 498; i >= 0; i--)
-    if (i != (long) vectorGetNext (v))
+    if (i != (long) GNUNET_vector_get_next (v))
       {
         DUMP (v);
         return 1;
       }
 
-  if (499 != (long) vectorGetFirst (v))
+  if (499 != (long) GNUNET_vector_get_first (v))
     {
       DUMP (v);
       return 1;
     }
   for (i = 498; i >= 250; i--)
-    if (i != (long) vectorGetNext (v))
+    if (i != (long) GNUNET_vector_get_next (v))
       {
         DUMP (v);
         return 1;
       }
   for (i = 251; i < 499; i++)
-    if (i != (long) vectorGetPrevious (v))
+    if (i != (long) GNUNET_vector_get_prev (v))
       {
         DUMP (v);
         return 1;
       }
 
-  vectorFree (v);
+  GNUNET_vector_destroy (v);
   return 0;
 }
 
@@ -212,12 +212,12 @@
 int
 main (int argc, char *argv[])
 {
-  if (NULL != vectorNew (0))
+  if (NULL != GNUNET_vector_create (0))
     {
       printf ("At %d\n", __LINE__);
       return 1;
     }
-  if (NULL != vectorNew (1))
+  if (NULL != GNUNET_vector_create (1))
     {
       printf ("At %d\n", __LINE__);
       return 1;

Modified: GNUnet/src/util/cron/Makefile.am
===================================================================
--- GNUnet/src/util/cron/Makefile.am    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/cron/Makefile.am    2007-11-23 11:51:54 UTC (rev 5742)
@@ -2,13 +2,11 @@
 
 SUBDIRS = .
 
-lib_LTLIBRARIES = \
-  libgnunetutil_cron.la
+noinst_LTLIBRARIES = \
+  libcron.la
 
-libgnunetutil_cron_la_SOURCES = \
+libcron_la_SOURCES = \
  cron.c
-libgnunetutil_cron_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la  
 
 check_PROGRAMS = \
  crontest \
@@ -19,7 +17,6 @@
 crontest_SOURCES = \
  crontest.c
 crontest_LDADD = \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 
 
@@ -27,6 +24,5 @@
 timertest_SOURCES = \
  timertest.c
 timertest_LDADD = \
- $(top_builddir)/src/util/cron/libgnunetutil_cron.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 

Modified: GNUnet/src/util/cron/cron.c
===================================================================
--- GNUnet/src/util/cron/cron.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/cron/cron.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -38,7 +38,7 @@
 #include "gnunet_util_cron.h"
 #include "platform.h"
 
-#define DEBUG_CRON NO
+#define DEBUG_CRON GNUNET_NO
 
 #if DEBUG_CRON
 #define HAVE_PRINT_CRON_TAB 1
@@ -88,7 +88,7 @@
   /**
    * The method to call at that point.
    */
-  CronJob method;
+  GNUNET_CronJob method;
 
   /**
    * data ptr (argument to the method)
@@ -98,7 +98,7 @@
   /**
    * The start-time for this event (in milliseconds).
    */
-  cron_t delta;
+  GNUNET_CronTime delta;
 
   /**
    * for cron-jobs: when this should be repeated
@@ -114,13 +114,13 @@
 
 } UTIL_cron_DeltaListEntry;
 
-typedef struct CronManager
+typedef struct GNUNET_CronManager
 {
 
   /**
    * The lock for the delta-list.
    */
-  struct MUTEX *deltaListLock_;
+  struct GNUNET_Mutex *deltaListLock_;
 
   /**
    * The delta-list of waiting tasks.
@@ -130,7 +130,7 @@
   /**
    * The currently running job.
    */
-  CronJob runningJob_;
+  GNUNET_CronJob runningJob_;
 
   void *runningData_;
 
@@ -139,13 +139,13 @@
   /**
    * The cron thread.
    */
-  struct PTHREAD *cron_handle;
+  struct GNUNET_ThreadHandle *cron_handle;
 
-  struct SEMAPHORE *cron_signal;
+  struct GNUNET_Semaphore *cron_signal;
 
-  struct SEMAPHORE *cron_signal_up;
+  struct GNUNET_Semaphore *cron_signal_up;
 
-  struct MUTEX *inBlockLock_;
+  struct GNUNET_Mutex *inBlockLock_;
 
   unsigned int runningRepeat_;
 
@@ -174,32 +174,33 @@
    */
   int inBlock;
 
-  struct SEMAPHORE *sig;
+  struct GNUNET_Semaphore *sig;
 
 } CronManager;
 
 
-struct CronManager *
+struct GNUNET_CronManager *
 cron_create (struct GE_Context *ectx)
 {
-  struct CronManager *cron;
+  struct GNUNET_CronManager *cron;
   unsigned int i;
 
-  cron = MALLOC (sizeof (CronManager));
+  cron = GNUNET_malloc (sizeof (CronManager));
   memset (cron, 0, sizeof (CronManager));
   cron->deltaListSize_ = INIT_CRON_JOBS;
   cron->deltaList_
-    = MALLOC (sizeof (UTIL_cron_DeltaListEntry) * cron->deltaListSize_);
+    =
+    GNUNET_malloc (sizeof (UTIL_cron_DeltaListEntry) * cron->deltaListSize_);
   for (i = 0; i < cron->deltaListSize_; i++)
     cron->deltaList_[i].next = i - 1;
   cron->firstFree_ = cron->deltaListSize_ - 1;
-  cron->deltaListLock_ = MUTEX_CREATE (YES);
-  cron->inBlockLock_ = MUTEX_CREATE (NO);
+  cron->deltaListLock_ = GNUNET_mutex_create (GNUNET_YES);
+  cron->inBlockLock_ = GNUNET_mutex_create (GNUNET_NO);
   cron->runningJob_ = NULL;
   cron->firstUsed_ = -1;
-  cron->cron_signal_up = SEMAPHORE_CREATE (0);
+  cron->cron_signal_up = GNUNET_semaphore_create (0);
   cron->ectx = ectx;
-  cron->cron_shutdown = YES;
+  cron->cron_shutdown = GNUNET_YES;
   cron->sig = NULL;
   return cron;
 }
@@ -214,94 +215,94 @@
 }
 
 void
-cron_stop (struct CronManager *cron)
+GNUNET_cron_stop (struct GNUNET_CronManager *cron)
 {
   void *unused;
 
 #if DEBUG_CRON
   GE_LOG (cron->ectx, GE_STATUS | GE_DEVELOPER | GE_BULK, "Stopping cron\n");
 #endif
-  cron->cron_shutdown = YES;
-  cron_add_job (cron, &noJob, 0, 0, NULL);
-  SEMAPHORE_DOWN (cron->cron_signal, YES);
-  SEMAPHORE_DESTROY (cron->cron_signal);
+  cron->cron_shutdown = GNUNET_YES;
+  GNUNET_cron_add_job (cron, &noJob, 0, 0, NULL);
+  GNUNET_semaphore_down (cron->cron_signal, GNUNET_YES);
+  GNUNET_semaphore_destroy (cron->cron_signal);
   cron->cron_signal = NULL;
-  PTHREAD_JOIN (cron->cron_handle, &unused);
+  GNUNET_thread_join (cron->cron_handle, &unused);
 #if DEBUG_CRON
   GE_LOG (NULL, GE_STATUS | GE_DEVELOPER | GE_BULK, "Cron stopped\n");
 #endif
 }
 
 /**
- * CronJob to suspend the cron thread
+ * GNUNET_CronJob to suspend the cron thread
  * until it is resumed.
  */
 static void
 block (void *cls)
 {
-  struct CronManager *cron = cls;
-  int ok = SYSERR;
+  struct GNUNET_CronManager *cron = cls;
+  int ok = GNUNET_SYSERR;
 
   if (cron->sig != NULL)
-    SEMAPHORE_UP (cron->sig);
-  while (ok == SYSERR)
+    GNUNET_semaphore_up (cron->sig);
+  while (ok == GNUNET_SYSERR)
     {
-      SEMAPHORE_DOWN (cron->cron_signal_up, YES);
-      MUTEX_LOCK (cron->inBlockLock_);
+      GNUNET_semaphore_down (cron->cron_signal_up, GNUNET_YES);
+      GNUNET_mutex_lock (cron->inBlockLock_);
       cron->inBlock--;
       if (cron->inBlock == 0)
-        ok = OK;
-      MUTEX_UNLOCK (cron->inBlockLock_);
+        ok = GNUNET_OK;
+      GNUNET_mutex_unlock (cron->inBlockLock_);
     }
 }
 
 void
-cron_suspend (struct CronManager *cron, int checkSelf)
+GNUNET_cron_suspend_jobs (struct GNUNET_CronManager *cron, int checkSelf)
 {
-  if ((YES == checkSelf) &&
-      (cron->cron_shutdown == NO) &&
-      (NO != PTHREAD_TEST_SELF (cron->cron_handle)))
+  if ((GNUNET_YES == checkSelf) &&
+      (cron->cron_shutdown == GNUNET_NO) &&
+      (GNUNET_NO != GNUNET_thread_test_self (cron->cron_handle)))
     return;
-  GE_ASSERT (NULL, NO == PTHREAD_TEST_SELF (cron->cron_handle));
-  MUTEX_LOCK (cron->inBlockLock_);
+  GE_ASSERT (NULL, GNUNET_NO == GNUNET_thread_test_self (cron->cron_handle));
+  GNUNET_mutex_lock (cron->inBlockLock_);
   cron->inBlock++;
   if (cron->inBlock == 1)
     {
-      cron->sig = SEMAPHORE_CREATE (0);
-      cron_add_job (cron, &block, 0, 0, cron);
-      SEMAPHORE_DOWN (cron->sig, YES);
-      SEMAPHORE_DESTROY (cron->sig);
+      cron->sig = GNUNET_semaphore_create (0);
+      GNUNET_cron_add_job (cron, &block, 0, 0, cron);
+      GNUNET_semaphore_down (cron->sig, GNUNET_YES);
+      GNUNET_semaphore_destroy (cron->sig);
       cron->sig = NULL;
     }
-  MUTEX_UNLOCK (cron->inBlockLock_);
+  GNUNET_mutex_unlock (cron->inBlockLock_);
 }
 
 int
-cron_test_running (struct CronManager *cron)
+GNUNET_cron_test_running (struct GNUNET_CronManager *cron)
 {
-  if ((NO == cron->cron_shutdown) || (cron->inBlock > 0))
-    return YES;
+  if ((GNUNET_NO == cron->cron_shutdown) || (cron->inBlock > 0))
+    return GNUNET_YES;
   else
-    return NO;
+    return GNUNET_NO;
 }
 
 void
-cron_resume_jobs (struct CronManager *cron, int checkSelf)
+GNUNET_cron_resume_jobs (struct GNUNET_CronManager *cron, int checkSelf)
 {
-  if ((YES == checkSelf) &&
-      (cron->cron_shutdown == NO) &&
-      (NO != PTHREAD_TEST_SELF (cron->cron_handle)))
+  if ((GNUNET_YES == checkSelf) &&
+      (cron->cron_shutdown == GNUNET_NO) &&
+      (GNUNET_NO != GNUNET_thread_test_self (cron->cron_handle)))
     return;
   GE_ASSERT (NULL, cron->inBlock > 0);
-  SEMAPHORE_UP (cron->cron_signal_up);
+  GNUNET_semaphore_up (cron->cron_signal_up);
 }
 
 static void
-abortSleep (struct CronManager *cron)
+abortSleep (struct GNUNET_CronManager *cron)
 {
   if (cron->cron_signal == NULL)
     return;                     /* cron_handle not valid */
-  PTHREAD_STOP_SLEEP (cron->cron_handle);
+  GNUNET_thread_stop_sleep (cron->cron_handle);
 }
 
 
@@ -310,14 +311,14 @@
  * Print the cron-tab.
  */
 void
-printCronTab (struct CronManager *cron)
+printCronTab (struct GNUNET_CronManager *cron)
 {
   int jobId;
   UTIL_cron_DeltaListEntry *tab;
-  cron_t now;
+  GNUNET_CronTime now;
 
-  now = get_time ();
-  MUTEX_LOCK (cron->deltaListLock_);
+  now = GNUNET_get_time ();
+  GNUNET_mutex_lock (cron->deltaListLock_);
 
   jobId = cron->firstUsed_;
   while (jobId != -1)
@@ -329,13 +330,14 @@
               jobId, tab->delta - now, (int) tab->method, tab->deltaRepeat);
       jobId = tab->next;
     }
-  MUTEX_UNLOCK (cron->deltaListLock_);
+  GNUNET_mutex_unlock (cron->deltaListLock_);
 }
 #endif
 
 void
-cron_advance_job (struct CronManager *cron,
-                  CronJob method, unsigned int deltaRepeat, void *data)
+GNUNET_cron_advance_job (struct GNUNET_CronManager *cron,
+                         GNUNET_CronJob method, unsigned int deltaRepeat,
+                         void *data)
 {
   UTIL_cron_DeltaListEntry *job;
   UTIL_cron_DeltaListEntry *last;
@@ -346,12 +348,12 @@
           GE_STATUS | GE_DEVELOPER | GE_BULK,
           "Advancing job %p-%p\n", method, data);
 #endif
-  MUTEX_LOCK (cron->deltaListLock_);
+  GNUNET_mutex_lock (cron->deltaListLock_);
   jobId = cron->firstUsed_;
   if (jobId == -1)
     {
       /* not in queue - do nothing! */
-      MUTEX_UNLOCK (cron->deltaListLock_);
+      GNUNET_mutex_unlock (cron->deltaListLock_);
       return;
     }
   last = NULL;
@@ -367,24 +369,24 @@
               (data != cron->runningData_) ||
               (deltaRepeat != cron->runningRepeat_))
             {
-              cron_add_job (cron, method, 0, deltaRepeat, data);
+              GNUNET_cron_add_job (cron, method, 0, deltaRepeat, data);
             }
-          MUTEX_UNLOCK (cron->deltaListLock_);
+          GNUNET_mutex_unlock (cron->deltaListLock_);
           return;
         }
       jobId = job->next;
       job = &cron->deltaList_[jobId];
     }
   /* ok, found it; remove, re-add with time 0 */
-  cron_del_job (cron, method, deltaRepeat, data);
-  cron_add_job (cron, method, 0, deltaRepeat, data);
-  MUTEX_UNLOCK (cron->deltaListLock_);
+  GNUNET_cron_del_job (cron, method, deltaRepeat, data);
+  GNUNET_cron_add_job (cron, method, 0, deltaRepeat, data);
+  GNUNET_mutex_unlock (cron->deltaListLock_);
 }
 
 void
-cron_add_job (struct CronManager *cron,
-              CronJob method,
-              unsigned int delta, unsigned int deltaRepeat, void *data)
+GNUNET_cron_add_job (struct GNUNET_CronManager *cron,
+                     GNUNET_CronJob method,
+                     unsigned int delta, unsigned int deltaRepeat, void *data)
 {
   UTIL_cron_DeltaListEntry *entry;
   UTIL_cron_DeltaListEntry *pos;
@@ -397,12 +399,13 @@
           "Adding job %p-%p to fire in %d CU\n", method, data, delta);
 #endif
 
-  MUTEX_LOCK (cron->deltaListLock_);
+  GNUNET_mutex_lock (cron->deltaListLock_);
   if (cron->firstFree_ == -1)
     {                           /* need to grow */
       unsigned int i;
 
-      GROW (cron->deltaList_, cron->deltaListSize_, cron->deltaListSize_ * 2);
+      GNUNET_array_grow (cron->deltaList_, cron->deltaListSize_,
+                         cron->deltaListSize_ * 2);
       for (i = cron->deltaListSize_ / 2; i < cron->deltaListSize_; i++)
         cron->deltaList_[i].next = i - 1;
       cron->deltaList_[cron->deltaListSize_ / 2].next = -1;
@@ -412,13 +415,13 @@
   entry->method = method;
   entry->data = data;
   entry->deltaRepeat = deltaRepeat;
-  entry->delta = get_time () + delta;
+  entry->delta = GNUNET_get_time () + delta;
   if (cron->firstUsed_ == -1)
     {
       cron->firstUsed_ = cron->firstFree_;
       cron->firstFree_ = entry->next;
       entry->next = -1;         /* end of list */
-      MUTEX_UNLOCK (cron->deltaListLock_);
+      GNUNET_mutex_unlock (cron->deltaListLock_);
       /* interrupt sleeping cron-thread! */
       abortSleep (cron);
       return;
@@ -441,7 +444,7 @@
           pos->next = cron->firstFree_;
           cron->firstFree_ = entry->next;
           entry->next = -1;
-          MUTEX_UNLOCK (cron->deltaListLock_);
+          GNUNET_mutex_unlock (cron->deltaListLock_);
 #if HAVE_PRINT_CRON_TAB
           printCronTab ();
 #endif
@@ -463,7 +466,7 @@
     }
   cron->firstFree_ = entry->next;
   entry->next = current;
-  MUTEX_UNLOCK (cron->deltaListLock_);
+  GNUNET_mutex_unlock (cron->deltaListLock_);
 }
 
 /**
@@ -475,11 +478,11 @@
  * jobs!)
  */
 static void
-runJob (struct CronManager *cron)
+runJob (struct GNUNET_CronManager *cron)
 {
   UTIL_cron_DeltaListEntry *job;
   int jobId;
-  CronJob method;
+  GNUNET_CronJob method;
   void *data;
   unsigned int repeat;
 
@@ -497,7 +500,7 @@
   cron->firstUsed_ = job->next;
   job->next = cron->firstFree_;
   cron->firstFree_ = jobId;
-  MUTEX_UNLOCK (cron->deltaListLock_);
+  GNUNET_mutex_unlock (cron->deltaListLock_);
   /* re-insert */
   if (repeat > 0)
     {
@@ -507,7 +510,7 @@
               "adding periodic job %p-%p to run again in %u\n",
               method, data, repeat);
 #endif
-      cron_add_job (cron, method, repeat, repeat, data);
+      GNUNET_cron_add_job (cron, method, repeat, repeat, data);
     }
   /* run */
 #if DEBUG_CRON
@@ -516,7 +519,7 @@
           "running job %p-%p\n", method, data);
 #endif
   method (data);
-  MUTEX_LOCK (cron->deltaListLock_);
+  GNUNET_mutex_lock (cron->deltaListLock_);
   cron->runningJob_ = NULL;
 #if DEBUG_CRON
   GE_LOG (cron->ectx,
@@ -531,21 +534,21 @@
 static void *
 cron_main_method (void *ctx)
 {
-  struct CronManager *cron = ctx;
-  cron_t now;
-  cron_t next;
+  struct GNUNET_CronManager *cron = ctx;
+  GNUNET_CronTime now;
+  GNUNET_CronTime next;
 
-  while (cron->cron_shutdown == NO)
+  while (cron->cron_shutdown == GNUNET_NO)
     {
 #if HAVE_PRINT_CRON_TAB
       printCronTab (cron);
 #endif
-      now = get_time ();
+      now = GNUNET_get_time ();
       next = now + 0xFFFFFFFF;
-      MUTEX_LOCK (cron->deltaListLock_);
-      while ((cron->cron_shutdown == NO) && (cron->firstUsed_ != -1))
+      GNUNET_mutex_lock (cron->deltaListLock_);
+      while ((cron->cron_shutdown == GNUNET_NO) && (cron->firstUsed_ != -1))
         {
-          now = get_time ();
+          now = GNUNET_get_time ();
           next = cron->deltaList_[cron->firstUsed_].delta;
           if (next <= now)
             {
@@ -566,26 +569,26 @@
           else
             break;
         }
-      MUTEX_UNLOCK (cron->deltaListLock_);
+      GNUNET_mutex_unlock (cron->deltaListLock_);
       next = next - now;        /* how long to sleep */
 #if DEBUG_CRON
       GE_LOG (cron->ectx,
               GE_STATUS | GE_DEVELOPER | GE_BULK,
               "Sleeping at %llu for %llu CU (%llu s, %llu CU)\n",
-              now, next, next / cronSECONDS, next);
+              now, next, next / GNUNET_CRON_SECONDS, next);
 #endif
       if (next > MAXSLEEP)
         next = MAXSLEEP;
-      if (cron->cron_shutdown == NO)
-        PTHREAD_SLEEP (next);
+      if (cron->cron_shutdown == GNUNET_NO)
+        GNUNET_thread_sleep (next);
 #if DEBUG_CRON
       GE_LOG (cron->ectx,
               GE_STATUS | GE_DEVELOPER | GE_BULK,
               "woke up at  %llu - %lld CS late\n",
-              get_time (), get_time () - (now + next));
+              GNUNET_get_time (), GNUNET_get_time () - (now + next));
 #endif
     }
-  SEMAPHORE_UP (cron->cron_signal);
+  GNUNET_semaphore_up (cron->cron_signal);
 #if DEBUG_CRON
   GE_LOG (cron->ectx,
           GE_STATUS | GE_DEVELOPER | GE_BULK, "Cron thread exits.\n");
@@ -599,7 +602,7 @@
  * Make sure to call stopCron before calling this method!
  */
 void
-cron_destroy (struct CronManager *cron)
+GNUNET_cron_destroy (struct GNUNET_CronManager *cron)
 {
   int i;
 
@@ -607,28 +610,29 @@
   i = cron->firstUsed_;
   while (i != -1)
     {
-      FREENONNULL (cron->deltaList_[i].data);
+      GNUNET_free_non_null (cron->deltaList_[i].data);
       i = cron->deltaList_[i].next;
     }
-  MUTEX_DESTROY (cron->deltaListLock_);
-  MUTEX_DESTROY (cron->inBlockLock_);
-  FREE (cron->deltaList_);
-  SEMAPHORE_DESTROY (cron->cron_signal_up);
-  FREE (cron);
+  GNUNET_mutex_destroy (cron->deltaListLock_);
+  GNUNET_mutex_destroy (cron->inBlockLock_);
+  GNUNET_free (cron->deltaList_);
+  GNUNET_semaphore_destroy (cron->cron_signal_up);
+  GNUNET_free (cron);
 }
 
 /**
  * Start the cron jobs.
  */
 void
-cron_start (struct CronManager *cron)
+GNUNET_cron_start (struct GNUNET_CronManager *cron)
 {
   GE_ASSERT (cron->ectx, cron->cron_signal == NULL);
-  cron->cron_shutdown = NO;
-  cron->cron_signal = SEMAPHORE_CREATE (0);
+  cron->cron_shutdown = GNUNET_NO;
+  cron->cron_signal = GNUNET_semaphore_create (0);
   /* large stack, we don't know for sure
      what the cron jobs may be doing */
-  cron->cron_handle = PTHREAD_CREATE (&cron_main_method, cron, 256 * 1024);
+  cron->cron_handle =
+    GNUNET_thread_create (&cron_main_method, cron, 256 * 1024);
   if (cron->cron_handle == 0)
     GE_DIE_STRERROR (cron->ectx,
                      GE_FATAL | GE_ADMIN | GE_USER | GE_BULK,
@@ -636,8 +640,8 @@
 }
 
 int
-cron_del_job (struct CronManager *cron,
-              CronJob method, unsigned int repeat, void *data)
+GNUNET_cron_del_job (struct GNUNET_CronManager *cron,
+                     GNUNET_CronJob method, unsigned int repeat, void *data)
 {
   UTIL_cron_DeltaListEntry *job;
   UTIL_cron_DeltaListEntry *last;
@@ -648,11 +652,11 @@
           GE_STATUS | GE_DEVELOPER | GE_BULK,
           "deleting job %p-%p\n", method, data);
 #endif
-  MUTEX_LOCK (cron->deltaListLock_);
+  GNUNET_mutex_lock (cron->deltaListLock_);
   jobId = cron->firstUsed_;
   if (jobId == -1)
     {
-      MUTEX_UNLOCK (cron->deltaListLock_);
+      GNUNET_mutex_unlock (cron->deltaListLock_);
       return 0;
     }
   last = NULL;
@@ -663,7 +667,7 @@
       last = job;
       if (job->next == -1)
         {
-          MUTEX_UNLOCK (cron->deltaListLock_);
+          GNUNET_mutex_unlock (cron->deltaListLock_);
           return 0;
         }
       jobId = job->next;
@@ -678,7 +682,7 @@
   job->method = NULL;
   job->data = NULL;
   job->deltaRepeat = 0;
-  MUTEX_UNLOCK (cron->deltaListLock_);
+  GNUNET_mutex_unlock (cron->deltaListLock_);
   return 1;
 }
 

Modified: GNUnet/src/util/cron/crontest.c
===================================================================
--- GNUnet/src/util/cron/crontest.c     2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/cron/crontest.c     2007-11-23 11:51:54 UTC (rev 5742)
@@ -31,7 +31,7 @@
 static int global2;
 static int global3;
 
-static struct CronManager *cron;
+static struct GNUNET_CronManager *cron;
 
 static void
 cronJob (void *unused)
@@ -59,9 +59,12 @@
   global = -1;
   global2 = -1;
   global3 = -1;
-  cron_add_job (cron, &cronJob, cronSECONDS * 1, cronSECONDS * 1, NULL);
-  cron_add_job (cron, &cronJob2, cronSECONDS * 4, cronSECONDS * 4, NULL);
-  cron_add_job (cron, &cronJob3, cronSECONDS * 16, cronSECONDS * 16, NULL);
+  GNUNET_cron_add_job (cron, &cronJob, GNUNET_CRON_SECONDS * 1,
+                       GNUNET_CRON_SECONDS * 1, NULL);
+  GNUNET_cron_add_job (cron, &cronJob2, GNUNET_CRON_SECONDS * 4,
+                       GNUNET_CRON_SECONDS * 4, NULL);
+  GNUNET_cron_add_job (cron, &cronJob3, GNUNET_CRON_SECONDS * 16,
+                       GNUNET_CRON_SECONDS * 16, NULL);
   for (i = 0; i < 10; i++)
     {
       /*    fprintf(stderr,"."); */
@@ -82,25 +85,26 @@
           return 1;
         }
     }
-  cron_del_job (cron, &cronJob, cronSECONDS * 1, NULL);
-  cron_del_job (cron, &cronJob2, cronSECONDS * 4, NULL);
-  cron_del_job (cron, &cronJob3, cronSECONDS * 16, NULL);
+  GNUNET_cron_del_job (cron, &cronJob, GNUNET_CRON_SECONDS * 1, NULL);
+  GNUNET_cron_del_job (cron, &cronJob2, GNUNET_CRON_SECONDS * 4, NULL);
+  GNUNET_cron_del_job (cron, &cronJob3, GNUNET_CRON_SECONDS * 16, NULL);
   return 0;
 }
 
 static void
 delJob (void *unused)
 {
-  cron_del_job (cron, &cronJob, 42, NULL);
+  GNUNET_cron_del_job (cron, &cronJob, 42, NULL);
 }
 
 static int
 testDelCron ()
 {
   global = 0;
-  cron_add_job (cron, &cronJob, cronSECONDS * 1, 42, NULL);
-  cron_add_job (cron, &delJob, 500 * cronMILLIS, 0, NULL);
-  PTHREAD_SLEEP (1 * cronSECONDS);
+  GNUNET_cron_add_job (cron, &cronJob, GNUNET_CRON_SECONDS * 1, 42, NULL);
+  GNUNET_cron_add_job (cron, &delJob, 500 * GNUNET_CRON_MILLISECONDS, 0,
+                       NULL);
+  GNUNET_thread_sleep (1 * GNUNET_CRON_SECONDS);
   if (global !=0)
     {
       fprintf (stderr,
@@ -116,11 +120,11 @@
   int failureCount = 0;
 
   cron = cron_create (NULL);
-  cron_start (cron);
+  GNUNET_cron_start (cron);
   failureCount += testCron ();
   failureCount += testDelCron ();
-  cron_stop (cron);
-  cron_destroy (cron);
+  GNUNET_cron_stop (cron);
+  GNUNET_cron_destroy (cron);
   if (failureCount != 0)
     return 1;
   return 0;

Modified: GNUnet/src/util/cron/timertest.c
===================================================================
--- GNUnet/src/util/cron/timertest.c    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/cron/timertest.c    2007-11-23 11:51:54 UTC (rev 5742)
@@ -29,22 +29,22 @@
 static void
 semaphore_up (void *ctx)
 {
-  struct SEMAPHORE *sem = ctx;
-  SEMAPHORE_UP (sem);
+  struct GNUNET_Semaphore *sem = ctx;
+  GNUNET_semaphore_up (sem);
 }
 
-static struct CronManager *cron;
+static struct GNUNET_CronManager *cron;
 
 static int
 check ()
 {
-  struct SEMAPHORE *sem;
+  struct GNUNET_Semaphore *sem;
   unsigned long long cumDelta;
-  cron_t now;
-  cron_t last;
+  GNUNET_CronTime now;
+  GNUNET_CronTime last;
   int i;
 
-  sem = SEMAPHORE_CREATE (0);
+  sem = GNUNET_semaphore_create (0);
 
   cumDelta = 0;
 
@@ -52,10 +52,11 @@
 #define INCR2 113
   for (i = 50; i < MAXV2 + 50; i += INCR2)
     {
-      last = get_time ();
-      cron_add_job (cron, &semaphore_up, i * cronMILLIS, 0, sem);
-      SEMAPHORE_DOWN (sem, YES);
-      now = get_time ();
+      last = GNUNET_get_time ();
+      GNUNET_cron_add_job (cron, &semaphore_up, i * GNUNET_CRON_MILLISECONDS,
+                           0, sem);
+      GNUNET_semaphore_down (sem, GNUNET_YES);
+      now = GNUNET_get_time ();
       if (now < last + i)
         now = last + i - now;
       else
@@ -70,16 +71,16 @@
   FPRINTF (stdout,
            "Sleep interrupt precision is %llums. ",
            cumDelta / (MAXV2 / INCR2));
-  if (cumDelta <= 10 * cronMILLIS * MAXV2 / INCR2)
+  if (cumDelta <= 10 * GNUNET_CRON_MILLISECONDS * MAXV2 / INCR2)
     fprintf (stdout, "Timer precision is excellent.\n");
-  else if (cumDelta <= 50 * cronMILLIS * MAXV2 / INCR2) /* 50ms average 
deviation */
+  else if (cumDelta <= 50 * GNUNET_CRON_MILLISECONDS * MAXV2 / INCR2)   /* 
50ms average deviation */
     fprintf (stdout, "Timer precision is good.\n");
-  else if (cumDelta > 250 * cronMILLIS * MAXV2 / INCR2)
+  else if (cumDelta > 250 * GNUNET_CRON_MILLISECONDS * MAXV2 / INCR2)
     fprintf (stdout, "Timer precision is awful.\n");
   else
     fprintf (stdout, "Timer precision is acceptable.\n");
 
-  SEMAPHORE_DESTROY (sem);
+  GNUNET_semaphore_destroy (sem);
   return 0;
 }
 
@@ -89,10 +90,10 @@
   int failureCount = 0;
 
   cron = cron_create (NULL);
-  cron_start (cron);
+  GNUNET_cron_start (cron);
   failureCount += check ();
-  cron_stop (cron);
-  cron_destroy (cron);
+  GNUNET_cron_stop (cron);
+  GNUNET_cron_destroy (cron);
   if (failureCount != 0)
     return 1;
   return 0;

Modified: GNUnet/src/util/crypto/Makefile.am
===================================================================
--- GNUnet/src/util/crypto/Makefile.am  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/crypto/Makefile.am  2007-11-23 11:51:54 UTC (rev 5742)
@@ -2,17 +2,16 @@
 
 INCLUDES = -I$(top_srcdir)/src/include
 
-lib_LTLIBRARIES = libgnunetutil_crypto.la
+noinst_LTLIBRARIES = libcrypto.la
 
 AM_CPPFLAGS = $(LIBGCRYPT_CFLAGS) -O3
 
-libgnunetutil_crypto_la_LIBADD = \
- $(GCLIBADD) \
- $(top_builddir)/src/util/libgnunetutil.la 
+libcrypto_la_LIBADD = \
+ $(GCLIBADD) 
 
-libgnunetutil_crypto_la_LDFLAGS = $(LIBGCRYPT_LIBS) -lgmp
+libcrypto_la_LDFLAGS = $(LIBGCRYPT_LIBS) -lgmp
 
-libgnunetutil_crypto_la_SOURCES = \
+libcrypto_la_SOURCES = \
  crc32.c \
  hashing.c \
  hostkey_gcrypt.c \
@@ -36,48 +35,40 @@
 hashingtest_SOURCES = \
  hashingtest.c
 hashingtest_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la  
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 crctest_SOURCES = \
  crctest.c
 crctest_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la  
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 kblockkey_test_SOURCES = \
  kblockkey_test.c
 kblockkey_test_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la  
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 hostkeytest_SOURCES = \
  hostkeytest.c
 hostkeytest_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la   
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 hashtest_SOURCES = \
  hashingtest.c
 hashtest_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la  
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 hashperf_SOURCES = \
  hashperf.c
 hashperf_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la  
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 symciphertest_SOURCES = \
  symciphertest.c
 symciphertest_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la   
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 weakkeytest_SOURCES = \
  weakkeytest.c
 weakkeytest_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la  
+ $(top_builddir)/src/util/libgnunetutil.la 
 

Modified: GNUnet/src/util/crypto/crc32.c
===================================================================
--- GNUnet/src/util/crypto/crc32.c      2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/crypto/crc32.c      2007-11-23 11:51:54 UTC (rev 5742)
@@ -95,7 +95,7 @@
  * @return the resulting CRC32 checksum
  */
 int
-crc32N (const void *buf, int len)
+GNUNET_crc32_n (const void *buf, unsigned int len)
 {
   uLong crc;
   crc = crc32 (0L, Z_NULL, 0);

Modified: GNUnet/src/util/crypto/crctest.c
===================================================================
--- GNUnet/src/util/crypto/crctest.c    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/crypto/crctest.c    2007-11-23 11:51:54 UTC (rev 5742)
@@ -215,7 +215,7 @@
   for (i = 0; i < 1024; i++)
     buf[i] = (char) i;
   for (i = 0; i < 1024; i++)
-    if (expected[i] != crc32N (&buf[i], 1024 - i))
+    if (expected[i] != GNUNET_crc32_n (&buf[i], 1024 - i))
       return 1;
   return 0;
 }

Modified: GNUnet/src/util/crypto/hashing.c
===================================================================
--- GNUnet/src/util/crypto/hashing.c    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/crypto/hashing.c    2007-11-23 11:51:54 UTC (rev 5742)
@@ -26,7 +26,7 @@
 
 /**
  * @file util/crypto/hashing.c
- * @brief SHA-512 hash related functions
+ * @brief SHA-512 GNUNET_hash related functions
  * @author Christian Grothoff
  */
 
@@ -357,12 +357,12 @@
 /**
  * Hash block of given size.
  *
- * @param block the data to hash, length is given as a second argument
- * @param size the length of the data to hash
+ * @param block the data to GNUNET_hash, length is given as a second argument
+ * @param size the length of the data to GNUNET_hash
  * @param ret pointer to where to write the hashcode
  */
 void
-hash (const void *block, unsigned int size, HashCode512 * ret)
+GNUNET_hash (const void *block, unsigned int size, GNUNET_HashCode * ret)
 {
   struct sha512_ctx ctx;
 
@@ -372,14 +372,15 @@
 }
 
 /**
- * Compute the hash of an entire file.  Does NOT load the entire file
+ * Compute the GNUNET_hash of an entire file.  Does NOT load the entire file
  * into memory but instead processes it in blocks.  Very important for
  * large files.
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-getFileHash (struct GE_Context *ectx, const char *filename, HashCode512 * ret)
+GNUNET_hash_file (struct GE_Context *ectx, const char *filename,
+                  GNUNET_HashCode * ret)
 {
   unsigned char *buf;
   unsigned long long len;
@@ -388,21 +389,21 @@
   int fh;
   struct sha512_ctx ctx;
 
-  if (OK != disk_file_test (ectx, filename))
-    return SYSERR;
-  if (OK != disk_file_size (ectx, filename, &len, NO))
-    return SYSERR;
-  fh = disk_file_open (ectx, filename, O_RDONLY | O_LARGEFILE);
+  if (GNUNET_OK != GNUNET_disk_file_test (ectx, filename))
+    return GNUNET_SYSERR;
+  if (GNUNET_OK != GNUNET_disk_file_size (ectx, filename, &len, GNUNET_NO))
+    return GNUNET_SYSERR;
+  fh = GNUNET_disk_file_open (ectx, filename, O_RDONLY | O_LARGEFILE);
   if (fh == -1)
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_ERROR | GE_USER | GE_ADMIN | GE_REQUEST,
                             "open", filename);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   sha512_init (&ctx);
   pos = 0;
-  buf = MALLOC (65536);
+  buf = GNUNET_malloc (65536);
   while (pos < len)
     {
       delta = 65536;
@@ -417,8 +418,8 @@
             GE_LOG_STRERROR_FILE (ectx,
                                   GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
                                   "close", filename);
-          FREE (buf);
-          return SYSERR;
+          GNUNET_free (buf);
+          return GNUNET_SYSERR;
         }
       sha512_update (&ctx, buf, delta);
       if (pos + delta > pos)
@@ -431,15 +432,15 @@
                           GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
                           "close", filename);
   sha512_final (&ctx, (unsigned char *) ret);
-  FREE (buf);
-  return OK;
+  GNUNET_free (buf);
+  return GNUNET_OK;
 }
 
 
 /* ***************** binary-ASCII encoding *************** */
 
 /**
- * 32 characters for encoding (hash => 32 characters)
+ * 32 characters for encoding (GNUNET_hash => 32 characters)
  */
 static char *encTable__ = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
 
@@ -454,18 +455,18 @@
 }
 
 /**
- * Convert hash to ASCII encoding.  The ASCII encoding is rather
+ * Convert GNUNET_hash to ASCII encoding.  The ASCII encoding is rather
  * GNUnet specific.  It was chosen such that it only uses characters
  * in [0-9A-V], can be produced without complex arithmetics and uses a
  * small number of characters.  The GNUnet encoding uses 102
  * characters plus a null terminator.
  *
- * @param block the hash code
- * @param result where to store the encoding (EncName can be
+ * @param block the GNUNET_hash code
+ * @param result where to store the encoding (GNUNET_EncName can be
  *  safely cast to char*, a '\0' termination is set).
  */
 void
-hash2enc (const HashCode512 * block, EncName * result)
+GNUNET_hash_to_enc (const GNUNET_HashCode * block, GNUNET_EncName * result)
 {
   unsigned int wpos;
   unsigned int rpos;
@@ -478,9 +479,9 @@
   wpos = 0;
   rpos = 0;
   bits = 0;
-  while ((rpos < sizeof (HashCode512)) || (vbit > 0))
+  while ((rpos < sizeof (GNUNET_HashCode)) || (vbit > 0))
     {
-      if ((rpos < sizeof (HashCode512)) && (vbit < 5))
+      if ((rpos < sizeof (GNUNET_HashCode)) && (vbit < 5))
         {
           bits = (bits << 8) | ((unsigned char *) block)[rpos++];       /* eat 
8 more bits */
           vbit += 8;
@@ -491,36 +492,36 @@
           GE_ASSERT (NULL, vbit == 2);  /* padding by 3: 512+3 mod 5 == 0 */
           vbit = 5;
         }
-      GE_ASSERT (NULL, wpos < sizeof (EncName) - 1);
+      GE_ASSERT (NULL, wpos < sizeof (GNUNET_EncName) - 1);
       result->encoding[wpos++] = encTable__[(bits >> (vbit - 5)) & 31];
       vbit -= 5;
     }
-  GE_ASSERT (NULL, wpos == sizeof (EncName) - 1);
+  GE_ASSERT (NULL, wpos == sizeof (GNUNET_EncName) - 1);
   GE_ASSERT (NULL, vbit == 0);
   result->encoding[wpos] = '\0';
 }
 
 /**
- * Convert ASCII encoding back to hash
+ * Convert ASCII encoding back to GNUNET_hash
  *
  * @param enc the encoding
- * @param result where to store the hash code
- * @return OK on success, SYSERR if result has the wrong encoding
+ * @param result where to store the GNUNET_hash code
+ * @return GNUNET_OK on success, GNUNET_SYSERR if result has the wrong encoding
  */
 int
-enc2hash (const char *enc, HashCode512 * result)
+GNUNET_enc_to_hash (const char *enc, GNUNET_HashCode * result)
 {
   unsigned int rpos;
   unsigned int wpos;
   unsigned int bits;
   unsigned int vbit;
 
-  if (strlen (enc) != sizeof (EncName) - 1)
-    return SYSERR;
+  if (strlen (enc) != sizeof (GNUNET_EncName) - 1)
+    return GNUNET_SYSERR;
 
   vbit = 2;                     /* padding! */
-  wpos = sizeof (HashCode512);
-  rpos = sizeof (EncName) - 1;
+  wpos = sizeof (GNUNET_HashCode);
+  rpos = sizeof (GNUNET_EncName) - 1;
   bits = getValue__ (enc[--rpos]) >> 3;
   while (wpos > 0)
     {
@@ -536,7 +537,7 @@
     }
   GE_ASSERT (NULL, rpos == 0);
   GE_ASSERT (NULL, vbit == 0);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -549,53 +550,49 @@
  *  hashcode proximity.
  */
 unsigned int
-distanceHashCode512 (const HashCode512 * a, const HashCode512 * b)
+GNUNET_hash_distance_u32 (const GNUNET_HashCode * a,
+                          const GNUNET_HashCode * b)
 {
   unsigned int x = (a->bits[1] - b->bits[1]) >> 16;
   return ((x * x) >> 16);
 }
 
-/**
- * Compare two hashcodes.
- * @return 1 if they are equal, 0 if not.
- */
-int
-equalsHashCode512 (const HashCode512 * a, const HashCode512 * b)
-{
-  return (0 == memcmp (a, b, sizeof (HashCode512)));
-}
-
 void
-makeRandomId (HashCode512 * result)
+GNUNET_create_random_hash (GNUNET_HashCode * result)
 {
   int i;
-  for (i = (sizeof (HashCode512) / sizeof (unsigned int)) - 1; i >= 0; i--)
+  for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0;
+       i--)
     result->bits[i] = rand ();
 }
 
 void
-deltaId (const HashCode512 * a, const HashCode512 * b, HashCode512 * result)
+GNUNET_hash_difference (const GNUNET_HashCode * a, const GNUNET_HashCode * b,
+                        GNUNET_HashCode * result)
 {
   int i;
-  for (i = (sizeof (HashCode512) / sizeof (unsigned int)) - 1; i >= 0; i--)
+  for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0;
+       i--)
     result->bits[i] = b->bits[i] - a->bits[i];
 }
 
 void
-addHashCodes (const HashCode512 * a,
-              const HashCode512 * delta, HashCode512 * result)
+GNUNET_hash_sum (const GNUNET_HashCode * a,
+                 const GNUNET_HashCode * delta, GNUNET_HashCode * result)
 {
   int i;
-  for (i = (sizeof (HashCode512) / sizeof (unsigned int)) - 1; i >= 0; i--)
+  for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0;
+       i--)
     result->bits[i] = delta->bits[i] + a->bits[i];
 }
 
 void
-xorHashCodes (const HashCode512 * a,
-              const HashCode512 * b, HashCode512 * result)
+GNUNET_hash_xor (const GNUNET_HashCode * a,
+                 const GNUNET_HashCode * b, GNUNET_HashCode * result)
 {
   int i;
-  for (i = (sizeof (HashCode512) / sizeof (unsigned int)) - 1; i >= 0; i--)
+  for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0;
+       i--)
     result->bits[i] = a->bits[i] ^ b->bits[i];
 }
 
@@ -603,25 +600,30 @@
  * Convert a hashcode into a key.
  */
 void
-hashToKey (const HashCode512 * hc, SESSIONKEY * skey, INITVECTOR * iv)
+GNUNET_hash_to_AES_key (const GNUNET_HashCode * hc,
+                        GNUNET_AES_SessionKey * skey,
+                        GNUNET_AES_InitializationVector * iv)
 {
   GE_ASSERT (NULL,
-             sizeof (HashCode512) >= SESSIONKEY_LEN + sizeof (INITVECTOR));
-  memcpy (skey, hc, SESSIONKEY_LEN);
-  skey->crc32 = htonl (crc32N (skey, SESSIONKEY_LEN));
-  memcpy (iv, &((char *) hc)[SESSIONKEY_LEN], sizeof (INITVECTOR));
+             sizeof (GNUNET_HashCode) >=
+             GNUNET_SESSIONKEY_LEN +
+             sizeof (GNUNET_AES_InitializationVector));
+  memcpy (skey, hc, GNUNET_SESSIONKEY_LEN);
+  skey->crc32 = htonl (GNUNET_crc32_n (skey, GNUNET_SESSIONKEY_LEN));
+  memcpy (iv, &((char *) hc)[GNUNET_SESSIONKEY_LEN],
+          sizeof (GNUNET_AES_InitializationVector));
 }
 
 /**
  * Obtain a bit from a hashcode.
- * @param code the hash to index bit-wise
+ * @param code the GNUNET_hash to index bit-wise
  * @param bit index into the hashcode, [0...511]
  * @return Bit \a bit from hashcode \a code, -1 for invalid index
  */
 int
-getHashCodeBit (const HashCode512 * code, unsigned int bit)
+GNUNET_hash_get_bit (const GNUNET_HashCode * code, unsigned int bit)
 {
-  if (bit >= 8 * sizeof (HashCode512))
+  if (bit >= 8 * sizeof (GNUNET_HashCode))
     {
       GE_ASSERT (NULL, 0);
       return -1;                /* error */
@@ -635,7 +637,7 @@
  * @return 1 if h1 > h2, -1 if h1 < h2 and 0 if h1 == h2.
  */
 int
-hashCodeCompare (const HashCode512 * h1, const HashCode512 * h2)
+GNUNET_hash_cmp (const GNUNET_HashCode * h1, const GNUNET_HashCode * h2)
 {
   unsigned int *i1;
   unsigned int *i2;
@@ -643,7 +645,8 @@
 
   i1 = (unsigned int *) h1;
   i2 = (unsigned int *) h2;
-  for (i = (sizeof (HashCode512) / sizeof (unsigned int)) - 1; i >= 0; i--)
+  for (i = (sizeof (GNUNET_HashCode) / sizeof (unsigned int)) - 1; i >= 0;
+       i--)
     {
       if (i1[i] > i2[i])
         return 1;
@@ -654,19 +657,20 @@
 }
 
 /**
- * Find out which of the two hash codes is closer to target
+ * Find out which of the two GNUNET_hash codes is closer to target
  * in the XOR metric (Kademlia).
  * @return -1 if h1 is closer, 1 if h2 is closer and 0 if h1==h2.
  */
 int
-hashCodeCompareDistance (const HashCode512 * h1,
-                         const HashCode512 * h2, const HashCode512 * target)
+GNUNET_hash_xorcmp (const GNUNET_HashCode * h1,
+                    const GNUNET_HashCode * h2,
+                    const GNUNET_HashCode * target)
 {
   int i;
   unsigned int d1;
   unsigned int d2;
 
-  for (i = sizeof (HashCode512) / sizeof (unsigned int) - 1; i >= 0; i--)
+  for (i = sizeof (GNUNET_HashCode) / sizeof (unsigned int) - 1; i >= 0; i--)
     {
       d1 = ((unsigned int *) h1)[i] ^ ((unsigned int *) target)[i];
       d2 = ((unsigned int *) h2)[i] ^ ((unsigned int *) target)[i];

Modified: GNUnet/src/util/crypto/hashingtest.c
===================================================================
--- GNUnet/src/util/crypto/hashingtest.c        2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/crypto/hashingtest.c        2007-11-23 11:51:54 UTC (rev 
5742)
@@ -31,18 +31,18 @@
 static int
 test (int number)
 {
-  HashCode512 h1;
-  HashCode512 h2;
-  EncName enc;
+  GNUNET_HashCode h1;
+  GNUNET_HashCode h2;
+  GNUNET_EncName enc;
 
-  memset (&h1, number, sizeof (HashCode512));
-  hash2enc (&h1, &enc);
-  if (OK != enc2hash ((char *) &enc, &h2))
+  memset (&h1, number, sizeof (GNUNET_HashCode));
+  GNUNET_hash_to_enc (&h1, &enc);
+  if (GNUNET_OK != GNUNET_enc_to_hash ((char *) &enc, &h2))
     {
       printf ("enc2hash failed!\n");
       return 1;
     }
-  if (!equalsHashCode512 (&h1, &h2))
+  if (0 != memcmp (&h1, &h2, sizeof (GNUNET_HashCode)))
     return 1;
   return 0;
 }

Modified: GNUnet/src/util/crypto/hashperf.c
===================================================================
--- GNUnet/src/util/crypto/hashperf.c   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/crypto/hashperf.c   2007-11-23 11:51:54 UTC (rev 5742)
@@ -31,32 +31,32 @@
 static void
 perfHash ()
 {
-  HashCode512 hc1;
-  HashCode512 hc2;
-  HashCode512 hc3;
+  GNUNET_HashCode hc1;
+  GNUNET_HashCode hc2;
+  GNUNET_HashCode hc3;
   int i;
   char *buf;
 
-  buf = MALLOC (1024 * 64);
+  buf = GNUNET_malloc (1024 * 64);
   memset (buf, 1, 1024 * 64);
-  hash ("foo", 3, &hc1);
+  GNUNET_hash ("foo", 3, &hc1);
   for (i = 0; i < 1024; i++)
     {
-      hash (&hc1, sizeof (HashCode512), &hc2);
-      hash (&hc2, sizeof (HashCode512), &hc1);
-      hash (buf, 1024 * 64, &hc3);
+      GNUNET_hash (&hc1, sizeof (GNUNET_HashCode), &hc2);
+      GNUNET_hash (&hc2, sizeof (GNUNET_HashCode), &hc1);
+      GNUNET_hash (buf, 1024 * 64, &hc3);
     }
-  FREE (buf);
+  GNUNET_free (buf);
 }
 
 int
 main (int argc, char *argv[])
 {
-  cron_t start;
+  GNUNET_CronTime start;
 
-  start = get_time ();
+  start = GNUNET_get_time ();
   perfHash ();
-  printf ("Hash perf took %llu ms\n", get_time () - start);
+  printf ("Hash perf took %llu ms\n", GNUNET_get_time () - start);
   return 0;
 }
 

Modified: GNUnet/src/util/crypto/hostkey_gcrypt.c
===================================================================
--- GNUnet/src/util/crypto/hostkey_gcrypt.c     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/crypto/hostkey_gcrypt.c     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -46,7 +46,7 @@
 /**
  * The private information of an RSA key pair.
  */
-struct PrivateKey
+struct GNUNET_RSA_PrivateKey
 {
   gcry_sexp_t sexp;
 };
@@ -90,10 +90,10 @@
 /**
  * This HostKey implementation uses RSA.
  */
-struct PrivateKey *
-makePrivateKey ()
+struct GNUNET_RSA_PrivateKey *
+GNUNET_RSA_create_key ()
 {
-  struct PrivateKey *ret;
+  struct GNUNET_RSA_PrivateKey *ret;
   gcry_sexp_t s_key;
   gcry_sexp_t s_keyparam;
   int rc;
@@ -127,7 +127,7 @@
     }
 #endif
   unlockGcrypt ();
-  ret = MALLOC (sizeof (struct PrivateKey));
+  ret = GNUNET_malloc (sizeof (struct GNUNET_RSA_PrivateKey));
   ret->sexp = s_key;
   return ret;
 }
@@ -136,12 +136,12 @@
  * Free memory occupied by hostkey
  */
 void
-freePrivateKey (struct PrivateKey *hostkey)
+GNUNET_RSA_free_key (struct GNUNET_RSA_PrivateKey *hostkey)
 {
   lockGcrypt ();
   gcry_sexp_release (hostkey->sexp);
   unlockGcrypt ();
-  FREE (hostkey);
+  GNUNET_free (hostkey);
 }
 
 static int
@@ -208,7 +208,8 @@
  * @param result where to write the result.
  */
 void
-getPublicKey (const struct PrivateKey *hostkey, PublicKey * result)
+GNUNET_RSA_get_public_key (const struct GNUNET_RSA_PrivateKey *hostkey,
+                           GNUNET_RSA_PublicKey * result)
 {
   gcry_mpi_t skey[2];
   size_t size;
@@ -223,21 +224,24 @@
   if (rc)
     DIE_GCRY (NULL, "key_from_sexp", rc);
 
-  result->len = htons (sizeof (PublicKey) - sizeof (result->padding));
-  result->sizen = htons (RSA_ENC_LEN);
+  result->len =
+    htons (sizeof (GNUNET_RSA_PublicKey) - sizeof (result->padding));
+  result->sizen = htons (GNUNET_RSA_DATA_ENCODING_LEN);
   result->padding = 0;
-  size = RSA_ENC_LEN;
+  size = GNUNET_RSA_DATA_ENCODING_LEN;
   rc = gcry_mpi_print (GCRYMPI_FMT_USG,
                        &result->key[0], size, &size, skey[0]);
   if (rc)
     DIE_GCRY (NULL, "gcry_mpi_print", rc);
-  adjust (&result->key[0], size, RSA_ENC_LEN);
-  size = RSA_KEY_LEN - RSA_ENC_LEN;
+  adjust (&result->key[0], size, GNUNET_RSA_DATA_ENCODING_LEN);
+  size = GNUNET_RSA_KEY_LEN - GNUNET_RSA_DATA_ENCODING_LEN;
   rc = gcry_mpi_print (GCRYMPI_FMT_USG,
-                       &result->key[RSA_ENC_LEN], size, &size, skey[1]);
+                       &result->key[GNUNET_RSA_DATA_ENCODING_LEN], size,
+                       &size, skey[1]);
   if (rc)
     DIE_GCRY (NULL, "gcry_mpi_print", rc);
-  adjust (&result->key[RSA_ENC_LEN], size, RSA_KEY_LEN - RSA_ENC_LEN);
+  adjust (&result->key[GNUNET_RSA_DATA_ENCODING_LEN], size,
+          GNUNET_RSA_KEY_LEN - GNUNET_RSA_DATA_ENCODING_LEN);
   gcry_mpi_release (skey[0]);
   gcry_mpi_release (skey[1]);
   unlockGcrypt ();
@@ -250,10 +254,10 @@
  * Note that the return type is not actually a private
  * key but rather an sexpression for the public key!
  */
-static struct PrivateKey *
-public2PrivateKey (const PublicKey * publicKey)
+static struct GNUNET_RSA_PrivateKey *
+public2PrivateKey (const GNUNET_RSA_PublicKey * publicKey)
 {
-  struct PrivateKey *ret;
+  struct GNUNET_RSA_PrivateKey *ret;
   gcry_sexp_t result;
   gcry_mpi_t n;
   gcry_mpi_t e;
@@ -261,14 +265,14 @@
   size_t erroff;
   int rc;
 
-  if ((ntohs (publicKey->sizen) != RSA_ENC_LEN) ||
+  if ((ntohs (publicKey->sizen) != GNUNET_RSA_DATA_ENCODING_LEN) ||
       (ntohs (publicKey->len) !=
-       sizeof (PublicKey) - sizeof (publicKey->padding)))
+       sizeof (GNUNET_RSA_PublicKey) - sizeof (publicKey->padding)))
     {
       GE_BREAK (NULL, 0);
       return NULL;
     }
-  size = RSA_ENC_LEN;
+  size = GNUNET_RSA_DATA_ENCODING_LEN;
   lockGcrypt ();
   rc = gcry_mpi_scan (&n, GCRYMPI_FMT_USG, &publicKey->key[0], size, &size);
   if (rc)
@@ -277,10 +281,11 @@
       unlockGcrypt ();
       return NULL;
     }
-  size = RSA_KEY_LEN - RSA_ENC_LEN;
+  size = GNUNET_RSA_KEY_LEN - GNUNET_RSA_DATA_ENCODING_LEN;
   rc = gcry_mpi_scan (&e,
                       GCRYMPI_FMT_USG,
-                      &publicKey->key[RSA_ENC_LEN], size, &size);
+                      &publicKey->key[GNUNET_RSA_DATA_ENCODING_LEN], size,
+                      &size);
   if (rc)
     {
       LOG_GCRY (NULL, LOG_ERROR, "gcry_mpi_scan", rc);
@@ -299,7 +304,7 @@
       return NULL;
     }
   unlockGcrypt ();
-  ret = MALLOC (sizeof (struct PrivateKey));
+  ret = GNUNET_malloc (sizeof (struct GNUNET_RSA_PrivateKey));
   ret->sexp = result;
   return ret;
 }
@@ -310,10 +315,10 @@
  * @returns encoding of the private key.
  *    The first 4 bytes give the size of the array, as usual.
  */
-PrivateKeyEncoded *
-encodePrivateKey (const struct PrivateKey * hostkey)
+GNUNET_RSA_PrivateKeyEncoded *
+GNUNET_RSA_encode_key (const struct GNUNET_RSA_PrivateKey * hostkey)
 {
-  PrivateKeyEncoded *retval;
+  GNUNET_RSA_PrivateKeyEncoded *retval;
   gcry_mpi_t pkv[6];
   void *pbu[6];
   size_t sizes[6];
@@ -349,7 +354,7 @@
       unlockGcrypt ();
       return NULL;
     }
-  size = sizeof (PrivateKeyEncoded);
+  size = sizeof (GNUNET_RSA_PrivateKeyEncoded);
   for (i = 0; i < 6; i++)
     {
       if (pkv[i] != NULL)
@@ -378,7 +383,7 @@
         }
     }
   GE_ASSERT (NULL, size < 65536);
-  retval = MALLOC (size);
+  retval = GNUNET_malloc (size);
   retval->len = htons (size);
   i = 0;
   retval->sizen = htons (sizes[0]);
@@ -415,10 +420,10 @@
  * Decode the private key from the file-format back
  * to the "normal", internal format.
  */
-struct PrivateKey *
-decodePrivateKey (const PrivateKeyEncoded * encoding)
+struct GNUNET_RSA_PrivateKey *
+GNUNET_RSA_decode_key (const GNUNET_RSA_PrivateKeyEncoded * encoding)
 {
-  struct PrivateKey *ret;
+  struct GNUNET_RSA_PrivateKey *ret;
   gcry_sexp_t res;
   gcry_mpi_t n, e, d, p, q, u;
   int rc;
@@ -511,7 +516,7 @@
     p = NULL;
   pos += ntohs (encoding->sizedmp1);
   pos += ntohs (encoding->sizedmq1);
-  size = ntohs (encoding->len) - sizeof (PrivateKeyEncoded) - pos;
+  size = ntohs (encoding->len) - sizeof (GNUNET_RSA_PrivateKeyEncoded) - pos;
   if (size > 0)
     {
       rc = gcry_mpi_scan (&u,
@@ -576,7 +581,7 @@
       return NULL;
     }
 #endif
-  ret = MALLOC (sizeof (struct PrivateKey));
+  ret = GNUNET_malloc (sizeof (struct GNUNET_RSA_PrivateKey));
   ret->sexp = res;
   unlockGcrypt ();
   return ret;
@@ -590,23 +595,24 @@
  * @param size the size of block
  * @param publicKey the encoded public key used to encrypt
  * @param target where to store the encrypted block
- * @returns SYSERR on error, OK if ok
+ * @returns GNUNET_SYSERR on error, GNUNET_OK if ok
  */
 int
-encryptPrivateKey (const void *block,
-                   unsigned short size,
-                   const PublicKey * publicKey, RSAEncryptedData * target)
+GNUNET_RSA_encrypt (const void *block,
+                    unsigned short size,
+                    const GNUNET_RSA_PublicKey * publicKey,
+                    GNUNET_RSA_EncryptedData * target)
 {
   gcry_sexp_t result;
   gcry_sexp_t data;
-  struct PrivateKey *pubkey;
+  struct GNUNET_RSA_PrivateKey *pubkey;
   gcry_mpi_t val;
   gcry_mpi_t rval;
   size_t isize;
   size_t erroff;
   int rc;
 
-  GE_ASSERT (NULL, size <= sizeof (HashCode512));
+  GE_ASSERT (NULL, size <= sizeof (GNUNET_HashCode));
   pubkey = public2PrivateKey (publicKey);
   isize = size;
   lockGcrypt ();
@@ -614,9 +620,9 @@
   if (rc)
     {
       LOG_GCRY (NULL, LOG_ERROR, "gcry_mpi_scan", rc);
-      freePrivateKey (pubkey);
+      GNUNET_RSA_free_key (pubkey);
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   rc = gcry_sexp_build (&data,
                         &erroff, "(data (flags pkcs1)(value %m))", val);
@@ -624,9 +630,9 @@
   if (rc)
     {
       LOG_GCRY (NULL, LOG_ERROR, "gcry_sexp_build", rc);        /* more info 
in erroff */
-      freePrivateKey (pubkey);
+      GNUNET_RSA_free_key (pubkey);
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
   rc = gcry_pk_encrypt (&result, data, pubkey->sexp);
@@ -634,12 +640,12 @@
     {
       LOG_GCRY (NULL, LOG_ERROR, "gcry_pk_encrypt", rc);
       gcry_sexp_release (data);
-      freePrivateKey (pubkey);
+      GNUNET_RSA_free_key (pubkey);
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   gcry_sexp_release (data);
-  freePrivateKey (pubkey);
+  GNUNET_RSA_free_key (pubkey);
 
   rc = key_from_sexp (&rval, result, "rsa", "a");
   gcry_sexp_release (result);
@@ -647,9 +653,9 @@
     {
       LOG_GCRY (NULL, LOG_ERROR, "key_from_sexp", rc);
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  isize = sizeof (RSAEncryptedData);
+  isize = sizeof (GNUNET_RSA_EncryptedData);
   rc = gcry_mpi_print (GCRYMPI_FMT_USG,
                        (unsigned char *) target, isize, &isize, rval);
   gcry_mpi_release (rval);
@@ -657,11 +663,11 @@
     {
       LOG_GCRY (NULL, LOG_ERROR, "gcry_mpi_print", rc);
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  adjust (&target->encoding[0], isize, sizeof (RSAEncryptedData));
+  adjust (&target->encoding[0], isize, sizeof (GNUNET_RSA_EncryptedData));
   unlockGcrypt ();
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -675,9 +681,9 @@
  * @returns the size of the decrypted block, -1 on error
  */
 int
-decryptPrivateKey (const struct PrivateKey *hostkey,
-                   const RSAEncryptedData * block,
-                   void *result, unsigned short max)
+GNUNET_RSA_decrypt (const struct GNUNET_RSA_PrivateKey *hostkey,
+                    const GNUNET_RSA_EncryptedData * block,
+                    void *result, unsigned short max)
 {
   gcry_sexp_t resultsexp;
   gcry_sexp_t data;
@@ -698,14 +704,14 @@
       return -1;
     }
 #endif
-  size = sizeof (RSAEncryptedData);
+  size = sizeof (GNUNET_RSA_EncryptedData);
   rc = gcry_mpi_scan (&val,
                       GCRYMPI_FMT_USG, &block->encoding[0], size, &size);
   if (rc)
     {
       LOG_GCRY (NULL, LOG_ERROR, "gcry_mpi_scan", rc);
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   rc = gcry_sexp_build (&data, &erroff, "(enc-val(flags)(rsa(a %m)))", val);
   gcry_mpi_release (val);
@@ -713,7 +719,7 @@
     {
       LOG_GCRY (NULL, LOG_ERROR, "gcry_sexp_build", rc);        /* more info 
in erroff */
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   rc = gcry_pk_decrypt (&resultsexp, data, hostkey->sexp);
   gcry_sexp_release (data);
@@ -721,7 +727,7 @@
     {
       LOG_GCRY (NULL, LOG_ERROR, "gcry_pk_decrypt", rc);
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
   /* resultsexp has format "(value %m)" */
@@ -731,25 +737,25 @@
     {
       LOG_GCRY (NULL, LOG_ERROR, "gcry_sexp_nth_mpi", rc);
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  tmp = MALLOC (max + HOSTKEY_LEN / 8);
+  tmp = GNUNET_malloc (max + HOSTKEY_LEN / 8);
   size = max + HOSTKEY_LEN / 8;
   rc = gcry_mpi_print (GCRYMPI_FMT_USG, tmp, size, &size, val);
   gcry_mpi_release (val);
   if (rc)
     {
       LOG_GCRY (NULL, LOG_ERROR, "gcry_mpi_print", rc);
-      FREE (tmp);
+      GNUNET_free (tmp);
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
   endp = tmp;
   endp += (size - max);
   size = max;
   memcpy (result, endp, size);
-  FREE (tmp);
+  GNUNET_free (tmp);
   unlockGcrypt ();
   return size;
 }
@@ -757,43 +763,44 @@
 /**
  * Sign a given block.
  *
- * @param hostkey the hostkey with which to sign this block
- * @param size how many bytes to sign
- * @param block the data to sign
+ * @param hostkey the hostkey with which to GNUNET_RSA_sign this block
+ * @param size how many bytes to GNUNET_RSA_sign
+ * @param block the data to GNUNET_RSA_sign
  * @param sig where to write the signature
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 int
-sign (const struct PrivateKey *hostkey,
-      unsigned short size, const void *block, Signature * sig)
+GNUNET_RSA_sign (const struct GNUNET_RSA_PrivateKey *hostkey,
+                 unsigned short size, const void *block,
+                 GNUNET_RSA_Signature * sig)
 {
   gcry_sexp_t result;
   gcry_sexp_t data;
   size_t ssize;
   gcry_mpi_t rval;
-  HashCode512 hc;
+  GNUNET_HashCode hc;
   char *buff;
   int bufSize;
   int rc;
 
-  hash (block, size, &hc);
+  GNUNET_hash (block, size, &hc);
 #define FORMATSTRING 
"(4:data(5:flags5:pkcs1)(4:hash6:sha51264:0123456789012345678901234567890123456789012345678901234567890123))"
   bufSize = strlen (FORMATSTRING) + 1;
-  buff = MALLOC (bufSize);
+  buff = GNUNET_malloc (bufSize);
   memcpy (buff, FORMATSTRING, bufSize);
   memcpy (&buff
           [bufSize -
            strlen
            
("0123456789012345678901234567890123456789012345678901234567890123))")
-           - 1], &hc, sizeof (HashCode512));
+           - 1], &hc, sizeof (GNUNET_HashCode));
   lockGcrypt ();
   rc = gcry_sexp_new (&data, buff, bufSize, 0);
-  FREE (buff);
+  GNUNET_free (buff);
   if (rc)
     {
       LOG_GCRY (NULL, LOG_ERROR, "gcry_sexp_new", rc);
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   rc = gcry_pk_sign (&result, data, hostkey->sexp);
   gcry_sexp_release (data);
@@ -801,7 +808,7 @@
     {
       LOG_GCRY (NULL, LOG_ERROR, "gcry_pk_sign", rc);
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   rc = key_from_sexp (&rval, result, "rsa", "s");
   gcry_sexp_release (result);
@@ -809,9 +816,9 @@
     {
       LOG_GCRY (NULL, LOG_ERROR, "key_from_sexp", rc);
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  ssize = sizeof (Signature);
+  ssize = sizeof (GNUNET_RSA_Signature);
   rc = gcry_mpi_print (GCRYMPI_FMT_USG,
                        (unsigned char *) sig, ssize, &ssize, rval);
   gcry_mpi_release (rval);
@@ -819,11 +826,11 @@
     {
       LOG_GCRY (NULL, LOG_ERROR, "gcry_mpi_print", rc);
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  adjust (&sig->sig[0], ssize, sizeof (Signature));
+  adjust (&sig->sig[0], ssize, sizeof (GNUNET_RSA_Signature));
   unlockGcrypt ();
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -833,25 +840,26 @@
  * @param len the length of the block
  * @param sig signature
  * @param publicKey public key of the signer
- * @returns OK if ok, SYSERR if invalid
+ * @returns GNUNET_OK if ok, GNUNET_SYSERR if invalid
  */
 int
-verifySig (const void *block,
-           unsigned short len,
-           const Signature * sig, const PublicKey * publicKey)
+GNUNET_RSA_verify (const void *block,
+                   unsigned short len,
+                   const GNUNET_RSA_Signature * sig,
+                   const GNUNET_RSA_PublicKey * publicKey)
 {
   gcry_sexp_t data;
   gcry_sexp_t sigdata;
   size_t size;
   gcry_mpi_t val;
-  struct PrivateKey *hostkey;
-  HashCode512 hc;
+  struct GNUNET_RSA_PrivateKey *hostkey;
+  GNUNET_HashCode hc;
   char *buff;
   int bufSize;
   size_t erroff;
   int rc;
 
-  size = sizeof (Signature);
+  size = sizeof (GNUNET_RSA_Signature);
   lockGcrypt ();
   rc = gcry_mpi_scan (&val,
                       GCRYMPI_FMT_USG,
@@ -860,7 +868,7 @@
     {
       LOG_GCRY (NULL, LOG_ERROR, "gcry_mpi_scan", rc);
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   rc = gcry_sexp_build (&sigdata, &erroff, "(sig-val(rsa(s %m)))", val);
   gcry_mpi_release (val);
@@ -868,27 +876,27 @@
     {
       LOG_GCRY (NULL, LOG_ERROR, "gcry_sexp_build", rc);
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  hash (block, len, &hc);
+  GNUNET_hash (block, len, &hc);
   bufSize = strlen (FORMATSTRING) + 1;
-  buff = MALLOC (bufSize);
+  buff = GNUNET_malloc (bufSize);
   memcpy (buff, FORMATSTRING, bufSize);
   memcpy (&buff[strlen (FORMATSTRING) -
                 strlen
                 
("0123456789012345678901234567890123456789012345678901234567890123))")],
-          &hc, sizeof (HashCode512));
+          &hc, sizeof (GNUNET_HashCode));
   rc = gcry_sexp_new (&data, buff, bufSize, 0);
-  FREE (buff);
+  GNUNET_free (buff);
   hostkey = public2PrivateKey (publicKey);
   if (hostkey == NULL)
     {
       gcry_sexp_release (data);
       gcry_sexp_release (sigdata);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   rc = gcry_pk_verify (sigdata, data, hostkey->sexp);
-  freePrivateKey (hostkey);
+  GNUNET_RSA_free_key (hostkey);
   gcry_sexp_release (data);
   gcry_sexp_release (sigdata);
   if (rc)
@@ -898,12 +906,12 @@
               _("RSA signature verification failed at %s:%d: %s\n"),
               __FILE__, __LINE__, gcry_strerror (rc));
       unlockGcrypt ();
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   else
     {
       unlockGcrypt ();
-      return OK;
+      return GNUNET_OK;
     }
 }
 

Modified: GNUnet/src/util/crypto/hostkeytest.c
===================================================================
--- GNUnet/src/util/crypto/hostkeytest.c        2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/crypto/hostkeytest.c        2007-11-23 11:51:54 UTC (rev 
5742)
@@ -32,38 +32,38 @@
 #define MAX_TESTVAL sizeof(SESSIONKEY)
 #define ITER 10
 
-#define PERF NO
+#define PERF GNUNET_NO
 
 static int
 testEncryptDecrypt ()
 {
-  struct PrivateKey *hostkey;
-  PublicKey pkey;
-  RSAEncryptedData target;
+  struct GNUNET_RSA_PrivateKey *hostkey;
+  GNUNET_RSA_PublicKey pkey;
+  GNUNET_RSA_EncryptedData target;
   char result[MAX_TESTVAL];
   int i;
-  TIME_T start;
+  GNUNET_Int32Time start;
   int ok;
 
   fprintf (stderr, "W");
-  hostkey = makePrivateKey ();
-  getPublicKey (hostkey, &pkey);
+  hostkey = GNUNET_RSA_create_key ();
+  GNUNET_RSA_get_public_key (hostkey, &pkey);
 
   ok = 0;
-  TIME (&start);
+  GNUNET_get_time_int32 (&start);
   for (i = 0; i < ITER; i++)
     {
       fprintf (stderr, ".");
-      if (SYSERR == encryptPrivateKey (TESTSTRING,
-                                       strlen (TESTSTRING) + 1,
-                                       &pkey, &target))
+      if (GNUNET_SYSERR == GNUNET_RSA_encrypt (TESTSTRING,
+                                               strlen (TESTSTRING) + 1,
+                                               &pkey, &target))
         {
           fprintf (stderr, "encryptPrivateKey returned SYSERR\n");
           ok++;
           continue;
         }
-      if (-1 == decryptPrivateKey (hostkey,
-                                   &target, result, strlen (TESTSTRING) + 1))
+      if (-1 == GNUNET_RSA_decrypt (hostkey,
+                                    &target, result, strlen (TESTSTRING) + 1))
         {
           fprintf (stderr, "decryptPrivateKey returned SYSERR\n");
           ok++;
@@ -79,37 +79,37 @@
         }
     }
   printf ("%d RSA encrypt/decrypt operations %ds (%d failures)\n",
-          ITER, (int) (TIME (NULL) - start), ok);
-  freePrivateKey (hostkey);
+          ITER, (int) (GNUNET_get_time_int32 (NULL) - start), ok);
+  GNUNET_RSA_free_key (hostkey);
   if (ok == 0)
-    return OK;
+    return GNUNET_OK;
   else
-    return SYSERR;
+    return GNUNET_SYSERR;
 }
 
 #if PERF
 static int
 testEncryptPerformance ()
 {
-  struct PrivateKey *hostkey;
-  PublicKey pkey;
-  RSAEncryptedData target;
+  struct GNUNET_RSA_PrivateKey *hostkey;
+  GNUNET_RSA_PublicKey pkey;
+  GNUNET_RSA_EncryptedData target;
   int i;
-  cron_t start;
+  GNUNET_CronTime start;
   int ok;
 
   fprintf (stderr, "W");
-  hostkey = makePrivateKey ();
-  getPublicKey (hostkey, &pkey);
+  hostkey = GNUNET_RSA_create_key ();
+  GNUNET_RSA_get_public_key (hostkey, &pkey);
 
   ok = 0;
-  start = get_time ();
+  start = GNUNET_get_time ();
   for (i = 0; i < ITER; i++)
     {
       fprintf (stderr, ".");
-      if (SYSERR == encryptPrivateKey (TESTSTRING,
-                                       strlen (TESTSTRING) + 1,
-                                       &pkey, &target))
+      if (GNUNET_SYSERR == GNUNET_RSA_encrypt (TESTSTRING,
+                                               strlen (TESTSTRING) + 1,
+                                               &pkey, &target))
         {
           fprintf (stderr, "encryptPrivateKey returned SYSERR\n");
           ok++;
@@ -117,51 +117,53 @@
         }
     }
   printf ("%d RSA encrypt operations %llu ms (%d failures)\n",
-          ITER, get_time () - start, ok);
-  freePrivateKey (hostkey);
+          ITER, GNUNET_get_time () - start, ok);
+  GNUNET_RSA_free_key (hostkey);
   if (ok != 0)
-    return SYSERR;
-  return OK;
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 #endif
 
 static int
 testEncryptDecryptSK ()
 {
-  struct PrivateKey *hostkey;
-  PublicKey pkey;
-  RSAEncryptedData target;
-  SESSIONKEY insk;
-  SESSIONKEY outsk;
+  struct GNUNET_RSA_PrivateKey *hostkey;
+  GNUNET_RSA_PublicKey pkey;
+  GNUNET_RSA_EncryptedData target;
+  GNUNET_AES_SessionKey insk;
+  GNUNET_AES_SessionKey outsk;
   int i;
-  TIME_T start;
+  GNUNET_Int32Time start;
   int ok;
 
   fprintf (stderr, "W");
-  hostkey = makePrivateKey ();
-  getPublicKey (hostkey, &pkey);
+  hostkey = GNUNET_RSA_create_key ();
+  GNUNET_RSA_get_public_key (hostkey, &pkey);
 
   ok = 0;
-  TIME (&start);
+  GNUNET_get_time_int32 (&start);
   for (i = 0; i < ITER; i++)
     {
       fprintf (stderr, ".");
-      makeSessionkey (&insk);
-      if (SYSERR == encryptPrivateKey (&insk,
-                                       sizeof (SESSIONKEY), &pkey, &target))
+      GNUNET_AES_create_session_key (&insk);
+      if (GNUNET_SYSERR == GNUNET_RSA_encrypt (&insk,
+                                               sizeof (GNUNET_AES_SessionKey),
+                                               &pkey, &target))
         {
           fprintf (stderr, "encryptPrivateKey returned SYSERR\n");
           ok++;
           continue;
         }
-      if (-1 == decryptPrivateKey (hostkey,
-                                   &target, &outsk, sizeof (SESSIONKEY)))
+      if (-1 == GNUNET_RSA_decrypt (hostkey,
+                                    &target, &outsk,
+                                    sizeof (GNUNET_AES_SessionKey)))
         {
           fprintf (stderr, "decryptPrivateKey returned SYSERR\n");
           ok++;
           continue;
         }
-      if (0 != memcmp (&insk, &outsk, sizeof (SESSIONKEY)))
+      if (0 != memcmp (&insk, &outsk, sizeof (GNUNET_AES_SessionKey)))
         {
           printf ("testEncryptDecryptSK failed!\n");
           ok++;
@@ -169,46 +171,48 @@
         }
     }
   printf ("%d RSA encrypt/decrypt SK operations %ds (%d failures)\n",
-          ITER, (int) (TIME (NULL) - start), ok);
-  freePrivateKey (hostkey);
+          ITER, (int) (GNUNET_get_time_int32 (NULL) - start), ok);
+  GNUNET_RSA_free_key (hostkey);
   if (ok != 0)
-    return SYSERR;
-  return OK;
+    return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 static int
 testSignVerify ()
 {
-  struct PrivateKey *hostkey;
-  Signature sig;
-  PublicKey pkey;
+  struct GNUNET_RSA_PrivateKey *hostkey;
+  GNUNET_RSA_Signature sig;
+  GNUNET_RSA_PublicKey pkey;
   int i;
-  TIME_T start;
-  int ok = OK;
+  GNUNET_Int32Time start;
+  int ok = GNUNET_OK;
 
   fprintf (stderr, "W");
-  hostkey = makePrivateKey ();
-  getPublicKey (hostkey, &pkey);
-  TIME (&start);
+  hostkey = GNUNET_RSA_create_key ();
+  GNUNET_RSA_get_public_key (hostkey, &pkey);
+  GNUNET_get_time_int32 (&start);
   for (i = 0; i < ITER; i++)
     {
       fprintf (stderr, ".");
-      if (SYSERR == sign (hostkey, strlen (TESTSTRING), TESTSTRING, &sig))
+      if (GNUNET_SYSERR ==
+          GNUNET_RSA_sign (hostkey, strlen (TESTSTRING), TESTSTRING, &sig))
         {
           fprintf (stderr, "sign returned SYSERR\n");
-          ok = SYSERR;
+          ok = GNUNET_SYSERR;
           continue;
         }
-      if (SYSERR == verifySig (TESTSTRING, strlen (TESTSTRING), &sig, &pkey))
+      if (GNUNET_SYSERR ==
+          GNUNET_RSA_verify (TESTSTRING, strlen (TESTSTRING), &sig, &pkey))
         {
           printf ("testSignVerify failed!\n");
-          ok = SYSERR;
+          ok = GNUNET_SYSERR;
           continue;
         }
     }
   printf ("%d RSA sign/verify operations %ds\n",
-          ITER, (int) (TIME (NULL) - start));
-  freePrivateKey (hostkey);
+          ITER, (int) (GNUNET_get_time_int32 (NULL) - start));
+  GNUNET_RSA_free_key (hostkey);
   return ok;
 }
 
@@ -216,29 +220,31 @@
 static int
 testSignPerformance ()
 {
-  struct PrivateKey *hostkey;
-  Signature sig;
-  PublicKey pkey;
+  struct GNUNET_RSA_PrivateKey *hostkey;
+  GNUNET_RSA_Signature sig;
+  GNUNET_RSA_PublicKey pkey;
   int i;
-  cron_t start;
-  int ok = OK;
+  GNUNET_CronTime start;
+  int ok = GNUNET_OK;
 
   fprintf (stderr, "W");
-  hostkey = makePrivateKey ();
-  getPublicKey (hostkey, &pkey);
-  start = get_time ();
+  hostkey = GNUNET_RSA_create_key ();
+  GNUNET_RSA_get_public_key (hostkey, &pkey);
+  start = GNUNET_get_time ();
   for (i = 0; i < ITER; i++)
     {
       fprintf (stderr, ".");
-      if (SYSERR == sign (hostkey, strlen (TESTSTRING), TESTSTRING, &sig))
+      if (GNUNET_SYSERR ==
+          GNUNET_RSA_sign (hostkey, strlen (TESTSTRING), TESTSTRING, &sig))
         {
           fprintf (stderr, "sign returned SYSERR\n");
-          ok = SYSERR;
+          ok = GNUNET_SYSERR;
           continue;
         }
     }
-  printf ("%d RSA sign operations %llu ms\n", ITER, get_time () - start);
-  freePrivateKey (hostkey);
+  printf ("%d RSA sign operations %llu ms\n", ITER,
+          GNUNET_get_time () - start);
+  GNUNET_RSA_free_key (hostkey);
   return ok;
 }
 #endif
@@ -246,60 +252,61 @@
 static int
 testPrivateKeyEncoding ()
 {
-  struct PrivateKey *hostkey;
-  PrivateKeyEncoded *encoding;
-  PublicKey pkey;
-  RSAEncryptedData target;
+  struct GNUNET_RSA_PrivateKey *hostkey;
+  GNUNET_RSA_PrivateKeyEncoded *encoding;
+  GNUNET_RSA_PublicKey pkey;
+  GNUNET_RSA_EncryptedData target;
   char result[MAX_TESTVAL];
   int i;
-  TIME_T start;
-  int ok = OK;
+  GNUNET_Int32Time start;
+  int ok = GNUNET_OK;
 
   fprintf (stderr, "W");
-  hostkey = makePrivateKey ();
+  hostkey = GNUNET_RSA_create_key ();
 
-  TIME (&start);
+  GNUNET_get_time_int32 (&start);
   for (i = 0; i < ITER; i++)
     {
       fprintf (stderr, ".");
-      getPublicKey (hostkey, &pkey);
-      if (SYSERR == encryptPrivateKey (TESTSTRING,
-                                       strlen (TESTSTRING) + 1,
-                                       &pkey, &target))
+      GNUNET_RSA_get_public_key (hostkey, &pkey);
+      if (GNUNET_SYSERR == GNUNET_RSA_encrypt (TESTSTRING,
+                                               strlen (TESTSTRING) + 1,
+                                               &pkey, &target))
         {
           fprintf (stderr, "encryptPrivateKey returned SYSERR\n");
-          ok = SYSERR;
+          ok = GNUNET_SYSERR;
           continue;
         }
-      encoding = encodePrivateKey (hostkey);
-      freePrivateKey (hostkey);
+      encoding = GNUNET_RSA_encode_key (hostkey);
+      GNUNET_RSA_free_key (hostkey);
       if (encoding == NULL)
         {
           fprintf (stderr, "encodePrivateKey returned NULL\n");
-          ok = SYSERR;
+          ok = GNUNET_SYSERR;
           continue;
         }
-      hostkey = decodePrivateKey (encoding);
-      FREE (encoding);
-      if (SYSERR == decryptPrivateKey (hostkey,
-                                       &target,
-                                       result, strlen (TESTSTRING) + 1))
+      hostkey = GNUNET_RSA_decode_key (encoding);
+      GNUNET_free (encoding);
+      if (GNUNET_SYSERR == GNUNET_RSA_decrypt (hostkey,
+                                               &target,
+                                               result,
+                                               strlen (TESTSTRING) + 1))
         {
           fprintf (stderr, "decryptPrivateKey returned SYSERR\n");
-          ok = SYSERR;
+          ok = GNUNET_SYSERR;
           continue;
         }
       if (strncmp (TESTSTRING, result, strlen (TESTSTRING)) != 0)
         {
           printf ("%s != %.*s - testEncryptDecrypt failed!\n",
                   TESTSTRING, (int) strlen (TESTSTRING), result);
-          ok = SYSERR;
+          ok = GNUNET_SYSERR;
           continue;
         }
     }
-  freePrivateKey (hostkey);
+  GNUNET_RSA_free_key (hostkey);
   printf ("%d RSA encrypt/encode/decode/decrypt operations %ds\n",
-          ITER, (int) (TIME (NULL) - start));
+          ITER, (int) (GNUNET_get_time_int32 (NULL) - start));
   return ok;
 }
 
@@ -309,18 +316,18 @@
   int failureCount = 0;
 
 #if PERF
-  if (OK != testEncryptPerformance ())
+  if (GNUNET_OK != testEncryptPerformance ())
     failureCount++;
-  if (OK != testSignPerformance ())
+  if (GNUNET_OK != testSignPerformance ())
     failureCount++;
 #endif
-  if (OK != testEncryptDecryptSK ())
+  if (GNUNET_OK != testEncryptDecryptSK ())
     failureCount++;
-  if (OK != testEncryptDecrypt ())
+  if (GNUNET_OK != testEncryptDecrypt ())
     failureCount++;
-  if (OK != testSignVerify ())
+  if (GNUNET_OK != testSignVerify ())
     failureCount++;
-  if (OK != testPrivateKeyEncoding ())
+  if (GNUNET_OK != testPrivateKeyEncoding ())
     failureCount++;
 
   if (failureCount != 0)

Modified: GNUnet/src/util/crypto/kblockkey.c
===================================================================
--- GNUnet/src/util/crypto/kblockkey.c  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/crypto/kblockkey.c  2007-11-23 11:51:54 UTC (rev 5742)
@@ -171,24 +171,24 @@
 }
 
 static void
-mpz_randomize (mpz_t n, unsigned int nbits, HashCode512 * rnd)
+mpz_randomize (mpz_t n, unsigned int nbits, GNUNET_HashCode * rnd)
 {
-  HashCode512 *tmp;
+  GNUNET_HashCode *tmp;
   int cnt;
   int i;
 
-  cnt = (nbits / sizeof (HashCode512) / 8) + 1;
-  tmp = MALLOC (sizeof (HashCode512) * cnt);
+  cnt = (nbits / sizeof (GNUNET_HashCode) / 8) + 1;
+  tmp = GNUNET_malloc (sizeof (GNUNET_HashCode) * cnt);
 
   tmp[0] = *rnd;
   for (i = 0; i < cnt - 1; i++)
     {
-      hash (&tmp[i], sizeof (HashCode512), &tmp[i + 1]);
+      GNUNET_hash (&tmp[i], sizeof (GNUNET_HashCode), &tmp[i + 1]);
     }
   *rnd = tmp[cnt - 1];
-  mpz_import (n, cnt * sizeof (HashCode512) / sizeof (unsigned int),
+  mpz_import (n, cnt * sizeof (GNUNET_HashCode) / sizeof (unsigned int),
               1, sizeof (unsigned int), 1, 0, tmp);
-  FREE (tmp);
+  GNUNET_free (tmp);
   i = get_nbits (n);
   while (i > nbits)
     mpz_clrbit (n, i--);
@@ -198,7 +198,7 @@
  * Return true if n is probably a prime
  */
 static int
-is_prime (mpz_t n, int steps, HashCode512 * hc)
+is_prime (mpz_t n, int steps, GNUNET_HashCode * hc)
 {
   mpz_t x;
   mpz_t y;
@@ -273,7 +273,7 @@
 }
 
 static void
-gen_prime (mpz_t ptest, unsigned int nbits, HashCode512 * hc)
+gen_prime (mpz_t ptest, unsigned int nbits, GNUNET_HashCode * hc)
 {
   mpz_t prime, pminus1, val_2, val_3, result;
   int i;
@@ -283,7 +283,7 @@
 
   GE_ASSERT (NULL, nbits >= 16);
 
-  mods = MALLOC (no_of_small_prime_numbers * sizeof (*mods));
+  mods = GNUNET_malloc (no_of_small_prime_numbers * sizeof (*mods));
   /* Make nbits fit into mpz_t implementation. */
   mpz_init_set_ui (val_2, 2);
   mpz_init_set_ui (val_3, 3);
@@ -337,7 +337,7 @@
               mpz_clear (result);
               mpz_clear (pminus1);
               mpz_clear (prime);
-              FREE (mods);
+              GNUNET_free (mods);
               return;
             }
         }
@@ -378,7 +378,7 @@
  */
 static void
 generate_kblock_key (KBlock_secret_key * sk,
-                     unsigned int nbits, HashCode512 * hc)
+                     unsigned int nbits, GNUNET_HashCode * hc)
 {
   mpz_t t1, t2;
   mpz_t phi;                    /* helper: (p-1)(q-1) */
@@ -446,15 +446,15 @@
  * Deterministically (!) create a hostkey using only the
  * given HashCode as input to the PRNG.
  */
-static PrivateKeyEncoded *
-makeKblockKeyInternal (const HashCode512 * hc)
+static GNUNET_RSA_PrivateKeyEncoded *
+makeKblockKeyInternal (const GNUNET_HashCode * hc)
 {
   KBlock_secret_key sk;
-  HashCode512 hx;
+  GNUNET_HashCode hx;
   void *pbu[6];
   mpz_t *pkv[6];
   size_t sizes[6];
-  PrivateKeyEncoded *retval;
+  GNUNET_RSA_PrivateKeyEncoded *retval;
   int i;
   size_t size;
 
@@ -475,7 +475,7 @@
   pkv[3] = &sk.p;
   pkv[4] = &sk.q;
   pkv[5] = &sk.u;
-  size = sizeof (PrivateKeyEncoded);
+  size = sizeof (GNUNET_RSA_PrivateKeyEncoded);
   for (i = 0; i < 6; i++)
     {
       pbu[i] = mpz_export (NULL, &sizes[i], 1,  /* most significant word first 
*/
@@ -486,7 +486,7 @@
       size += sizes[i];
     }
   GE_ASSERT (NULL, size < 65536);
-  retval = MALLOC (size);
+  retval = GNUNET_malloc (size);
   retval->len = htons (size);
   i = 0;
   retval->sizen = htons (sizes[0]);
@@ -518,48 +518,48 @@
 
 typedef struct
 {
-  HashCode512 hc;
-  PrivateKeyEncoded *pke;
+  GNUNET_HashCode hc;
+  GNUNET_RSA_PrivateKeyEncoded *pke;
 } KBlockKeyCacheLine;
 
 static KBlockKeyCacheLine **cache;
 static unsigned int cacheSize;
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 /**
  * Deterministically (!) create a hostkey using only the
  * given HashCode as input to the PRNG.
  */
-struct PrivateKey *
-makeKblockKey (const HashCode512 * hc)
+struct GNUNET_RSA_PrivateKey *
+GNUNET_RSA_create_key_from_hash (const GNUNET_HashCode * hc)
 {
-  struct PrivateKey *ret;
+  struct GNUNET_RSA_PrivateKey *ret;
   KBlockKeyCacheLine *line;
   int i;
 
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   for (i = 0; i < cacheSize; i++)
     {
-      if (equalsHashCode512 (hc, &cache[i]->hc))
+      if (0 == memcmp (hc, &cache[i]->hc, sizeof (GNUNET_HashCode)))
         {
-          ret = decodePrivateKey (cache[i]->pke);
-          MUTEX_UNLOCK (lock);
+          ret = GNUNET_RSA_decode_key (cache[i]->pke);
+          GNUNET_mutex_unlock (lock);
           return ret;
         }
     }
 
-  line = MALLOC (sizeof (KBlockKeyCacheLine));
+  line = GNUNET_malloc (sizeof (KBlockKeyCacheLine));
   line->hc = *hc;
   line->pke = makeKblockKeyInternal (hc);
-  GROW (cache, cacheSize, cacheSize + 1);
+  GNUNET_array_grow (cache, cacheSize, cacheSize + 1);
   cache[cacheSize - 1] = line;
-  MUTEX_UNLOCK (lock);
-  return decodePrivateKey (line->pke);
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_RSA_decode_key (line->pke);
 }
 
 void __attribute__ ((constructor)) gnunet_crypto_kblock_ltdl_init (void)
 {
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
 }
 
 void __attribute__ ((destructor)) gnunet_crypto_kblock_ltdl_fini (void)
@@ -567,11 +567,11 @@
   int i;
   for (i = 0; i < cacheSize; i++)
     {
-      FREE (cache[i]->pke);
-      FREE (cache[i]);
+      GNUNET_free (cache[i]->pke);
+      GNUNET_free (cache[i]);
     }
-  GROW (cache, cacheSize, 0);
-  MUTEX_DESTROY (lock);
+  GNUNET_array_grow (cache, cacheSize, 0);
+  GNUNET_mutex_destroy (lock);
 }
 
 /* end of kblockkey.c */

Modified: GNUnet/src/util/crypto/kblockkey_test.c
===================================================================
--- GNUnet/src/util/crypto/kblockkey_test.c     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/crypto/kblockkey_test.c     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -37,78 +37,78 @@
 static int
 testMultiKey (const char *word)
 {
-  HashCode512 in;
-  struct PrivateKey *hostkey;
-  PublicKey pkey;
-  PublicKey pkey1;
+  GNUNET_HashCode in;
+  struct GNUNET_RSA_PrivateKey *hostkey;
+  GNUNET_RSA_PublicKey pkey;
+  GNUNET_RSA_PublicKey pkey1;
   int i;
 
   fprintf (stderr, "Testing KBlock key uniqueness (%s) ", word);
-  hash (word, strlen (word), &in);
-  hostkey = makeKblockKey (&in);
+  GNUNET_hash (word, strlen (word), &in);
+  hostkey = GNUNET_RSA_create_key_from_hash (&in);
   if (hostkey == NULL)
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  getPublicKey (hostkey, &pkey);
+  GNUNET_RSA_get_public_key (hostkey, &pkey);
   /*
-     for (i=0;i<sizeof(PublicKey);i++)
+     for (i=0;i<sizeof(GNUNET_RSA_PublicKey);i++)
      printf("%02x", ((unsigned char*) &pkey)[i]);
      printf("\n"); */
-  freePrivateKey (hostkey);
+  GNUNET_RSA_free_key (hostkey);
   for (i = 0; i < UNIQUE_ITER; i++)
     {
       fprintf (stderr, ".");
-      hostkey = makeKblockKey (&in);
+      hostkey = GNUNET_RSA_create_key_from_hash (&in);
       if (hostkey == NULL)
         {
           GE_BREAK (NULL, 0);
           fprintf (stderr, " ERROR\n");
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
-      getPublicKey (hostkey, &pkey1);
-      freePrivateKey (hostkey);
-      if (0 != memcmp (&pkey, &pkey1, sizeof (PublicKey)))
+      GNUNET_RSA_get_public_key (hostkey, &pkey1);
+      GNUNET_RSA_free_key (hostkey);
+      if (0 != memcmp (&pkey, &pkey1, sizeof (GNUNET_RSA_PublicKey)))
         {
           GE_BREAK (NULL, 0);
           fprintf (stderr, " ERROR\n");
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
     }
   fprintf (stderr, " OK\n");
-  return OK;
+  return GNUNET_OK;
 }
 
 
 static int
-testEncryptDecrypt (struct PrivateKey *hostkey)
+testEncryptDecrypt (struct GNUNET_RSA_PrivateKey *hostkey)
 {
-  PublicKey pkey;
-  RSAEncryptedData target;
+  GNUNET_RSA_PublicKey pkey;
+  GNUNET_RSA_EncryptedData target;
   char result[MAX_TESTVAL];
   int i;
-  TIME_T start;
+  GNUNET_Int32Time start;
   int ok;
 
   fprintf (stderr, "W");
-  getPublicKey (hostkey, &pkey);
+  GNUNET_RSA_get_public_key (hostkey, &pkey);
 
   ok = 0;
-  TIME (&start);
+  GNUNET_get_time_int32 (&start);
   for (i = 0; i < ITER; i++)
     {
       fprintf (stderr, ".");
-      if (SYSERR == encryptPrivateKey (TESTSTRING,
-                                       strlen (TESTSTRING) + 1,
-                                       &pkey, &target))
+      if (GNUNET_SYSERR == GNUNET_RSA_encrypt (TESTSTRING,
+                                               strlen (TESTSTRING) + 1,
+                                               &pkey, &target))
         {
           fprintf (stderr, "encryptPrivateKey returned SYSERR\n");
           ok++;
           continue;
         }
-      if (-1 == decryptPrivateKey (hostkey,
-                                   &target, result, strlen (TESTSTRING) + 1))
+      if (-1 == GNUNET_RSA_decrypt (hostkey,
+                                    &target, result, strlen (TESTSTRING) + 1))
         {
           fprintf (stderr, "decryptPrivateKey returned SYSERR\n");
           ok++;
@@ -123,102 +123,105 @@
         }
     }
   printf ("%d RSA encrypt/decrypt operations %ds (%d failures)\n",
-          ITER, (int) (TIME (NULL) - start), ok);
+          ITER, (int) (GNUNET_get_time_int32 (NULL) - start), ok);
   if (ok == 0)
-    return OK;
+    return GNUNET_OK;
   else
-    return SYSERR;
+    return GNUNET_SYSERR;
 }
 
 static int
-testSignVerify (struct PrivateKey *hostkey)
+testSignVerify (struct GNUNET_RSA_PrivateKey *hostkey)
 {
-  Signature sig;
-  PublicKey pkey;
+  GNUNET_RSA_Signature sig;
+  GNUNET_RSA_PublicKey pkey;
   int i;
-  TIME_T start;
-  int ok = OK;
+  GNUNET_Int32Time start;
+  int ok = GNUNET_OK;
 
   fprintf (stderr, "W");
-  getPublicKey (hostkey, &pkey);
-  TIME (&start);
+  GNUNET_RSA_get_public_key (hostkey, &pkey);
+  GNUNET_get_time_int32 (&start);
   for (i = 0; i < ITER; i++)
     {
       fprintf (stderr, ".");
-      if (SYSERR == sign (hostkey, strlen (TESTSTRING), TESTSTRING, &sig))
+      if (GNUNET_SYSERR ==
+          GNUNET_RSA_sign (hostkey, strlen (TESTSTRING), TESTSTRING, &sig))
         {
           fprintf (stderr, "sign returned SYSERR\n");
-          ok = SYSERR;
+          ok = GNUNET_SYSERR;
           continue;
         }
-      if (SYSERR == verifySig (TESTSTRING, strlen (TESTSTRING), &sig, &pkey))
+      if (GNUNET_SYSERR ==
+          GNUNET_RSA_verify (TESTSTRING, strlen (TESTSTRING), &sig, &pkey))
         {
           printf ("testSignVerify failed!\n");
-          ok = SYSERR;
+          ok = GNUNET_SYSERR;
           continue;
         }
     }
   printf ("%d RSA sign/verify operations %ds\n",
-          ITER, (int) (TIME (NULL) - start));
+          ITER, (int) (GNUNET_get_time_int32 (NULL) - start));
   return ok;
 }
 
 static int
-testPrivateKeyEncoding (const struct PrivateKey *hostkey)
+testPrivateKeyEncoding (const struct GNUNET_RSA_PrivateKey *hostkey)
 {
-  PrivateKeyEncoded *encoding;
-  struct PrivateKey *hostkey2;
-  PublicKey pkey;
-  RSAEncryptedData target;
+  GNUNET_RSA_PrivateKeyEncoded *encoding;
+  struct GNUNET_RSA_PrivateKey *hostkey2;
+  GNUNET_RSA_PublicKey pkey;
+  GNUNET_RSA_EncryptedData target;
   char result[MAX_TESTVAL];
   int i;
-  TIME_T start;
-  int ok = OK;
+  GNUNET_Int32Time start;
+  int ok = GNUNET_OK;
 
   fprintf (stderr, "W");
 
-  TIME (&start);
+  GNUNET_get_time_int32 (&start);
   for (i = 0; i < ITER; i++)
     {
       fprintf (stderr, ".");
-      getPublicKey (hostkey, &pkey);
-      if (SYSERR == encryptPrivateKey (TESTSTRING,
-                                       strlen (TESTSTRING) + 1,
-                                       &pkey, &target))
+      GNUNET_RSA_get_public_key (hostkey, &pkey);
+      if (GNUNET_SYSERR == GNUNET_RSA_encrypt (TESTSTRING,
+                                               strlen (TESTSTRING) + 1,
+                                               &pkey, &target))
         {
           fprintf (stderr, "encryptPrivateKey returned SYSERR\n");
-          ok = SYSERR;
+          ok = GNUNET_SYSERR;
           continue;
         }
-      encoding = encodePrivateKey (hostkey);
+      encoding = GNUNET_RSA_encode_key (hostkey);
       if (encoding == NULL)
         {
           fprintf (stderr, "encodePrivateKey returned NULL\n");
-          ok = SYSERR;
+          ok = GNUNET_SYSERR;
           continue;
         }
-      hostkey2 = decodePrivateKey (encoding);
-      FREE (encoding);
-      if (SYSERR == decryptPrivateKey (hostkey2,
-                                       &target,
-                                       result, strlen (TESTSTRING) + 1))
+      hostkey2 = GNUNET_RSA_decode_key (encoding);
+      GNUNET_free (encoding);
+      if (GNUNET_SYSERR == GNUNET_RSA_decrypt (hostkey2,
+                                               &target,
+                                               result,
+                                               strlen (TESTSTRING) + 1))
         {
           fprintf (stderr, "decryptPrivateKey returned SYSERR\n");
-          ok = SYSERR;
-          freePrivateKey (hostkey2);
+          ok = GNUNET_SYSERR;
+          GNUNET_RSA_free_key (hostkey2);
           continue;
         }
-      freePrivateKey (hostkey2);
+      GNUNET_RSA_free_key (hostkey2);
       if (strncmp (TESTSTRING, result, strlen (TESTSTRING)) != 0)
         {
           printf ("%s != %.*s - testEncryptDecrypt failed!\n",
                   TESTSTRING, (int) strlen (TESTSTRING), result);
-          ok = SYSERR;
+          ok = GNUNET_SYSERR;
           continue;
         }
     }
   printf ("%d RSA encrypt/encode/decode/decrypt operations %ds\n",
-          ITER, (int) (TIME (NULL) - start));
+          ITER, (int) (GNUNET_get_time_int32 (NULL) - start));
   return ok;
 }
 
@@ -226,28 +229,28 @@
 main (int argc, char *argv[])
 {
   int failureCount = 0;
-  HashCode512 in;
-  struct PrivateKey *hostkey;
+  GNUNET_HashCode in;
+  struct GNUNET_RSA_PrivateKey *hostkey;
 
-  makeRandomId (&in);
-  hostkey = makeKblockKey (&in);
+  GNUNET_create_random_hash (&in);
+  hostkey = GNUNET_RSA_create_key_from_hash (&in);
   if (hostkey == NULL)
     {
       printf ("\nmakeKblockKey failed!\n");
       return 1;
     }
 
-  if (OK != testMultiKey ("foo"))
+  if (GNUNET_OK != testMultiKey ("foo"))
     failureCount++;
-  if (OK != testMultiKey ("bar"))
+  if (GNUNET_OK != testMultiKey ("bar"))
     failureCount++;
-  if (OK != testEncryptDecrypt (hostkey))
+  if (GNUNET_OK != testEncryptDecrypt (hostkey))
     failureCount++;
-  if (OK != testSignVerify (hostkey))
+  if (GNUNET_OK != testSignVerify (hostkey))
     failureCount++;
-  if (OK != testPrivateKeyEncoding (hostkey))
+  if (GNUNET_OK != testPrivateKeyEncoding (hostkey))
     failureCount++;
-  freePrivateKey (hostkey);
+  GNUNET_RSA_free_key (hostkey);
 
   if (failureCount != 0)
     {

Modified: GNUnet/src/util/crypto/locking_gcrypt.c
===================================================================
--- GNUnet/src/util/crypto/locking_gcrypt.c     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/crypto/locking_gcrypt.c     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -34,10 +34,10 @@
  * to gcrypt or should we tell gcrypt that we use
  * pthreads?
  */
-#define USE_LOCK NO
+#define USE_LOCK GNUNET_NO
 
 #if USE_LOCK
-static struct MUTEX *gcrypt_shared_lock;
+static struct GNUNET_Mutex *gcrypt_shared_lock;
 #else
 GCRY_THREAD_OPTION_PTHREAD_IMPL;
 #endif
@@ -47,7 +47,7 @@
 lockGcrypt ()
 {
 #if USE_LOCK
-  MUTEX_LOCK (gcrypt_shared_lock);
+  GNUNET_mutex_lock (gcrypt_shared_lock);
 #endif
 }
 
@@ -55,7 +55,7 @@
 unlockGcrypt ()
 {
 #if USE_LOCK
-  MUTEX_UNLOCK (gcrypt_shared_lock);
+  GNUNET_mutex_unlock (gcrypt_shared_lock);
 #endif
 }
 
@@ -68,7 +68,7 @@
 void __attribute__ ((constructor)) gnunet_crypto_ltdl_init ()
 {
 #if USE_LOCK
-  gcrypt_shared_lock = MUTEX_CREATE (YES);
+  gcrypt_shared_lock = GNUNET_mutex_create (GNUNET_YES);
 #else
   gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
 #endif
@@ -93,7 +93,7 @@
 void __attribute__ ((destructor)) gnunet_crypto_ltdl_fini ()
 {
 #if USE_LOCK
-  MUTEX_DESTROY (gcrypt_shared_lock);
+  GNUNET_mutex_destroy (gcrypt_shared_lock);
   gcrypt_shared_lock = NULL;
 #endif
 }

Modified: GNUnet/src/util/crypto/random.c
===================================================================
--- GNUnet/src/util/crypto/random.c     2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/crypto/random.c     2007-11-23 11:51:54 UTC (rev 5742)
@@ -34,7 +34,7 @@
  * @return a random value in the interval [0,i[.
  */
 unsigned int
-randomi (unsigned int i)
+GNUNET_random_u32 (int mode, unsigned int i)
 {
 #ifdef gcry_fast_random_poll
   static unsigned int invokeCount;
@@ -42,45 +42,55 @@
   unsigned int ret;
 
   GE_ASSERT (NULL, i > 0);
-  lockGcrypt ();
-  /* see http://lists.gnupg.org/pipermail/gcrypt-devel/2004-May/000613.html */
+
+  if (mode == GNUNET_RANDOM_QUALITY_STRONG)
+    {
+      lockGcrypt ();
+      /* see 
http://lists.gnupg.org/pipermail/gcrypt-devel/2004-May/000613.html */
 #ifdef gcry_fast_random_poll
-  if ((invokeCount++ % 256) == 0)
-    gcry_fast_random_poll ();
+      if ((invokeCount++ % 256) == 0)
+        gcry_fast_random_poll ();
 #endif
-  ret = rand ();                /* in case gcry_randomize fails,
+      ret = rand ();            /* in case gcry_randomize fails,
                                    we at least get a pseudo-
                                    random number this way */
-  gcry_randomize ((unsigned char *) &ret,
-                  sizeof (unsigned int), GCRY_STRONG_RANDOM);
-  unlockGcrypt ();
-  return ret % i;
+      gcry_randomize ((unsigned char *) &ret,
+                      sizeof (unsigned int), GCRY_STRONG_RANDOM);
+      unlockGcrypt ();
+      return ret % i;
+    }
+  else
+    {
+      ret = i * ((double) RANDOM () / RAND_MAX);
+      if (ret >= i)
+        ret = i - 1;
+      return ret;
+    }
 }
 
+
 /**
  * Get an array with a random permutation of the
  * numbers 0...n-1.
- * @param mode STRONG if the strong (but expensive) PRNG should be used, WEAK 
otherwise
+ * @param mode GNUNET_RANDOM_QUALITY_STRONG if the strong (but expensive) PRNG 
should be used, GNUNET_RANDOM_QUALITY_WEAK otherwise
  * @param n the size of the array
  * @return the permutation array (allocated from heap)
  */
-int *
-permute (int mode, int n)
+unsigned int *
+GNUNET_permute (int mode, unsigned int n)
 {
-  int *ret;
-  int i;
-  int tmp;
+  unsigned int *ret;
+  unsigned int i;
+  unsigned int tmp;
   unsigned int x;
-  unsigned int (*prng) (unsigned int u);
 
   GE_ASSERT (NULL, n > 0);
-  ret = MALLOC (n * sizeof (int));
-  prng = (mode == STRONG) ? randomi : weak_randomi;
+  ret = GNUNET_malloc (n * sizeof (int));
   for (i = 0; i < n; i++)
     ret[i] = i;
   for (i = 0; i < n; i++)
     {
-      x = prng (n);
+      x = GNUNET_random_u32 (mode, n);
       tmp = ret[x];
       ret[x] = ret[i];
       ret[i] = tmp;
@@ -92,43 +102,26 @@
  * Random on unsigned 64-bit values.
  */
 unsigned long long
-randomi64 (unsigned long long u)
+GNUNET_random_u64 (int mode, unsigned long long u)
 {
   unsigned long long ret;
 
   GE_ASSERT (NULL, u > 0);
-  lockGcrypt ();
-  gcry_randomize ((unsigned char *) &ret,
-                  sizeof (unsigned long long), GCRY_STRONG_RANDOM);
-  unlockGcrypt ();
-  return ret % u;
+  if (mode == GNUNET_RANDOM_QUALITY_STRONG)
+    {
+      lockGcrypt ();
+      gcry_randomize ((unsigned char *) &ret,
+                      sizeof (unsigned long long), GCRY_STRONG_RANDOM);
+      unlockGcrypt ();
+      return ret % u;
+    }
+  else
+    {
+      ret = u * ((double) RANDOM () / RAND_MAX);
+      if (ret >= u)
+        ret = u - 1;
+      return ret;
+    }
 }
 
-/**
- * @return a cryptographically weak random value in the interval [0,i[.
- */
-unsigned int
-weak_randomi (unsigned int i)
-{
-  unsigned int ret;
-
-  GE_ASSERT (NULL, i > 0);
-  ret = i * ((double) RANDOM () / RAND_MAX);
-  if (ret >= i)
-    ret = i - 1;
-  return ret;
-}
-
-unsigned long long
-weak_randomi64 (unsigned long long u)
-{
-  unsigned long long ret;
-
-  GE_ASSERT (NULL, u > 0);
-  ret = u * ((double) RANDOM () / RAND_MAX);
-  if (ret >= u)
-    ret = u - 1;
-  return ret;
-}
-
 /* end of random.c */

Modified: GNUnet/src/util/crypto/symcipher_gcrypt.c
===================================================================
--- GNUnet/src/util/crypto/symcipher_gcrypt.c   2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/crypto/symcipher_gcrypt.c   2007-11-23 11:51:54 UTC (rev 
5742)
@@ -57,12 +57,12 @@
  * Create a new SessionKey (for AES-256).
  */
 void
-makeSessionkey (SESSIONKEY * key)
+GNUNET_AES_create_session_key (GNUNET_AES_SessionKey * key)
 {
   lockGcrypt ();
-  gcry_randomize (&key->key[0], SESSIONKEY_LEN, GCRY_STRONG_RANDOM);
+  gcry_randomize (&key->key[0], GNUNET_SESSIONKEY_LEN, GCRY_STRONG_RANDOM);
   unlockGcrypt ();
-  key->crc32 = htonl (crc32N (key, SESSIONKEY_LEN));
+  key->crc32 = htonl (GNUNET_crc32_n (key, GNUNET_SESSIONKEY_LEN));
 }
 
 /**
@@ -77,18 +77,19 @@
  * @returns the size of the encrypted block, -1 for errors
  */
 int
-encryptBlock (const void *block,
-              unsigned short len,
-              const SESSIONKEY * sessionkey,
-              const INITVECTOR * iv, void *result)
+GNUNET_AES_encrypt (const void *block,
+                    unsigned short len,
+                    const GNUNET_AES_SessionKey * sessionkey,
+                    const GNUNET_AES_InitializationVector * iv, void *result)
 {
   gcry_cipher_hd_t handle;
   int rc;
 
-  if (sessionkey->crc32 != htonl (crc32N (sessionkey, SESSIONKEY_LEN)))
+  if (sessionkey->crc32 !=
+      htonl (GNUNET_crc32_n (sessionkey, GNUNET_SESSIONKEY_LEN)))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   lockGcrypt ();
   rc = gcry_cipher_open (&handle,
@@ -101,7 +102,7 @@
       unlockGcrypt ();
       return -1;
     }
-  rc = gcry_cipher_setkey (handle, sessionkey, SESSIONKEY_LEN);
+  rc = gcry_cipher_setkey (handle, sessionkey, GNUNET_SESSIONKEY_LEN);
 
   if (rc && ((char) rc != GPG_ERR_WEAK_KEY))
     {
@@ -112,7 +113,8 @@
       unlockGcrypt ();
       return -1;
     }
-  rc = gcry_cipher_setiv (handle, iv, sizeof (INITVECTOR));
+  rc =
+    gcry_cipher_setiv (handle, iv, sizeof (GNUNET_AES_InitializationVector));
   if (rc && ((char) rc != GPG_ERR_WEAK_KEY))
     {
       LOG_GCRY (NULL,
@@ -149,17 +151,19 @@
  * @return -1 on failure, size of decrypted block on success
  */
 int
-decryptBlock (const SESSIONKEY * sessionkey,
-              const void *block,
-              unsigned short size, const INITVECTOR * iv, void *result)
+GNUNET_AES_decrypt (const GNUNET_AES_SessionKey * sessionkey,
+                    const void *block,
+                    unsigned short size,
+                    const GNUNET_AES_InitializationVector * iv, void *result)
 {
   gcry_cipher_hd_t handle;
   int rc;
 
-  if (sessionkey->crc32 != htonl (crc32N (sessionkey, SESSIONKEY_LEN)))
+  if (sessionkey->crc32 !=
+      htonl (GNUNET_crc32_n (sessionkey, GNUNET_SESSIONKEY_LEN)))
     {
       GE_BREAK (NULL, 0);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   lockGcrypt ();
   rc = gcry_cipher_open (&handle,
@@ -172,7 +176,7 @@
       unlockGcrypt ();
       return -1;
     }
-  rc = gcry_cipher_setkey (handle, sessionkey, SESSIONKEY_LEN);
+  rc = gcry_cipher_setkey (handle, sessionkey, GNUNET_SESSIONKEY_LEN);
 
   if (rc && ((char) rc != GPG_ERR_WEAK_KEY))
     {
@@ -183,7 +187,8 @@
       unlockGcrypt ();
       return -1;
     }
-  rc = gcry_cipher_setiv (handle, iv, sizeof (INITVECTOR));
+  rc =
+    gcry_cipher_setiv (handle, iv, sizeof (GNUNET_AES_InitializationVector));
 
   if (rc && ((char) rc != GPG_ERR_WEAK_KEY))
     {

Modified: GNUnet/src/util/crypto/symciphertest.c
===================================================================
--- GNUnet/src/util/crypto/symciphertest.c      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/crypto/symciphertest.c      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -34,22 +34,26 @@
 static int
 testSymcipher ()
 {
-  SESSIONKEY key;
+  GNUNET_AES_SessionKey key;
   char result[100];
   int size;
   char res[100];
 
-  makeSessionkey (&key);
-  size = encryptBlock (TESTSTRING,
-                       strlen (TESTSTRING) + 1,
-                       &key, (const INITVECTOR *) INITVALUE, result);
+  GNUNET_AES_create_session_key (&key);
+  size = GNUNET_AES_encrypt (TESTSTRING,
+                             strlen (TESTSTRING) + 1,
+                             &key,
+                             (const GNUNET_AES_InitializationVector *)
+                             INITVALUE, result);
   if (size == -1)
     {
       printf ("symciphertest failed: encryptBlock returned %d\n", size);
       return 1;
     }
-  size = decryptBlock (&key,
-                       result, size, (const INITVECTOR *) INITVALUE, res);
+  size = GNUNET_AES_decrypt (&key,
+                             result, size,
+                             (const GNUNET_AES_InitializationVector *)
+                             INITVALUE, res);
   if (strlen (TESTSTRING) + 1 != size)
     {
       printf ("symciphertest failed: decryptBlock returned %d\n", size);
@@ -67,8 +71,8 @@
 int
 verifyCrypto ()
 {
-  SESSIONKEY key;
-  char result[SESSIONKEY_LEN];
+  GNUNET_AES_SessionKey key;
+  char result[GNUNET_SESSIONKEY_LEN];
   char *res;
   int ret;
 
@@ -90,8 +94,8 @@
   res = NULL;
   ret = 0;
 
-  memcpy (key.key, raw_key, SESSIONKEY_LEN);
-  key.crc32 = htonl (crc32N (&key, SESSIONKEY_LEN));
+  memcpy (key.key, raw_key, GNUNET_SESSIONKEY_LEN);
+  key.crc32 = htonl (GNUNET_crc32_n (&key, GNUNET_SESSIONKEY_LEN));
 
   if (ntohl (key.crc32) != (unsigned int) 38125195LL)
     {
@@ -102,37 +106,40 @@
       goto error;
     }
 
-  if (SESSIONKEY_LEN !=
-      encryptBlock (plain,
-                    SESSIONKEY_LEN,
-                    &key, (const INITVECTOR *) "testtesttesttest", result))
+  if (GNUNET_SESSIONKEY_LEN !=
+      GNUNET_AES_encrypt (plain,
+                          GNUNET_SESSIONKEY_LEN,
+                          &key,
+                          (const GNUNET_AES_InitializationVector *)
+                          "testtesttesttest", result))
     {
       printf ("Wrong return value from encrypt block.\n");
       ret = 1;
       goto error;
     }
 
-  if (memcmp (encrresult, result, SESSIONKEY_LEN) != 0)
+  if (memcmp (encrresult, result, GNUNET_SESSIONKEY_LEN) != 0)
     {
       printf ("Encrypted result wrong.\n");
       ret = 1;
       goto error;
     }
 
-  res = MALLOC (SESSIONKEY_LEN);
+  res = GNUNET_malloc (GNUNET_SESSIONKEY_LEN);
 
-  if (SESSIONKEY_LEN !=
-      decryptBlock (&key,
-                    result,
-                    SESSIONKEY_LEN,
-                    (const INITVECTOR *) "testtesttesttest", res))
+  if (GNUNET_SESSIONKEY_LEN !=
+      GNUNET_AES_decrypt (&key,
+                          result,
+                          GNUNET_SESSIONKEY_LEN,
+                          (const GNUNET_AES_InitializationVector *)
+                          "testtesttesttest", res))
     {
       printf ("Wrong return value from decrypt block.\n");
       ret = 1;
       goto error;
     }
 
-  if (memcmp (res, plain, SESSIONKEY_LEN) != 0)
+  if (memcmp (res, plain, GNUNET_SESSIONKEY_LEN) != 0)
     {
       printf ("Decrypted result does not match input.\n");
 
@@ -141,7 +148,7 @@
 
 error:
 
-  FREENONNULL (res);
+  GNUNET_free_non_null (res);
 
   return ret;
 }
@@ -151,7 +158,8 @@
 {
   int failureCount = 0;
 
-  GE_ASSERT (NULL, strlen (INITVALUE) > sizeof (INITVECTOR));
+  GE_ASSERT (NULL,
+             strlen (INITVALUE) > sizeof (GNUNET_AES_InitializationVector));
   failureCount += testSymcipher ();
   failureCount += verifyCrypto ();
 

Modified: GNUnet/src/util/crypto/weakkeytest.c
===================================================================
--- GNUnet/src/util/crypto/weakkeytest.c        2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/crypto/weakkeytest.c        2007-11-23 11:51:54 UTC (rev 
5742)
@@ -32,14 +32,14 @@
 #include "platform.h"
 
 #define MAX_WEAK_KEY_TRIALS 100000
-#define GENERATE_WEAK_KEYS NO
+#define GENERATE_WEAK_KEYS GNUNET_NO
 #define WEAK_KEY_TESTSTRING "I hate weak keys."
 
 static void
-printWeakKey (SESSIONKEY * key)
+printWeakKey (GNUNET_AES_SessionKey * key)
 {
   int i;
-  for (i = 0; i < SESSIONKEY_LEN; i++)
+  for (i = 0; i < GNUNET_SESSIONKEY_LEN; i++)
     {
       printf ("%x ", (int) (key->key[i]));
     }
@@ -51,10 +51,10 @@
   char result[100];
   char res[100];
   int size;
-  SESSIONKEY weak_key;
-  INITVECTOR INITVALUE;
+  GNUNET_AES_SessionKey weak_key;
+  GNUNET_AES_InitializationVector INITVALUE;
 
-  memset (&INITVALUE, 42, sizeof (INITVECTOR));
+  memset (&INITVALUE, 42, sizeof (GNUNET_AES_InitializationVector));
   /* sorry, this is not a weak key -- I don't have
      any at the moment! */
   weak_key.key[0] = (char) (0x4c);
@@ -90,11 +90,11 @@
   weak_key.key[30] = (char) (0xaa);
   weak_key.key[31] = (char) (0xaa);
   /* memset(&weak_key, 0, 32); */
-  weak_key.crc32 = htonl (crc32N (&weak_key, SESSIONKEY_LEN));
+  weak_key.crc32 = htonl (GNUNET_crc32_n (&weak_key, GNUNET_SESSIONKEY_LEN));
 
-  size = encryptBlock (WEAK_KEY_TESTSTRING,
-                       strlen (WEAK_KEY_TESTSTRING) + 1,
-                       &weak_key, &INITVALUE, result);
+  size = GNUNET_AES_encrypt (WEAK_KEY_TESTSTRING,
+                             strlen (WEAK_KEY_TESTSTRING) + 1,
+                             &weak_key, &INITVALUE, result);
 
   if (size == -1)
     {
@@ -102,7 +102,7 @@
       return 1;
     }
 
-  size = decryptBlock (&weak_key, result, size, &INITVALUE, res);
+  size = GNUNET_AES_decrypt (&weak_key, result, size, &INITVALUE, res);
 
   if ((strlen (WEAK_KEY_TESTSTRING) + 1) != size)
     {
@@ -121,7 +121,7 @@
 static int
 getWeakKeys ()
 {
-  SESSIONKEY sessionkey;
+  GNUNET_AES_SessionKey sessionkey;
   int number_of_weak_keys = 0;
   int number_of_runs;
 
@@ -135,7 +135,7 @@
       if (number_of_runs % 1000 == 0)
         fprintf (stderr, ".");
       /*printf("Got to run number %d.\n", number_of_runs); */
-      makeSessionkey (&sessionkey);
+      GNUNET_AES_create_session_key (&sessionkey);
 
       rc = gcry_cipher_open (&handle,
                              GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CFB, 0);
@@ -148,7 +148,7 @@
           continue;
         }
 
-      rc = gcry_cipher_setkey (handle, &sessionkey, SESSIONKEY_LEN);
+      rc = gcry_cipher_setkey (handle, &sessionkey, GNUNET_SESSIONKEY_LEN);
 
       if ((char) rc == GPG_ERR_WEAK_KEY)
         {

Modified: GNUnet/src/util/disk/storage.c
===================================================================
--- GNUnet/src/util/disk/storage.c      2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/disk/storage.c      2007-11-23 11:51:54 UTC (rev 5742)
@@ -86,7 +86,7 @@
   GE_ASSERT (gfsd->ectx, filename != NULL);
   if ((dirname != NULL) && (strlen (dirname) > 0))
     {
-      fn = MALLOC (strlen (filename) + strlen (dirname) + 3);
+      fn = GNUNET_malloc (strlen (filename) + strlen (dirname) + 3);
       if (strlen (dirname) > 0)
         {
           strcpy (fn, dirname);
@@ -105,51 +105,52 @@
         strcat (fn, filename);
     }
   else
-    fn = STRDUP (filename);
+    fn = GNUNET_strdup (filename);
 
 #ifdef HAVE_STAT64
   if (0 != STAT64 (fn, &buf))
     {
       GE_LOG_STRERROR_FILE (gfsd->ectx,
                             GE_WARNING | GE_USER | GE_REQUEST, "stat64", fn);
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
 #else
   if (0 != STAT (fn, &buf))
     {
       GE_LOG_STRERROR_FILE (gfsd->ectx,
                             GE_WARNING | GE_USER | GE_REQUEST, "stat", fn);
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
 #endif
-  if ((!S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == YES))
+  if ((!S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES))
     gfsd->total += buf.st_size;
   if ((S_ISDIR (buf.st_mode)) &&
       (0 == ACCESS (fn, X_OK)) &&
-      ((!S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == YES)))
+      ((!S_ISLNK (buf.st_mode)) || (gfsd->include_sym_links == GNUNET_YES)))
     {
-      if (SYSERR == disk_directory_scan (gfsd->ectx, fn, &getSizeRec, gfsd))
+      if (GNUNET_SYSERR ==
+          GNUNET_disk_directory_scan (gfsd->ectx, fn, &getSizeRec, gfsd))
         {
-          FREE (fn);
-          return SYSERR;
+          GNUNET_free (fn);
+          return GNUNET_SYSERR;
         }
     }
-  FREE (fn);
-  return OK;
+  GNUNET_free (fn);
+  return GNUNET_OK;
 }
 
 /**
  * Get the size of the file (or directory)
  * of the given file (in bytes).
  *
- * @return SYSERR on error, OK on success
+ * @return GNUNET_SYSERR on error, GNUNET_OK on success
  */
 int
-disk_file_size (struct GE_Context *ectx,
-                const char *filename,
-                unsigned long long *size, int includeSymLinks)
+GNUNET_disk_file_size (struct GE_Context *ectx,
+                       const char *filename,
+                       unsigned long long *size, int includeSymLinks)
 {
   GetFileSizeData gfsd;
   int ret;
@@ -171,7 +172,7 @@
  * @return -1 on errors, otherwise the number of free blocks
  */
 long
-disk_get_blocks_available (struct GE_Context *ectx, const char *part)
+GNUNET_disk_get_blocks_available (struct GE_Context *ectx, const char *part)
 {
 #ifdef SOLARIS
   struct statvfs buf;
@@ -217,11 +218,11 @@
 /**
  * Test if fil is a directory.
  *
- * @return YES if yes, NO if not, SYSERR if it
+ * @return GNUNET_YES if yes, GNUNET_NO if not, GNUNET_SYSERR if it
  *   does not exist
  */
 int
-disk_directory_test (struct GE_Context *ectx, const char *fil)
+GNUNET_disk_directory_test (struct GE_Context *ectx, const char *fil)
 {
   struct stat filestat;
   int ret;
@@ -234,38 +235,38 @@
           GE_LOG_STRERROR_FILE (ectx,
                                 GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST,
                                 "stat", fil);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
-      return NO;
+      return GNUNET_NO;
     }
   if (!S_ISDIR (filestat.st_mode))
-    return NO;
+    return GNUNET_NO;
   if (ACCESS (fil, R_OK | X_OK) < 0)
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST,
                             "access", fil);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return YES;
+  return GNUNET_YES;
 }
 
 /**
  * Check that fil corresponds to a filename
  * (of a file that exists and that is not a directory).
- * @returns YES if yes, NO if not a file, SYSERR if something
+ * @returns GNUNET_YES if yes, GNUNET_NO if not a file, GNUNET_SYSERR if 
something
  * else (will print an error message in that case, too).
  */
 int
-disk_file_test (struct GE_Context *ectx, const char *fil)
+GNUNET_disk_file_test (struct GE_Context *ectx, const char *fil)
 {
   struct stat filestat;
   int ret;
   char *rdir;
 
-  rdir = string_expandFileName (ectx, fil);
+  rdir = GNUNET_expand_file_name (ectx, fil);
   if (rdir == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
 
   ret = STAT (rdir, &filestat);
   if (ret != 0)
@@ -275,45 +276,45 @@
           GE_LOG_STRERROR_FILE (ectx,
                                 GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST,
                                 "stat", rdir);
-          FREE (rdir);
-          return SYSERR;
+          GNUNET_free (rdir);
+          return GNUNET_SYSERR;
         }
-      FREE (rdir);
-      return NO;
+      GNUNET_free (rdir);
+      return GNUNET_NO;
     }
   if (!S_ISREG (filestat.st_mode))
     {
-      FREE (rdir);
-      return NO;
+      GNUNET_free (rdir);
+      return GNUNET_NO;
     }
   if (ACCESS (rdir, R_OK) < 0)
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_WARNING | GE_USER | GE_ADMIN | GE_REQUEST,
                             "access", rdir);
-      FREE (rdir);
-      return SYSERR;
+      GNUNET_free (rdir);
+      return GNUNET_SYSERR;
     }
-  FREE (rdir);
-  return YES;
+  GNUNET_free (rdir);
+  return GNUNET_YES;
 }
 
 /**
  * Implementation of "mkdir -p"
  * @param dir the directory to create
- * @returns OK on success, SYSERR on failure
+ * @returns GNUNET_OK on success, GNUNET_SYSERR on failure
  */
 int
-disk_directory_create (struct GE_Context *ectx, const char *dir)
+GNUNET_disk_directory_create (struct GE_Context *ectx, const char *dir)
 {
   char *rdir;
   int len;
   int pos;
-  int ret = OK;
+  int ret = GNUNET_OK;
 
-  rdir = string_expandFileName (ectx, dir);
+  rdir = GNUNET_expand_file_name (ectx, dir);
   if (rdir == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
 
   len = strlen (rdir);
 #ifndef MINGW
@@ -343,13 +344,13 @@
       if ((rdir[pos] == DIR_SEPARATOR) || (pos == len))
         {
           rdir[pos] = '\0';
-          ret = disk_directory_test (ectx, rdir);
-          if (ret == SYSERR)
+          ret = GNUNET_disk_directory_test (ectx, rdir);
+          if (ret == GNUNET_SYSERR)
             {
-              FREE (rdir);
-              return SYSERR;
+              GNUNET_free (rdir);
+              return GNUNET_SYSERR;
             }
-          if (ret == NO)
+          if (ret == GNUNET_NO)
             {
 #ifndef MINGW
               ret = mkdir (rdir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | 
S_IXGRP | S_IROTH | S_IXOTH);  /* 755 */
@@ -361,16 +362,16 @@
                   GE_LOG_STRERROR_FILE (ectx,
                                         GE_ERROR | GE_USER | GE_BULK,
                                         "mkdir", rdir);
-                  FREE (rdir);
-                  return SYSERR;
+                  GNUNET_free (rdir);
+                  return GNUNET_SYSERR;
                 }
             }
           rdir[pos] = DIR_SEPARATOR;
         }
       pos++;
     }
-  FREE (rdir);
-  return OK;
+  GNUNET_free (rdir);
+  return GNUNET_OK;
 }
 
 
@@ -379,24 +380,25 @@
  * a file.
  *
  * @param filename name of a file in the directory
- * @returns OK on success, SYSERR on failure
+ * @returns GNUNET_OK on success, GNUNET_SYSERR on failure
  */
 int
-disk_directory_create_for_file (struct GE_Context *ectx, const char *dir)
+GNUNET_disk_directory_create_for_file (struct GE_Context *ectx,
+                                       const char *dir)
 {
   char *rdir;
   int len;
   int ret;
 
-  rdir = string_expandFileName (ectx, dir);
+  rdir = GNUNET_expand_file_name (ectx, dir);
   if (rdir == NULL)
-    return SYSERR;
+    return GNUNET_SYSERR;
   len = strlen (rdir);
   while ((len > 0) && (rdir[len] != DIR_SEPARATOR))
     len--;
   rdir[len] = '\0';
-  ret = disk_directory_create (ectx, rdir);
-  FREE (rdir);
+  ret = GNUNET_disk_directory_create (ectx, rdir);
+  GNUNET_free (rdir);
   return ret;
 }
 
@@ -409,8 +411,8 @@
  * @return the number of bytes read on success, -1 on failure
  */
 int
-disk_file_read (struct GE_Context *ectx,
-                const char *fileName, int len, void *result)
+GNUNET_disk_file_read (struct GE_Context *ectx,
+                       const char *fileName, int len, void *result)
 {
   /* open file, must exist, open read only */
   int handle;
@@ -421,11 +423,11 @@
   if (len == 0)
     return 0;
   GE_ASSERT (ectx, result != NULL);
-  handle = disk_file_open (ectx, fileName, O_RDONLY, S_IRUSR);
+  handle = GNUNET_disk_file_open (ectx, fileName, O_RDONLY, S_IRUSR);
   if (handle < 0)
     return -1;
   size = READ (handle, result, len);
-  disk_file_close (ectx, fileName, handle);
+  GNUNET_disk_file_close (ectx, fileName, handle);
   return size;
 }
 
@@ -452,12 +454,12 @@
  * @param buffer the data to write
  * @param n number of bytes to write
  * @param mode permissions to set on the file
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-disk_file_write (struct GE_Context *ectx,
-                 const char *fileName,
-                 const void *buffer, unsigned int n, const char *mode)
+GNUNET_disk_file_write (struct GE_Context *ectx,
+                        const char *fileName,
+                        const void *buffer, unsigned int n, const char *mode)
 {
   int handle;
   char *fn;
@@ -465,12 +467,13 @@
   /* open file, open with 600, create if not
      present, otherwise overwrite */
   GE_ASSERT (ectx, fileName != NULL);
-  fn = string_expandFileName (ectx, fileName);
-  handle = disk_file_open (ectx, fn, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
+  fn = GNUNET_expand_file_name (ectx, fileName);
+  handle =
+    GNUNET_disk_file_open (ectx, fn, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR);
   if (handle == -1)
     {
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
   GE_ASSERT (ectx, (n == 0) || (buffer != NULL));
   /* write the buffer take length from the beginning */
@@ -478,18 +481,18 @@
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_WARNING | GE_USER | GE_IMMEDIATE, "write", fn);
-      disk_file_close (ectx, fn, handle);
-      FREE (fn);
-      return SYSERR;
+      GNUNET_disk_file_close (ectx, fn, handle);
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
-  disk_file_close (ectx, fn, handle);
+  GNUNET_disk_file_close (ectx, fn, handle);
   if (0 != CHMOD (fn, atoo (mode)))
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_WARNING | GE_USER | GE_BULK, "chmod", fn);
     }
-  FREE (fn);
-  return OK;
+  GNUNET_free (fn);
+  return GNUNET_OK;
 }
 
 /**
@@ -499,13 +502,14 @@
  * @param callback the method to call for each file,
  *        can be NULL, in that case, we only count
  * @param data argument to pass to callback
- * @return the number of files found, SYSERR on error or
- *         ieration aborted by callback returning SYSERR
+ * @return the number of files found, GNUNET_SYSERR on error or
+ *         ieration aborted by callback returning GNUNET_SYSERR
  */
 int
-disk_directory_scan (struct GE_Context *ectx,
-                     const char *dirName,
-                     DirectoryEntryCallback callback, void *data)
+GNUNET_disk_directory_scan (struct GE_Context *ectx,
+                            const char *dirName,
+                            GNUNET_DirectoryEntryCallback callback,
+                            void *data)
 {
   DIR *dinfo;
   struct dirent *finfo;
@@ -517,14 +521,14 @@
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_WARNING | GE_USER | GE_BULK, "stat", dirName);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (!S_ISDIR (istat.st_mode))
     {
       GE_LOG (ectx,
               GE_WARNING | GE_USER | GE_BULK,
               _("Expected `%s' to be a directory!\n"), dirName);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   errno = 0;
   dinfo = OPENDIR (dirName);
@@ -533,7 +537,7 @@
       GE_LOG_STRERROR_FILE (ectx,
                             GE_WARNING | GE_USER | GE_BULK,
                             "opendir", dirName);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   while ((finfo = readdir (dinfo)) != NULL)
     {
@@ -542,10 +546,10 @@
         continue;
       if (callback != NULL)
         {
-          if (OK != callback (finfo->d_name, dirName, data))
+          if (GNUNET_OK != callback (finfo->d_name, dirName, data))
             {
               closedir (dinfo);
-              return SYSERR;
+              return GNUNET_SYSERR;
             }
         }
       count++;
@@ -555,7 +559,7 @@
 }
 
 /**
- * Callback for disk_directory_remove
+ * Callback for GNUNET_disk_directory_remove
  */
 static int
 rmHelper (const char *fil, const char *dir, void *ctx)
@@ -565,15 +569,15 @@
   size_t n;
 
   n = strlen (dir) + strlen (fil) + 2;
-  fn = MALLOC (n);
-  SNPRINTF (fn, n, "%s/%s", dir, fil);
-  if (SYSERR == disk_directory_remove (ectx, fn))
+  fn = GNUNET_malloc (n);
+  GNUNET_snprintf (fn, n, "%s/%s", dir, fil);
+  if (GNUNET_SYSERR == GNUNET_disk_directory_remove (ectx, fn))
     {
-      FREE (fn);
-      return SYSERR;
+      GNUNET_free (fn);
+      return GNUNET_SYSERR;
     }
-  FREE (fn);
-  return OK;
+  GNUNET_free (fn);
+  return GNUNET_OK;
 }
 
 /**
@@ -582,42 +586,43 @@
  *
  *
  * @param fileName the file to remove
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-disk_directory_remove (struct GE_Context *ectx, const char *fileName)
+GNUNET_disk_directory_remove (struct GE_Context *ectx, const char *fileName)
 {
   struct stat istat;
 
   if (0 != STAT (fileName, &istat))
-    return NO;                  /* file may not exist... */
+    return GNUNET_NO;           /* file may not exist... */
   if (UNLINK (fileName) == 0)
-    return OK;
+    return GNUNET_OK;
   if ((errno != EISDIR) &&
       /* EISDIR is not sufficient in all cases, e.g.
          sticky /tmp directory may result in EPERM on BSD.
          So we also explicitly check "isDirectory" */
-      (YES != disk_directory_test (ectx, fileName)))
+      (GNUNET_YES != GNUNET_disk_directory_test (ectx, fileName)))
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
                             "rmdir", fileName);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  if (SYSERR == disk_directory_scan (ectx, fileName, &rmHelper, ectx))
-    return SYSERR;
+  if (GNUNET_SYSERR ==
+      GNUNET_disk_directory_scan (ectx, fileName, &rmHelper, ectx))
+    return GNUNET_SYSERR;
   if (0 != RMDIR (fileName))
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_WARNING | GE_USER | GE_ADMIN | GE_BULK,
                             "rmdir", fileName);
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 void
-disk_file_close (struct GE_Context *ectx, const char *filename, int fd)
+GNUNET_disk_file_close (struct GE_Context *ectx, const char *filename, int fd)
 {
   if (0 != CLOSE (fd))
     GE_LOG_STRERROR_FILE (ectx,
@@ -625,7 +630,8 @@
 }
 
 int
-disk_file_open (struct GE_Context *ectx, const char *filename, int oflag, ...)
+GNUNET_disk_file_open (struct GE_Context *ectx, const char *filename,
+                       int oflag, ...)
 {
   char *fn;
   int mode;
@@ -643,9 +649,9 @@
                             GE_BULK, "plibc_conv_to_win_path", filename);
       return -1;
     }
-  fn = STRDUP (szFile);
+  fn = GNUNET_strdup (szFile);
 #else
-  fn = string_expandFileName (ectx, filename);
+  fn = GNUNET_expand_file_name (ectx, filename);
 #endif
   if (oflag & O_CREAT)
     {
@@ -665,7 +671,7 @@
   ret = OPEN (fn, oflag, mode);
   if (ret == -1)
     GE_LOG_STRERROR_FILE (ectx, GE_WARNING | GE_USER | GE_BULK, "open", fn);
-  FREE (fn);
+  GNUNET_free (fn);
   return ret;
 }
 
@@ -673,10 +679,11 @@
 
 /**
  * Copy a file.
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-disk_file_copy (struct GE_Context *ectx, const char *src, const char *dst)
+GNUNET_disk_file_copy (struct GE_Context *ectx, const char *src,
+                       const char *dst)
 {
   char *buf;
   unsigned long long pos;
@@ -685,22 +692,22 @@
   int in;
   int out;
 
-  if (OK != disk_file_size (ectx, src, &size, YES))
-    return SYSERR;
+  if (GNUNET_OK != GNUNET_disk_file_size (ectx, src, &size, GNUNET_YES))
+    return GNUNET_SYSERR;
   pos = 0;
-  in = disk_file_open (ectx, src, O_RDONLY | O_LARGEFILE);
+  in = GNUNET_disk_file_open (ectx, src, O_RDONLY | O_LARGEFILE);
   if (in == -1)
-    return SYSERR;
-  out = disk_file_open (ectx,
-                        dst,
-                        O_LARGEFILE | O_WRONLY | O_CREAT | O_EXCL,
-                        S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+    return GNUNET_SYSERR;
+  out = GNUNET_disk_file_open (ectx,
+                               dst,
+                               O_LARGEFILE | O_WRONLY | O_CREAT | O_EXCL,
+                               S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
   if (out == -1)
     {
-      disk_file_close (ectx, src, in);
-      return SYSERR;
+      GNUNET_disk_file_close (ectx, src, in);
+      return GNUNET_SYSERR;
     }
-  buf = MALLOC (COPY_BLK_SIZE);
+  buf = GNUNET_malloc (COPY_BLK_SIZE);
   while (pos < size)
     {
       len = COPY_BLK_SIZE;
@@ -712,15 +719,15 @@
         goto FAIL;
       pos += len;
     }
-  FREE (buf);
-  disk_file_close (ectx, src, in);
-  disk_file_close (ectx, dst, out);
-  return OK;
+  GNUNET_free (buf);
+  GNUNET_disk_file_close (ectx, src, in);
+  GNUNET_disk_file_close (ectx, dst, out);
+  return GNUNET_OK;
 FAIL:
-  FREE (buf);
-  disk_file_close (ectx, src, in);
-  disk_file_close (ectx, dst, out);
-  return SYSERR;
+  GNUNET_free (buf);
+  GNUNET_disk_file_close (ectx, src, in);
+  GNUNET_disk_file_close (ectx, dst, out);
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -728,7 +735,7 @@
  * @param fn the filename to canonicalize
  */
 void
-disk_filename_canonicalize (char *fn)
+GNUNET_disk_filename_canonicalize (char *fn)
 {
   char *idx;
   char c;

Modified: GNUnet/src/util/disk/storagetest.c
===================================================================
--- GNUnet/src/util/disk/storagetest.c  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/disk/storagetest.c  2007-11-23 11:51:54 UTC (rev 5742)
@@ -34,8 +34,9 @@
 {
   char tmp[100];
 
-  disk_file_write (NULL, ".testfile", TESTSTRING, strlen (TESTSTRING), "644");
-  tmp[disk_file_read (NULL, ".testfile", 100, tmp)] = '\0';
+  GNUNET_disk_file_write (NULL, ".testfile", TESTSTRING, strlen (TESTSTRING),
+                          "644");
+  tmp[GNUNET_disk_file_read (NULL, ".testfile", 100, tmp)] = '\0';
   if (0 != memcmp (tmp, TESTSTRING, strlen (TESTSTRING) + 1))
     {
       fprintf (stderr,

Modified: GNUnet/src/util/error/error.c
===================================================================
--- GNUnet/src/util/error/error.c       2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/error/error.c       2007-11-23 11:51:54 UTC (rev 5742)
@@ -172,7 +172,7 @@
 GE_isLogged (GE_Context * ctx, GE_KIND kind)
 {
   if (ctx == NULL)
-    return YES;
+    return GNUNET_YES;
   return GE_applies (kind, ctx->mask);
 }
 

Modified: GNUnet/src/util/getopt/getopt.c
===================================================================
--- GNUnet/src/util/getopt/getopt.c     2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/getopt/getopt.c     2007-11-23 11:51:54 UTC (rev 5742)
@@ -175,7 +175,7 @@
    variable POSIXLY_CORRECT, or using `+' as the first character
    of the list of option characters.
 
-   PERMUTE is the default.  We permute the contents of ARGV as we scan,
+   PERMUTE is the default.  We GNUNET_permute the contents of ARGV as we scan,
    so that eventually all the non-options are at the end.  This allows options
    to be given in any order, even with programs that were not written to
    expect this.
@@ -499,7 +499,7 @@
    `flag' field is nonzero, the value of the option's `val' field
    if the `flag' field is zero.
 
-   The elements of ARGV aren't really const, because we permute them.
+   The elements of ARGV aren't really const, because we GNUNET_permute them.
    But we pretend they're const in the prototype to be compatible
    with other systems.
 
@@ -603,7 +603,7 @@
           return -1;
         }
 
-      /* If we have come to a non-option and did not permute it,
+      /* If we have come to a non-option and did not GNUNET_permute it,
          either stop the scan or describe it to the caller and pass it by.  */
 
       if (NONOPTION_P)
@@ -999,14 +999,14 @@
  *   argument, or -1 on error
  */
 int
-gnunet_parse_options (const char *binaryOptions,
+GNUNET_parse_options (const char *binaryOptions,
                       struct GE_Context *ectx,
                       struct GC_Configuration *cfg,
-                      const CommandLineOption * allOptions,
+                      const GNUNET_CommandLineOption * allOptions,
                       unsigned int argc, char *const *argv)
 {
   struct GNoption *long_options;
-  CommandLineProcessorContext clpc;
+  GNUNET_CommandLineProcessorContext clpc;
   int count;
   int i;
   char *shorts;
@@ -1025,8 +1025,8 @@
   count = 0;
   while (allOptions[count].name != NULL)
     count++;
-  long_options = MALLOC (sizeof (struct GNoption) * (count + 1));
-  shorts = MALLOC (count * 2 + 1);
+  long_options = GNUNET_malloc (sizeof (struct GNoption) * (count + 1));
+  shorts = GNUNET_malloc (count * 2 + 1);
   spos = 0;
   for (i = 0; i < count; i++)
     {
@@ -1043,14 +1043,14 @@
   long_options[count].flag = NULL;
   long_options[count].val = '\0';
   shorts[spos++] = '\0';
-  cont = OK;
+  cont = GNUNET_OK;
   /* main getopt loop */
-  while (cont == OK)
+  while (cont == GNUNET_OK)
     {
       int option_index = 0;
       c = GNgetopt_long (argc, argv, shorts, long_options, &option_index);
 
-      if (c == SYSERR)
+      if (c == GNUNET_SYSERR)
         break;                  /* No more flags to process */
 
       for (i = 0; i < count; i++)
@@ -1069,14 +1069,14 @@
           GE_LOG (ectx,
                   GE_INFO | GE_USER | GE_IMMEDIATE,
                   _("Use --help to get a list of options.\n"));
-          cont = SYSERR;
+          cont = GNUNET_SYSERR;
         }
     }
 
-  FREE (shorts);
-  FREE (long_options);
-  if (cont == SYSERR)
-    return SYSERR;
+  GNUNET_free (shorts);
+  GNUNET_free (long_options);
+  if (cont == GNUNET_SYSERR)
+    return GNUNET_SYSERR;
   return GNoptind;
 }
 

Modified: GNUnet/src/util/getopt/printhelp.c
===================================================================
--- GNUnet/src/util/getopt/printhelp.c  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/getopt/printhelp.c  2007-11-23 11:51:54 UTC (rev 5742)
@@ -31,8 +31,8 @@
 #define BORDER 29
 
 int
-gnunet_getopt_format_help (CommandLineProcessorContext * ctx,
-                           void *scls, const char *option, const char *value)
+GNUNET_getopt_format_help_ (GNUNET_CommandLineProcessorContext * ctx,
+                            void *scls, const char *option, const char *value)
 {
   const char *about = scls;
   int slen;
@@ -42,7 +42,7 @@
   int p;
   char *scp;
   const char *trans;
-  const struct CommandLineOption *opt;
+  const struct GNUNET_CommandLineOption *opt;
 
   printf ("%s\n%s\n", ctx->binaryOptions, gettext (about));
   printf (_
@@ -83,22 +83,22 @@
             {
               if (isspace (trans[j]))
                 {
-                  scp = MALLOC (j - p + 1);
+                  scp = GNUNET_malloc (j - p + 1);
                   memcpy (scp, &trans[p], j - p);
                   scp[j - p] = '\0';
                   printf ("%s\n%*s", scp, BORDER + 2, "");
-                  FREE (scp);
+                  GNUNET_free (scp);
                   p = j + 1;
                   slen = BORDER + 2;
                   goto OUTER;
                 }
             }
           /* could not find space to break line */
-          scp = MALLOC (78 - slen + 1);
+          scp = GNUNET_malloc (78 - slen + 1);
           memcpy (scp, &trans[p], 78 - slen);
           scp[78 - slen] = '\0';
           printf ("%s\n%*s", scp, BORDER + 2, "");
-          FREE (scp);
+          GNUNET_free (scp);
           slen = BORDER + 2;
           p = p + 78 - slen;
         }
@@ -109,7 +109,7 @@
         printf ("\n");
       i++;
     }
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /* end of printhelp.c */

Modified: GNUnet/src/util/getopt/printversion.c
===================================================================
--- GNUnet/src/util/getopt/printversion.c       2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/getopt/printversion.c       2007-11-23 11:51:54 UTC (rev 
5742)
@@ -29,14 +29,14 @@
 #include "platform.h"
 
 int
-gnunet_getopt_print_version (CommandLineProcessorContext * ctx,
-                             void *scls,
-                             const char *option, const char *value)
+GNUNET_getopt_print_version_ (GNUNET_CommandLineProcessorContext * ctx,
+                              void *scls,
+                              const char *option, const char *value)
 {
   const char *version = scls;
 
   printf ("%s v%s\n", ctx->binaryName, version);
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /* end of printversion.c */

Modified: GNUnet/src/util/getopt/setoption.c
===================================================================
--- GNUnet/src/util/getopt/setoption.c  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/getopt/setoption.c  2007-11-23 11:51:54 UTC (rev 5742)
@@ -31,12 +31,12 @@
 
 
 int
-gnunet_getopt_configure_set_option (CommandLineProcessorContext * ctx,
+GNUNET_getopt_configure_set_option (GNUNET_CommandLineProcessorContext * ctx,
                                     void *scls,
                                     const char *cmdLineOption,
                                     const char *value)
 {
-  char *section = STRDUP (scls);
+  char *section = GNUNET_strdup (scls);
   struct GC_Configuration *cfg = ctx->cfg;
   char *option;
   int ret;
@@ -57,20 +57,20 @@
               _
               ("Setting option `%s' in section `%s' to `%s' when processing 
command line option `%s' was denied.\n"),
               option, section, value, cmdLineOption);
-      FREE (section);
-      return SYSERR;
+      GNUNET_free (section);
+      return GNUNET_SYSERR;
     }
-  FREE (section);
-  return OK;
+  GNUNET_free (section);
+  return GNUNET_OK;
 }
 
 int
-gnunet_getopt_configure_increment_value (CommandLineProcessorContext * ctx,
-                                         void *scls,
+GNUNET_getopt_configure_increment_value (GNUNET_CommandLineProcessorContext *
+                                         ctx, void *scls,
                                          const char *cmdLineOption,
                                          const char *value)
 {
-  char *section = STRDUP (scls);
+  char *section = GNUNET_strdup (scls);
   struct GC_Configuration *cfg = ctx->cfg;
   char *option;
   int ret;
@@ -85,46 +85,46 @@
                                            option,
                                            0,
                                            (unsigned long long) -1L, 0, &old);
-  if (ret == SYSERR)
+  if (ret == GNUNET_SYSERR)
     {
-      FREE (section);
-      return SYSERR;
+      GNUNET_free (section);
+      return GNUNET_SYSERR;
     }
   ret = GC_set_configuration_value_number (cfg,
                                            ctx->ectx,
                                            section, option, old + 1);
-  FREE (section);
+  GNUNET_free (section);
   if (ret == 0)
-    ret = OK;
+    ret = GNUNET_OK;
   else
-    ret = SYSERR;
+    ret = GNUNET_SYSERR;
   return ret;
 }
 
 int
-gnunet_getopt_configure_set_one (CommandLineProcessorContext * ctx,
+GNUNET_getopt_configure_set_one (GNUNET_CommandLineProcessorContext * ctx,
                                  void *scls,
                                  const char *option, const char *value)
 {
   int *val = scls;
   *val = 1;
-  return OK;
+  return GNUNET_OK;
 }
 
 int
-gnunet_getopt_configure_set_string (CommandLineProcessorContext * ctx,
+GNUNET_getopt_configure_set_string (GNUNET_CommandLineProcessorContext * ctx,
                                     void *scls,
                                     const char *option, const char *value)
 {
   char **val = scls;
 
   GE_ASSERT (NULL, value != NULL);
-  *val = STRDUP (value);
-  return OK;
+  *val = GNUNET_strdup (value);
+  return GNUNET_OK;
 }
 
 int
-gnunet_getopt_configure_set_ulong (CommandLineProcessorContext * ctx,
+GNUNET_getopt_configure_set_ulong (GNUNET_CommandLineProcessorContext * ctx,
                                    void *scls,
                                    const char *option, const char *value)
 {
@@ -134,13 +134,13 @@
       GE_LOG (ctx->ectx,
               GE_ERROR | GE_IMMEDIATE | GE_USER,
               _("You must pass a number to the `%s' option.\n"), "-X");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 int
-gnunet_getopt_configure_set_uint (CommandLineProcessorContext * ctx,
+GNUNET_getopt_configure_set_uint (GNUNET_CommandLineProcessorContext * ctx,
                                   void *scls,
                                   const char *option, const char *value)
 {
@@ -151,9 +151,9 @@
       GE_LOG (ctx->ectx,
               GE_ERROR | GE_IMMEDIATE | GE_USER,
               _("You must pass a number to the `%s' option.\n"), "-X");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  return OK;
+  return GNUNET_OK;
 }
 
 

Modified: GNUnet/src/util/loggers/Makefile.am
===================================================================
--- GNUnet/src/util/loggers/Makefile.am 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/loggers/Makefile.am 2007-11-23 11:51:54 UTC (rev 5742)
@@ -2,13 +2,11 @@
 
 SUBDIRS = .
 
-lib_LTLIBRARIES = \
-  libgnunetutil_logging.la
+noinst_LTLIBRARIES = \
+  libloggers.la
 
-libgnunetutil_logging_la_SOURCES = \
+libloggers_la_SOURCES = \
   file.c memory.c
 # smtp.c
 
-libgnunetutil_logging_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la 
 

Modified: GNUnet/src/util/loggers/file.c
===================================================================
--- GNUnet/src/util/loggers/file.c      2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/loggers/file.c      2007-11-23 11:51:54 UTC (rev 5742)
@@ -26,6 +26,7 @@
  */
 #define _XOPEN_SOURCE           /* glibc2 needs this */
 #include "gnunet_util_error_loggers.h"
+#include "gnunet_util_os.h"
 #include "gnunet_util_string.h"
 #include "gnunet_util.h"
 #include "platform.h"
@@ -54,13 +55,18 @@
   char *basename;
 
   /**
+   * Who should own the log files?
+   */
+  char *user;
+
+  /**
    * Lock.
    */
-  struct MUTEX *lock;
+  struct GNUNET_Mutex *lock;
 
   /**
    * Should we log the current date with each message?
-   * (0: NO, 1: YES)
+   * (0: GNUNET_NO, 1: GNUNET_YES)
    */
   int logdate;
 
@@ -84,7 +90,7 @@
   /**
    * When did we start the current logfile?
    */
-  TIME_T logstart;
+  GNUNET_Int32Time logstart;
 
 } FileContext;
 
@@ -96,9 +102,9 @@
   char c;
 
 #if ENABLE_NLS
-  datefmt = STRDUP (nl_langinfo (D_FMT));
+  datefmt = GNUNET_strdup (nl_langinfo (D_FMT));
 #else
-  datefmt = STRDUP ("%Y-%m-%d");
+  datefmt = GNUNET_strdup ("%Y-%m-%d");
 #endif
   /* Remove slashes */
   idx = datefmt;
@@ -130,31 +136,31 @@
   time (&curtime);
   lcltime = *localtime (&curtime);
   def = ctx->basename;
-  fullname = MALLOC (strlen (dir) + strlen (fil) + 2);
+  fullname = GNUNET_malloc (strlen (dir) + strlen (fil) + 2);
   strcpy (fullname, dir);
   if (dir[strlen (dir) - 1] != DIR_SEPARATOR)
     strcat (fullname, DIR_SEPARATOR_STR);
   strcat (fullname, fil);
   if (0 != strncmp (def, fullname, strlen (def)))
     {
-      FREE (fullname);
-      return OK;
+      GNUNET_free (fullname);
+      return GNUNET_OK;
     }
   logdate = &fullname[strlen (def) + 1];
   datefmt = getDateFormat ();
   ret = strptime (logdate, datefmt, &t);
-  FREE (datefmt);
+  GNUNET_free (datefmt);
   if ((ret == NULL) || (ret[0] != '\0'))
     {
-      FREE (fullname);
-      return OK;                /* not a logfile */
+      GNUNET_free (fullname);
+      return GNUNET_OK;         /* not a logfile */
     }
   if (ctx->logrotate
       + t.tm_year * 365 + t.tm_yday
       - lcltime.tm_year * 365 - lcltime.tm_yday <= 0)
     UNLINK (fullname);          /* TODO: add ctx->fctx */
-  FREE (fullname);
-  return OK;
+  GNUNET_free (fullname);
+  return GNUNET_OK;
 }
 
 /**
@@ -181,14 +187,14 @@
 #endif
   /* Format current date for filename */
   GE_ASSERT (NULL, 0 != strftime (date, 80, datefmt, &lcltime));
-  FREE (datefmt);
+  GNUNET_free (datefmt);
 
   /* Remove special chars */
-  disk_filename_canonicalize (date);
+  GNUNET_disk_filename_canonicalize (date);
 
   size = strlen (name) + 82;
-  ret = MALLOC (size);
-  SNPRINTF (ret, size, "%s-%s", name, date);
+  ret = GNUNET_malloc (size);
+  GNUNET_snprintf (ret, size, "%s-%s", name, date);
   return ret;
 }
 
@@ -197,12 +203,12 @@
 {
   char *dirname;
 
-  dirname = STRDUP (logfilename);
+  dirname = GNUNET_strdup (logfilename);
   while ((strlen (dirname) > 0) &&
          (dirname[strlen (dirname) - 1] != DIR_SEPARATOR))
     dirname[strlen (dirname) - 1] = '\0';
-  disk_directory_scan (NULL, dirname, &removeOldLog, fctx);
-  FREE (dirname);
+  GNUNET_disk_directory_scan (NULL, dirname, &removeOldLog, fctx);
+  GNUNET_free (dirname);
 
 }
 
@@ -213,13 +219,14 @@
   char *name;
   int ret;
 
-  MUTEX_LOCK (fctx->lock);
+  GNUNET_mutex_lock (fctx->lock);
   if (fctx->logrotate)
     {
       name = getLogFileName (fctx->basename);
-      if ((fctx->first_start == YES) || (0 != strcmp (name, fctx->filename)))
+      if ((fctx->first_start == GNUNET_YES)
+          || (0 != strcmp (name, fctx->filename)))
         {
-          fctx->first_start = NO;
+          fctx->first_start = GNUNET_NO;
           fclose (fctx->handle);
           fctx->handle = FOPEN (name, "a+");
           if (fctx->handle == NULL)
@@ -229,13 +236,15 @@
                        _("Failed to open log-file `%s': %s\n"),
                        name, STRERROR (errno));
             }
-          FREE (fctx->filename);
+          GNUNET_free (fctx->filename);
           fctx->filename = name;
           purge_old_logs (fctx, name);
+          if (fctx->user != NULL)
+            GNUNET_file_change_owner (NULL, name, fctx->user);
         }
       else
         {
-          FREE (name);
+          GNUNET_free (name);
         }
     }
 
@@ -265,7 +274,7 @@
              _("`%s' failed at %s:%d in %s with error: %s\n"),
              "fclose", __FILE__, __LINE__, __FUNCTION__, STRERROR (errno));
   fflush (fctx->handle);
-  MUTEX_UNLOCK (fctx->lock);
+  GNUNET_mutex_unlock (fctx->lock);
 }
 
 static void
@@ -273,15 +282,16 @@
 {
   FileContext *fctx = cls;
 
-  MUTEX_DESTROY (fctx->lock);
-  FREENONNULL (fctx->filename);
-  FREENONNULL (fctx->basename);
+  GNUNET_mutex_destroy (fctx->lock);
+  GNUNET_free_non_null (fctx->filename);
+  GNUNET_free_non_null (fctx->basename);
+  GNUNET_free_non_null (fctx->user);
   if ((fctx->handle != stderr) &&
       (fctx->handle != stdout) && (0 != fclose (fctx->handle)))
     fprintf (stderr,
              _("`%s' failed at %s:%d in %s with error: %s\n"),
              "fclose", __FILE__, __LINE__, __FUNCTION__, STRERROR (errno));
-  FREE (fctx);
+  GNUNET_free (fctx);
 }
 
 /**
@@ -289,6 +299,7 @@
  *
  * @param mask which events should be logged?
  * @param filename which file should we log to?
+ * @param owner who should own the log file (username)?
  * @param logDate should the context log event dates?
  * @param logrotate after how many days should rotated log
  *        files be deleted (use 0 for no rotation)
@@ -296,21 +307,22 @@
 struct GE_Context *
 GE_create_context_logfile (struct GE_Context *ectx,
                            GE_KIND mask,
-                           const char *filename, int logDate, int logrotate)
+                           const char *filename,
+                           const char *owner, int logDate, int logrotate)
 {
   FileContext *fctx;
   FILE *fd;
   char *name;
-  TIME_T start;
+  GNUNET_Int32Time start;
 
-  TIME (&start);
+  GNUNET_get_time_int32 (&start);
   if (logrotate != 0)
     {
       name = getLogFileName (filename);
     }
   else
     {
-      name = STRDUP (filename);
+      name = GNUNET_strdup (filename);
     }
   fd = FOPEN (name, "a+");
   if (fd == NULL)
@@ -318,18 +330,19 @@
       GE_LOG_STRERROR_FILE (ectx,
                             GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE |
                             GE_BULK, "fopen", name);
-      FREE (name);
+      GNUNET_free (name);
       return NULL;              /* ERROR! */
     }
-  fctx = MALLOC (sizeof (FileContext));
-  fctx->first_start = YES;
+  fctx = GNUNET_malloc (sizeof (FileContext));
+  fctx->first_start = GNUNET_YES;
   fctx->logdate = logDate;
   fctx->logrotate = logrotate;
   fctx->handle = fd;
   fctx->filename = name;
-  fctx->basename = STRDUP (filename);
+  fctx->basename = GNUNET_strdup (filename);
+  fctx->user = owner != NULL ? GNUNET_strdup (owner) : NULL;
   fctx->logstart = start;
-  fctx->lock = MUTEX_CREATE (YES);
+  fctx->lock = GNUNET_mutex_create (GNUNET_YES);
   purge_old_logs (fctx, name);
   return GE_create_context_callback (mask,
                                      &filelogger, fctx, &fileclose, NULL);
@@ -346,15 +359,16 @@
 {
   FileContext *fctx;
 
-  fctx = MALLOC (sizeof (FileContext));
+  fctx = GNUNET_malloc (sizeof (FileContext));
   fctx->logdate = logDate;
   fctx->logrotate = 0;
   fctx->handle = stderr;
   fctx->filename = NULL;
   fctx->basename = NULL;
+  fctx->user = NULL;
   fctx->logstart = 0;
-  fctx->first_start = NO;
-  fctx->lock = MUTEX_CREATE (YES);
+  fctx->first_start = GNUNET_NO;
+  fctx->lock = GNUNET_mutex_create (GNUNET_YES);
   return GE_create_context_callback (mask,
                                      &filelogger, fctx, &fileclose, NULL);
 
@@ -370,15 +384,16 @@
 {
   FileContext *fctx;
 
-  fctx = MALLOC (sizeof (FileContext));
+  fctx = GNUNET_malloc (sizeof (FileContext));
   fctx->logdate = logDate;
   fctx->logrotate = 0;
-  fctx->first_start = NO;
+  fctx->first_start = GNUNET_NO;
   fctx->handle = stdout;
   fctx->filename = NULL;
   fctx->basename = NULL;
+  fctx->user = NULL;
   fctx->logstart = 0;
-  fctx->lock = MUTEX_CREATE (YES);
+  fctx->lock = GNUNET_mutex_create (GNUNET_YES);
   return GE_create_context_callback (mask,
                                      &filelogger, fctx, &fileclose, NULL);
 

Modified: GNUnet/src/util/loggers/memory.c
===================================================================
--- GNUnet/src/util/loggers/memory.c    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/loggers/memory.c    2007-11-23 11:51:54 UTC (rev 5742)
@@ -39,7 +39,7 @@
 typedef struct GE_Memory
 {
   GE_Message *messages;
-  struct MUTEX *lock;
+  struct GNUNET_Mutex *lock;
   unsigned int maxSize;
   unsigned int size;
   unsigned int pos;
@@ -51,32 +51,33 @@
   GE_Memory *ctx = cls;
   unsigned int max;
 
-  MUTEX_LOCK (ctx->lock);
+  GNUNET_mutex_lock (ctx->lock);
   if (ctx->pos == ctx->size)
     {
       if ((ctx->maxSize != 0) && (ctx->size == ctx->maxSize))
         {
-          MUTEX_UNLOCK (ctx->lock);
+          GNUNET_mutex_unlock (ctx->lock);
           return;
         }
       max = ctx->pos * 2 + 16;
       if ((ctx->maxSize == 0) && (max > ctx->maxSize))
         max = ctx->maxSize;
-      GROW (ctx->messages, ctx->size, max);
+      GNUNET_array_grow (ctx->messages, ctx->size, max);
     }
-  ctx->messages[ctx->pos].date = STRDUP (date);
+  ctx->messages[ctx->pos].date = GNUNET_strdup (date);
   if (ctx->pos == ctx->maxSize - 1)
     {
-      ctx->messages[ctx->pos].msg = STRDUP (_("Out of memory (for logging)"));
+      ctx->messages[ctx->pos].msg =
+        GNUNET_strdup (_("Out of memory (for logging)"));
       ctx->messages[ctx->pos].mask = GE_STATUS | GE_USER | GE_BULK;
     }
   else
     {
-      ctx->messages[ctx->pos].msg = STRDUP (msg);
+      ctx->messages[ctx->pos].msg = GNUNET_strdup (msg);
       ctx->messages[ctx->pos].mask = kind;
     }
   ctx->pos++;
-  MUTEX_UNLOCK (ctx->lock);
+  GNUNET_mutex_unlock (ctx->lock);
 }
 
 /**
@@ -105,12 +106,12 @@
 {
   GE_Memory *ret;
 
-  ret = MALLOC (sizeof (GE_Memory));
+  ret = GNUNET_malloc (sizeof (GE_Memory));
   ret->maxSize = maxSize;
   ret->size = 0;
   ret->pos = 0;
   ret->messages = NULL;
-  ret->lock = MUTEX_CREATE (NO);
+  ret->lock = GNUNET_mutex_create (GNUNET_NO);
   return ret;
 }
 
@@ -134,17 +135,17 @@
 {
   int i;
 
-  MUTEX_LOCK (memory->lock);
+  GNUNET_mutex_lock (memory->lock);
   for (i = 0; i < memory->pos; i++)
     {
       handler (ctx,
                memory->messages[i].mask,
                memory->messages[i].date, memory->messages[i].msg);
-      FREE (memory->messages[i].date);
-      FREE (memory->messages[i].msg);
+      GNUNET_free (memory->messages[i].date);
+      GNUNET_free (memory->messages[i].msg);
     }
   memory->pos = 0;
-  MUTEX_UNLOCK (memory->lock);
+  GNUNET_mutex_unlock (memory->lock);
 }
 
 void
@@ -152,14 +153,14 @@
 {
   int i;
 
-  MUTEX_LOCK (memory->lock);
+  GNUNET_mutex_lock (memory->lock);
   for (i = memory->pos - 1; i >= 0; i--)
     {
-      FREE (memory->messages[i].date);
-      FREE (memory->messages[i].msg);
+      GNUNET_free (memory->messages[i].date);
+      GNUNET_free (memory->messages[i].msg);
     }
-  GROW (memory->messages, memory->size, 0);
-  MUTEX_UNLOCK (memory->lock);
+  GNUNET_array_grow (memory->messages, memory->size, 0);
+  GNUNET_mutex_unlock (memory->lock);
 }
 
 void
@@ -167,12 +168,12 @@
 {
   int i;
 
-  MUTEX_DESTROY (memory->lock);
+  GNUNET_mutex_destroy (memory->lock);
   for (i = memory->pos - 1; i >= 0; i--)
     {
-      FREE (memory->messages[i].date);
-      FREE (memory->messages[i].msg);
+      GNUNET_free (memory->messages[i].date);
+      GNUNET_free (memory->messages[i].msg);
     }
-  GROW (memory->messages, memory->size, 0);
-  FREE (memory);
+  GNUNET_array_grow (memory->messages, memory->size, 0);
+  GNUNET_free (memory);
 }

Modified: GNUnet/src/util/network/dns.c
===================================================================
--- GNUnet/src/util/network/dns.c       2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/network/dns.c       2007-11-23 11:51:54 UTC (rev 5742)
@@ -39,8 +39,8 @@
   struct IPCache *next;
   char *addr;
   struct sockaddr *sa;
-  cron_t last_refresh;
-  cron_t last_request;
+  GNUNET_CronTime last_refresh;
+  GNUNET_CronTime last_request;
   unsigned int salen;
 #if HAVE_ADNS
   int posted;
@@ -50,7 +50,7 @@
 
 static struct IPCache *head;
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 #if HAVE_ADNS
 static int a_init;
@@ -72,7 +72,7 @@
       a_init = 1;
       adns_init (&a_state, adns_if_noerrprint, NULL);
     }
-  if (cache->posted == NO)
+  if (cache->posted == GNUNET_NO)
     {
       ret = adns_submit_reverse (a_state, cache->sa, adns_r_ptr,
 #ifdef adns_qf_none
@@ -82,7 +82,7 @@
 #endif
                                  cache, &cache->query);
       if (adns_s_ok == ret)
-        cache->posted = YES;
+        cache->posted = GNUNET_YES;
     }
   adns_processany (a_state);
   answer = NULL;
@@ -92,17 +92,17 @@
       if (answer != NULL)
         {
           if ((answer->rrs.str != NULL) && (*(answer->rrs.str) != NULL))
-            cache->addr = STRDUP (*(answer->rrs.str));
+            cache->addr = GNUNET_strdup (*(answer->rrs.str));
           free (answer);
         }
-      cache->posted = NO;
+      cache->posted = GNUNET_NO;
     }
 #else
 #if HAVE_GETNAMEINFO
   char hostname[256];
 
   if (0 == getnameinfo (cache->sa, cache->salen, hostname, 255, NULL, 0, 0))
-    cache->addr = STRDUP (hostname);
+    cache->addr = GNUNET_strdup (hostname);
 #else
 #if HAVE_GETHOSTBYADDR
   struct hostent *ent;
@@ -111,7 +111,7 @@
     {
     case AF_INET:
       ent = gethostbyaddr (&((struct sockaddr_in *) cache->sa)->sin_addr,
-                           sizeof (IPaddr), AF_INET);
+                           sizeof (GNUNET_IPv4Address), AF_INET);
       break;
     case AF_INET6:
       ent = gethostbyaddr (&((struct sockaddr_in6 *) cache->sa)->sin6_addr,
@@ -121,7 +121,7 @@
       ent = NULL;
     }
   if (ent != NULL)
-    cache->addr = STRDUP (ent->h_name);
+    cache->addr = GNUNET_strdup (ent->h_name);
 #endif
 #endif
 #endif
@@ -132,16 +132,16 @@
 {
   struct IPCache *ret;
 
-  ret = MALLOC (sizeof (struct IPCache));
+  ret = GNUNET_malloc (sizeof (struct IPCache));
 #if HAVE_ADNS
-  ret->posted = NO;
+  ret->posted = GNUNET_NO;
 #endif
   ret->next = head;
   ret->salen = salen;
-  ret->sa = salen == 0 ? NULL : MALLOC (salen);
+  ret->sa = salen == 0 ? NULL : GNUNET_malloc (salen);
   memcpy (ret->sa, sa, salen);
-  ret->last_request = get_time ();
-  ret->last_refresh = get_time ();
+  ret->last_request = GNUNET_get_time ();
+  ret->last_refresh = GNUNET_get_time ();
   ret->addr = NULL;
   cache_resolve (ret);
   head = ret;
@@ -161,12 +161,13 @@
     case AF_INET:
       if (salen != sizeof (struct sockaddr_in))
         return NULL;
-      ret = STRDUP ("255.255.255.255");
-      SNPRINTF (ret,
-                strlen ("255.255.255.255") + 1,
-                "%u.%u.%u.%u",
-                PRIP (ntohl
-                      (*(int *) &((struct sockaddr_in *) sa)->sin_addr)));
+      ret = GNUNET_strdup ("255.255.255.255");
+      GNUNET_snprintf (ret,
+                       strlen ("255.255.255.255") + 1,
+                       "%u.%u.%u.%u",
+                       GNUNET_PRIP (ntohl
+                                    (*(int *) &((struct sockaddr_in *) sa)->
+                                     sin_addr)));
       break;
     case AF_INET6:
       if (salen != sizeof (struct sockaddr_in6))
@@ -174,7 +175,7 @@
       inet_ntop (AF_INET6,
                  &((struct sockaddr_in6 *) sa)->sin6_addr,
                  inet6, INET6_ADDRSTRLEN);
-      ret = STRDUP (inet6);
+      ret = GNUNET_strdup (inet6);
       break;
     default:
       ret = NULL;
@@ -192,46 +193,46 @@
  * @param sa should be of type "struct sockaddr*"
  */
 char *
-network_get_ip_as_string (const void *sav, unsigned int salen, int do_resolve)
+GNUNET_get_ip_as_string (const void *sav, unsigned int salen, int do_resolve)
 {
   const struct sockaddr *sa = sav;
   char *ret;
   struct IPCache *cache;
   struct IPCache *prev;
-  cron_t now;
+  GNUNET_CronTime now;
 
   if (salen < sizeof (struct sockaddr))
     return NULL;
-  now = get_time ();
-  MUTEX_LOCK (lock);
+  now = GNUNET_get_time ();
+  GNUNET_mutex_lock (lock);
   cache = head;
   prev = NULL;
   while ((cache != NULL) &&
          ((cache->salen != salen) || (0 != memcmp (cache->sa, sa, salen))))
     {
-      if (cache->last_request + 60 * cronMINUTES < now)
+      if (cache->last_request + 60 * GNUNET_CRON_MINUTES < now)
         {
 #if HAVE_ADNS
-          if (cache->posted == YES)
+          if (cache->posted == GNUNET_YES)
             {
               adns_cancel (cache->query);
-              cache->posted = NO;
+              cache->posted = GNUNET_NO;
             }
 #endif
           if (prev != NULL)
             {
               prev->next = cache->next;
-              FREENONNULL (cache->addr);
-              FREE (cache->sa);
-              FREE (cache);
+              GNUNET_free_non_null (cache->addr);
+              GNUNET_free (cache->sa);
+              GNUNET_free (cache);
               cache = prev->next;
             }
           else
             {
               head = cache->next;
-              FREENONNULL (cache->addr);
-              FREE (cache->sa);
-              FREE (cache);
+              GNUNET_free_non_null (cache->addr);
+              GNUNET_free (cache->sa);
+              GNUNET_free (cache);
               cache = head;
             }
           continue;
@@ -242,31 +243,31 @@
   if (cache != NULL)
     {
       cache->last_request = now;
-      if (cache->last_refresh + 12 * cronHOURS < now)
+      if (cache->last_refresh + 12 * GNUNET_CRON_HOURS < now)
         {
-          FREENONNULL (cache->addr);
+          GNUNET_free_non_null (cache->addr);
           cache->addr = NULL;
           cache->salen = 0;
           cache_resolve (cache);
         }
 #if HAVE_ADNS
-      if (cache->posted == YES)
+      if (cache->posted == GNUNET_YES)
         {
           cache_resolve (cache);
         }
 #endif
     }
-  else if (do_resolve == NO)
+  else if (do_resolve == GNUNET_NO)
     {
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       return no_resolve (sav, salen);
     }
   else
     cache = resolve (sa, salen);
-  ret = (cache->addr == NULL) ? NULL : STRDUP (cache->addr);
+  ret = (cache->addr == NULL) ? NULL : GNUNET_strdup (cache->addr);
   if (ret == NULL)
     ret = no_resolve (sa, salen);
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   return ret;
 }
 
@@ -275,26 +276,26 @@
 
 void __attribute__ ((constructor)) gnunet_dns_ltdl_init ()
 {
-  lock = MUTEX_CREATE (YES);
+  lock = GNUNET_mutex_create (GNUNET_YES);
 }
 
 void __attribute__ ((destructor)) gnunet_dns_ltdl_fini ()
 {
   struct IPCache *pos;
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   while (head != NULL)
     {
       pos = head->next;
 #if HAVE_ADNS
-      if (head->posted == YES)
+      if (head->posted == GNUNET_YES)
         {
           adns_cancel (head->query);
-          head->posted = NO;
+          head->posted = GNUNET_NO;
         }
 #endif
-      FREENONNULL (head->addr);
-      FREE (head->sa);
-      FREE (head);
+      GNUNET_free_non_null (head->addr);
+      GNUNET_free (head->sa);
+      GNUNET_free (head);
       head = pos;
     }
 #if HAVE_ADNS

Modified: GNUnet/src/util/network/endian.c
===================================================================
--- GNUnet/src/util/network/endian.c    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/network/endian.c    2007-11-23 11:51:54 UTC (rev 5742)
@@ -28,7 +28,7 @@
 #include "gnunet_util_network.h"
 
 unsigned long long
-ntohll (unsigned long long n)
+GNUNET_ntohll (unsigned long long n)
 {
 #if __BYTE_ORDER == __BIG_ENDIAN
   return n;
@@ -38,7 +38,7 @@
 }
 
 unsigned long long
-htonll (unsigned long long n)
+GNUNET_htonll (unsigned long long n)
 {
 #if __BYTE_ORDER == __BIG_ENDIAN
   return n;

Modified: GNUnet/src/util/network/io.c
===================================================================
--- GNUnet/src/util/network/io.c        2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/network/io.c        2007-11-23 11:51:54 UTC (rev 5742)
@@ -28,15 +28,15 @@
 #include "platform.h"
 #include "network.h"
 
-#define DEBUG_IO NO
+#define DEBUG_IO GNUNET_NO
 
 /**
  * Global lock for gethostbyname.
  */
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
 #ifndef MINGW
-static struct SignalHandlerContext *sctx;
+static struct GNUNET_SignalHandlerContext *sctx;
 
 static void
 catcher ()
@@ -46,9 +46,9 @@
 
 void __attribute__ ((constructor)) gnunet_network_io_init ()
 {
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
 #ifndef MINGW
-  sctx = signal_handler_install (SIGPIPE, &catcher);
+  sctx = GNUNET_signal_handler_install (SIGPIPE, &catcher);
 #else
   InitWinEnv (NULL);
 #endif
@@ -56,10 +56,10 @@
 
 void __attribute__ ((destructor)) gnunet_network_io_fini ()
 {
-  MUTEX_DESTROY (lock);
+  GNUNET_mutex_destroy (lock);
   lock = NULL;
 #ifndef MINGW
-  signal_handler_uninstall (SIGPIPE, &catcher, sctx);
+  GNUNET_signal_handler_uninstall (SIGPIPE, &catcher, sctx);
   sctx = NULL;
 #else
   ShutdownWinEnv ();
@@ -68,15 +68,16 @@
 
 /**
  * Get the IP address of the given host.
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-get_host_by_name (struct GE_Context *ectx, const char *hostname, IPaddr * ip)
+GNUNET_get_host_by_name (struct GE_Context *ectx, const char *hostname,
+                         GNUNET_IPv4Address * ip)
 {
   struct hostent *he;
 
   /* slight hack: re-use config lock */
-  MUTEX_LOCK (lock);
+  GNUNET_mutex_lock (lock);
   he = GETHOSTBYNAME (hostname);
   if (he == NULL)
     {
@@ -84,30 +85,31 @@
               GE_ERROR | GE_ADMIN | GE_BULK,
               _("Could not find IP of host `%s': %s\n"),
               hostname, hstrerror (h_errno));
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   if (he->h_addrtype != AF_INET)
     {
       GE_BREAK (ectx, 0);
-      MUTEX_UNLOCK (lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (lock);
+      return GNUNET_SYSERR;
     }
   memcpy (ip,
           &((struct in_addr *) he->h_addr_list[0])->s_addr,
           sizeof (struct in_addr));
-  MUTEX_UNLOCK (lock);
-  return OK;
+  GNUNET_mutex_unlock (lock);
+  return GNUNET_OK;
 }
 
 
 
-struct SocketHandle *
-socket_create (struct GE_Context *ectx, struct LoadMonitor *mon, int osSocket)
+struct GNUNET_SocketHandle *
+socket_create (struct GE_Context *ectx, struct GNUNET_LoadMonitor *mon,
+               int osSocket)
 {
   SocketHandle *ret;
 
-  ret = MALLOC (sizeof (SocketHandle));
+  ret = GNUNET_malloc (sizeof (SocketHandle));
   ret->ectx = ectx;
   ret->mon = mon;
   ret->handle = osSocket;
@@ -116,7 +118,7 @@
 }
 
 void
-socket_close (struct SocketHandle *s)
+GNUNET_socket_close (struct GNUNET_SocketHandle *s)
 {
   GE_ASSERT (NULL, s != NULL);
   if ((0 != SHUTDOWN (s->handle, SHUT_RDWR)) &&
@@ -134,7 +136,7 @@
 }
 
 void
-socket_destroy (struct SocketHandle *s)
+GNUNET_socket_destroy (struct GNUNET_SocketHandle *s)
 {
   GE_ASSERT (NULL, s != NULL);
   if (s->handle != -1)
@@ -159,13 +161,13 @@
                          GE_WARNING | GE_USER | GE_DEVELOPER | GE_BULK,
                          "close");
     }
-  FREE (s);
+  GNUNET_free (s);
 }
 
 /* TODO: log errors! */
 #ifdef OSX
 static int
-socket_set_nosigpipe (struct SocketHandle *s, int dontSigPipe)
+socket_set_nosigpipe (struct GNUNET_SocketHandle *s, int dontSigPipe)
 {
   return setsockopt (s->handle,
                      SOL_SOCKET, SO_NOSIGPIPE,
@@ -175,7 +177,7 @@
 
 /* TODO: log errors! */
 int
-socket_set_blocking (struct SocketHandle *s, int doBlock)
+GNUNET_socket_set_blocking (struct GNUNET_SocketHandle *s, int doBlock)
 {
 #if MINGW
   u_long mode;
@@ -213,10 +215,10 @@
 }
 
 int
-socket_test_blocking (struct SocketHandle *s)
+GNUNET_socket_test_blocking (struct GNUNET_SocketHandle *s)
 {
 #ifndef MINGW
-  return (fcntl (s->handle, F_GETFL) & O_NONBLOCK) ? NO : YES;
+  return (fcntl (s->handle, F_GETFL) & O_NONBLOCK) ? GNUNET_NO : GNUNET_YES;
 #else
 #if HAVE_PLIBC_FD
   return plibc_fd_get_blocking (s->handle);
@@ -227,30 +229,30 @@
 }
 
 int
-socket_recv (struct SocketHandle *s,
-             NC_KIND nc, void *buf, size_t max, size_t * read)
+GNUNET_socket_recv (struct GNUNET_SocketHandle *s,
+                    GNUNET_NC_KIND nc, void *buf, size_t max, size_t * read)
 {
   int flags;
   size_t pos;
   size_t ret;
 
   GE_ASSERT (NULL, s->checksum == -s->handle);
-  socket_set_blocking (s, 0 != (nc & NC_Blocking));
+  GNUNET_socket_set_blocking (s, 0 != (nc & GNUNET_NC_BLOCKING));
   flags = 0;
 #ifdef CYGWIN
-  if (0 == (nc & NC_IgnoreInt))
+  if (0 == (nc & GNUNET_NC_IGNORE_INT))
     flags |= MSG_NOSIGNAL;
 #elif OSX
-  socket_set_nosigpipe (s, 0 == (nc & NC_IgnoreInt));
-  if (0 == (nc & NC_Blocking))
+  socket_set_nosigpipe (s, 0 == (nc & GNUNET_NC_IGNORE_INT));
+  if (0 == (nc & GNUNET_NC_BLOCKING))
     flags |= MSG_DONTWAIT;
 #elif SOMEBSD || SOLARIS
-  if (0 == (nc & NC_Blocking))
+  if (0 == (nc & GNUNET_NC_BLOCKING))
     flags |= MSG_DONTWAIT;
 #elif LINUX
-  if (0 == (nc & NC_Blocking))
+  if (0 == (nc & GNUNET_NC_BLOCKING))
     flags |= MSG_DONTWAIT;
-  if (0 == (nc & NC_IgnoreInt))
+  if (0 == (nc & GNUNET_NC_IGNORE_INT))
     flags |= MSG_NOSIGNAL;
 #else
   /* good luck */
@@ -263,71 +265,72 @@
       ret = (size_t) RECV (s->handle, &((char *) buf)[pos], max - pos, flags);
       GE_ASSERT (NULL, s->checksum == -s->handle);
       if ((ret == (size_t) - 1) &&
-          (errno == EINTR) && (0 != (nc & NC_IgnoreInt)))
+          (errno == EINTR) && (0 != (nc & GNUNET_NC_IGNORE_INT)))
         continue;
       if ((ret == (size_t) - 1) || (ret > max - pos))
         {
           if (errno == EINTR)
             {
               *read = pos;
-              return YES;
+              return GNUNET_YES;
             }
           if (errno == EWOULDBLOCK)
             {
-              if (0 != (nc & NC_Blocking))
+              if (0 != (nc & GNUNET_NC_BLOCKING))
                 continue;
               *read = pos;
-              return (pos == 0) ? NO : YES;
+              return (pos == 0) ? GNUNET_NO : GNUNET_YES;
             }
 #if DEBUG_IO
           GE_LOG_STRERROR (s->ectx, GE_DEBUG | GE_USER | GE_REQUEST, "recv");
 #endif
           *read = pos;
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (ret == 0)
         {
           /* most likely: other side closed connection */
           *read = pos;
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (s->mon != NULL)
-        os_network_monitor_notify_transmission (s->mon, Download, ret);
+        GNUNET_network_monitor_notify_transmission (s->mon,
+                                                    GNUNET_ND_DOWNLOAD, ret);
       GE_ASSERT (NULL, pos + ret >= pos);
       pos += ret;
     }
-  while ((pos < max) && (0 != (nc & NC_Blocking)));
+  while ((pos < max) && (0 != (nc & GNUNET_NC_BLOCKING)));
   *read = pos;
-  return YES;
+  return GNUNET_YES;
 }
 
 int
-socket_recv_from (struct SocketHandle *s,
-                  NC_KIND nc,
-                  void *buf,
-                  size_t max,
-                  size_t * read, char *from, unsigned int *fromlen)
+GNUNET_socket_recv_from (struct GNUNET_SocketHandle *s,
+                         GNUNET_NC_KIND nc,
+                         void *buf,
+                         size_t max,
+                         size_t * read, char *from, unsigned int *fromlen)
 {
   int flags;
   size_t pos;
   size_t ret;
 
-  socket_set_blocking (s, 0 != (nc & NC_Blocking));
+  GNUNET_socket_set_blocking (s, 0 != (nc & GNUNET_NC_BLOCKING));
   flags = 0;
 #ifdef CYGWIN
-  if (0 == (nc & NC_IgnoreInt))
+  if (0 == (nc & GNUNET_NC_IGNORE_INT))
     flags |= MSG_NOSIGNAL;
 #elif OSX
-  socket_set_nosigpipe (s, 0 == (nc & NC_IgnoreInt));
-  if (0 == (nc & NC_Blocking))
+  socket_set_nosigpipe (s, 0 == (nc & GNUNET_NC_IGNORE_INT));
+  if (0 == (nc & GNUNET_NC_BLOCKING))
     flags |= MSG_DONTWAIT;
 #elif SOMEBSD || SOLARIS
-  if (0 == (nc & NC_Blocking))
+  if (0 == (nc & GNUNET_NC_BLOCKING))
     flags |= MSG_DONTWAIT;
 #elif LINUX
-  if (0 == (nc & NC_Blocking))
+  if (0 == (nc & GNUNET_NC_BLOCKING))
     flags |= MSG_DONTWAIT;
-  if (0 == (nc & NC_IgnoreInt))
+  if (0 == (nc & GNUNET_NC_IGNORE_INT))
     flags |= MSG_NOSIGNAL;
 #else
   /* good luck */
@@ -340,67 +343,69 @@
                                max - pos,
                                flags, (struct sockaddr *) from, fromlen);
       if ((ret == (size_t) - 1) &&
-          (errno == EINTR) && (0 != (nc & NC_IgnoreInt)))
+          (errno == EINTR) && (0 != (nc & GNUNET_NC_IGNORE_INT)))
         continue;
       if ((ret == (size_t) - 1) || (ret > max - pos))
         {
           if (errno == EINTR)
             {
               *read = pos;
-              return YES;
+              return GNUNET_YES;
             }
           if (errno == EWOULDBLOCK)
             {
-              if (0 != (nc & NC_Blocking))
+              if (0 != (nc & GNUNET_NC_BLOCKING))
                 continue;
               *read = pos;
-              return (pos == 0) ? NO : YES;
+              return (pos == 0) ? GNUNET_NO : GNUNET_YES;
             }
           GE_LOG_STRERROR (s->ectx,
                            GE_ERROR | GE_USER | GE_BULK | GE_DEVELOPER,
                            "recvfrom");
           *read = pos;
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (ret == 0)
         {
           /* most likely: other side closed connection */
           *read = pos;
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (s->mon != NULL)
-        os_network_monitor_notify_transmission (s->mon, Download, ret);
+        GNUNET_network_monitor_notify_transmission (s->mon,
+                                                    GNUNET_ND_DOWNLOAD, ret);
       pos += ret;
     }
-  while ((pos < max) && (0 != (nc & NC_Blocking)));
+  while ((pos < max) && (0 != (nc & GNUNET_NC_BLOCKING)));
   *read = pos;
-  return YES;
+  return GNUNET_YES;
 }
 
 int
-socket_send (struct SocketHandle *s,
-             NC_KIND nc, const void *buf, size_t max, size_t * sent)
+GNUNET_socket_send (struct GNUNET_SocketHandle *s,
+                    GNUNET_NC_KIND nc, const void *buf, size_t max,
+                    size_t * sent)
 {
   int flags;
   size_t pos;
   size_t ret;
 
-  socket_set_blocking (s, 0 != (nc & NC_Blocking));
+  GNUNET_socket_set_blocking (s, 0 != (nc & GNUNET_NC_BLOCKING));
   flags = 0;
 #if SOMEBSD || SOLARIS
-  if (0 == (nc & NC_Blocking))
+  if (0 == (nc & GNUNET_NC_BLOCKING))
     flags |= MSG_DONTWAIT;
 #elif OSX
-  socket_set_nosigpipe (s, 0 == (nc & NC_IgnoreInt));
-  if (0 == (nc & NC_Blocking))
+  socket_set_nosigpipe (s, 0 == (nc & GNUNET_NC_IGNORE_INT));
+  if (0 == (nc & GNUNET_NC_BLOCKING))
     flags |= MSG_DONTWAIT;
 #elif CYGWIN
-  if (0 == (nc & NC_IgnoreInt))
+  if (0 == (nc & GNUNET_NC_IGNORE_INT))
     flags |= MSG_NOSIGNAL;
 #elif LINUX
-  if (0 == (nc & NC_Blocking))
+  if (0 == (nc & GNUNET_NC_BLOCKING))
     flags |= MSG_DONTWAIT;
-  if (0 == (nc & NC_IgnoreInt))
+  if (0 == (nc & GNUNET_NC_IGNORE_INT))
     flags |= MSG_NOSIGNAL;
 #else
   /* pray */
@@ -411,70 +416,71 @@
     {
       ret = (size_t) SEND (s->handle, &((char *) buf)[pos], max - pos, flags);
       if ((ret == (size_t) - 1) &&
-          (errno == EINTR) && (0 != (nc & NC_IgnoreInt)))
+          (errno == EINTR) && (0 != (nc & GNUNET_NC_IGNORE_INT)))
         continue;
       if ((ret == (size_t) - 1) || (ret > max - pos))
         {
           if (errno == EINTR)
             {
               *sent = pos;
-              return YES;
+              return GNUNET_YES;
             }
           if (errno == EWOULDBLOCK)
             {
-              if (0 != (nc & NC_Blocking))
+              if (0 != (nc & GNUNET_NC_BLOCKING))
                 continue;
               *sent = pos;
-              return (pos == 0) ? NO : YES;
+              return (pos == 0) ? GNUNET_NO : GNUNET_YES;
             }
 #if DEBUG_IO
           GE_LOG_STRERROR (s->ectx, GE_DEBUG | GE_USER | GE_REQUEST, "send");
 #endif
           *sent = pos;
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (ret == 0)
         {
           /* strange error; most likely: other side closed connection */
           *sent = pos;
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (s->mon != NULL)
-        os_network_monitor_notify_transmission (s->mon, Upload, ret);
+        GNUNET_network_monitor_notify_transmission (s->mon, GNUNET_ND_UPLOAD,
+                                                    ret);
       pos += ret;
     }
-  while ((pos < max) && (0 != (nc & NC_Blocking)));
+  while ((pos < max) && (0 != (nc & GNUNET_NC_BLOCKING)));
   *sent = pos;
-  return YES;
+  return GNUNET_YES;
 }
 
 int
-socket_send_to (struct SocketHandle *s,
-                NC_KIND nc,
-                const void *buf,
-                size_t max,
-                size_t * sent, const char *dst, unsigned int dstlen)
+GNUNET_socket_send_to (struct GNUNET_SocketHandle *s,
+                       GNUNET_NC_KIND nc,
+                       const void *buf,
+                       size_t max,
+                       size_t * sent, const char *dst, unsigned int dstlen)
 {
   int flags;
   size_t pos;
   size_t ret;
 
-  socket_set_blocking (s, 0 != (nc & NC_Blocking));
+  GNUNET_socket_set_blocking (s, 0 != (nc & GNUNET_NC_BLOCKING));
   flags = 0;
 #if SOMEBSD || SOLARIS
-  if (0 == (nc & NC_Blocking))
+  if (0 == (nc & GNUNET_NC_BLOCKING))
     flags |= MSG_DONTWAIT;
 #elif OSX
-  socket_set_nosigpipe (s, 0 == (nc & NC_IgnoreInt));
-  if (0 == (nc & NC_Blocking))
+  socket_set_nosigpipe (s, 0 == (nc & GNUNET_NC_IGNORE_INT));
+  if (0 == (nc & GNUNET_NC_BLOCKING))
     flags |= MSG_DONTWAIT;
 #elif CYGWIN
-  if (0 == (nc & NC_IgnoreInt))
+  if (0 == (nc & GNUNET_NC_IGNORE_INT))
     flags |= MSG_NOSIGNAL;
 #elif LINUX
-  if (0 == (nc & NC_Blocking))
+  if (0 == (nc & GNUNET_NC_BLOCKING))
     flags |= MSG_DONTWAIT;
-  if (0 == (nc & NC_IgnoreInt))
+  if (0 == (nc & GNUNET_NC_IGNORE_INT))
     flags |= MSG_NOSIGNAL;
 #else
   /* pray */
@@ -488,42 +494,43 @@
                              max - pos,
                              flags, (const struct sockaddr *) dst, dstlen);
       if ((ret == (size_t) - 1) &&
-          (errno == EINTR) && (0 != (nc & NC_IgnoreInt)))
+          (errno == EINTR) && (0 != (nc & GNUNET_NC_IGNORE_INT)))
         continue;
       if ((ret == (size_t) - 1) || (ret > max - pos))
         {
           if (errno == EINTR)
             {
               *sent = pos;
-              return YES;
+              return GNUNET_YES;
             }
           if (errno == EWOULDBLOCK)
             {
-              if (0 != (nc & NC_Blocking))
+              if (0 != (nc & GNUNET_NC_BLOCKING))
                 continue;
               *sent = pos;
-              return (pos == 0) ? NO : YES;
+              return (pos == 0) ? GNUNET_NO : GNUNET_YES;
             }
 #if DEBUG_IO
           GE_LOG_STRERROR (s->ectx,
                            GE_DEBUG | GE_USER | GE_REQUEST, "sendto");
 #endif
           *sent = pos;
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (ret == 0)
         {
           /* strange error; most likely: other side closed connection */
           *sent = pos;
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (s->mon != NULL)
-        os_network_monitor_notify_transmission (s->mon, Upload, ret);
+        GNUNET_network_monitor_notify_transmission (s->mon, GNUNET_ND_UPLOAD,
+                                                    ret);
       pos += ret;
     }
-  while ((pos < max) && (0 != (nc & NC_Blocking)));
+  while ((pos < max) && (0 != (nc & GNUNET_NC_BLOCKING)));
   *sent = pos;
-  return YES;
+  return GNUNET_YES;
 }
 
 /**
@@ -531,7 +538,7 @@
  * @return 1 if valid, 0 otherwise
  */
 int
-socket_test_valid (struct SocketHandle *s)
+GNUNET_socket_test_valid (struct GNUNET_SocketHandle *s)
 {
 #ifndef MINGW
   struct stat buf;

Modified: GNUnet/src/util/network/ip.c
===================================================================
--- GNUnet/src/util/network/ip.c        2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/network/ip.c        2007-11-23 11:51:54 UTC (rev 5742)
@@ -47,10 +47,11 @@
 /**
  * Obtain the identity information for the current node
  * (connection information), conInfo.
- * @return SYSERR on failure, OK on success
+ * @return GNUNET_SYSERR on failure, GNUNET_OK on success
  */
 static int
-getAddressFromHostname (struct GE_Context *ectx, IPaddr * identity)
+getAddressFromHostname (struct GE_Context *ectx,
+                        GNUNET_IPv4Address * identity)
 {
   char hostname[MAX_HOSTNAME];
   int ret;
@@ -60,16 +61,17 @@
       GE_LOG_STRERROR (ectx,
                        GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
                        "gethostname");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  ret = get_host_by_name (ectx, hostname, identity);
+  ret = GNUNET_get_host_by_name (ectx, hostname, identity);
   return ret;
 }
 
-#if HAVE_GETIFADDRS && HAVE_FREEIFADDRS
+#if HAVE_GETIFADDRS && HAVE_GNUNET_freeIFADDRS
 static int
 getAddressFromGetIfAddrs (struct GC_Configuration *cfg,
-                          struct GE_Context *ectx, IPaddr * identity)
+                          struct GE_Context *ectx,
+                          GNUNET_IPv4Address * identity)
 {
   char *interfaces;
   struct ifaddrs *ifa_first;
@@ -83,7 +85,7 @@
               GE_ERROR | GE_BULK | GE_USER,
               _("No interface specified in section `%s' under `%s'!\n"),
               "NETWORK", "INTERFACE");
-      return SYSERR;            /* that won't work! */
+      return GNUNET_SYSERR;     /* that won't work! */
     }
 
   if (getifaddrs (&ifa_first) == 0)
@@ -104,8 +106,8 @@
                       &(((struct sockaddr_in *) ifa_ptr->ifa_addr)->sin_addr),
                       sizeof (struct in_addr));
               freeifaddrs (ifa_first);
-              FREE (interfaces);
-              return OK;
+              GNUNET_free (interfaces);
+              return GNUNET_OK;
             }
         }
       freeifaddrs (ifa_first);
@@ -114,8 +116,8 @@
           GE_WARNING | GE_USER | GE_BULK,
           _("Could not obtain IP for interface `%s' using `%s'.\n"),
           interfaces, "getifaddrs");
-  FREE (interfaces);
-  return SYSERR;
+  GNUNET_free (interfaces);
+  return GNUNET_SYSERR;
 }
 #endif
 
@@ -124,7 +126,7 @@
 #define MAX_INTERFACES 16
 static int
 getAddressFromIOCTL (struct GC_Configuration *cfg,
-                     struct GE_Context *ectx, IPaddr * identity)
+                     struct GE_Context *ectx, GNUNET_IPv4Address * identity)
 {
   char *interfaces;
 #ifndef MINGW
@@ -145,16 +147,16 @@
               GE_ERROR | GE_BULK | GE_USER,
               _("No interface specified in section `%s' under `%s'!\n"),
               "NETWORK", "INTERFACE");
-      return SYSERR;            /* that won't work! */
+      return GNUNET_SYSERR;     /* that won't work! */
     }
 #ifndef MINGW
   sockfd = SOCKET (PF_INET, SOCK_DGRAM, 0);
   if (sockfd == -1)
     {
-      FREE (interfaces);
+      GNUNET_free (interfaces);
       GE_LOG_STRERROR (ectx,
                        GE_ERROR | GE_ADMIN | GE_USER | GE_BULK, "socket");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   memset (&ifc, 0, sizeof (struct ifconf));
   ifc.ifc_len = sizeof (ifr);
@@ -166,8 +168,8 @@
                        GE_WARNING | GE_ADMIN | GE_USER | GE_BULK, "ioctl");
       if (0 != CLOSE (sockfd))
         GE_LOG_STRERROR (ectx, GE_WARNING | GE_ADMIN | GE_BULK, "close");
-      FREE (interfaces);
-      return SYSERR;
+      GNUNET_free (interfaces);
+      return GNUNET_SYSERR;
     }
   ifCount = ifc.ifc_len / sizeof (struct ifreq);
 
@@ -187,8 +189,8 @@
               sizeof (struct in_addr));
       if (0 != CLOSE (sockfd))
         GE_LOG_STRERROR (ectx, GE_WARNING | GE_ADMIN | GE_BULK, "close");
-      FREE (interfaces);
-      return OK;
+      GNUNET_free (interfaces);
+      return GNUNET_OK;
     }
   GE_LOG (ectx,
           GE_WARNING | GE_ADMIN | GE_USER | GE_BULK,
@@ -210,8 +212,8 @@
               sizeof (struct in_addr));
       if (0 != CLOSE (sockfd))
         GE_LOG_STRERROR (ectx, GE_WARNING | GE_ADMIN | GE_BULK, "close");
-      FREE (interfaces);
-      return OK;
+      GNUNET_free (interfaces);
+      return GNUNET_OK;
     }
 
   if (0 != CLOSE (sockfd))
@@ -220,8 +222,8 @@
           GE_WARNING | GE_USER | GE_BULK,
           _("Could not obtain IP for interface `%s' using `%s'.\n"),
           interfaces, "ioctl");
-  FREE (interfaces);
-  return SYSERR;
+  GNUNET_free (interfaces);
+  return GNUNET_SYSERR;
 #else /* MinGW */
 
   /* Win 98 or Win NT SP 4 */
@@ -270,13 +272,14 @@
 
           GlobalFree (pTable);
           GlobalFree (pAddrTable);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       else if (iAddrCount > 1)
         GE_LOG (ectx, GE_WARNING | GE_BULK | GE_USER,
                 _("There is more than one IP address specified"
                   " for interface `%s'.\nGNUnet will "
-                  "use %u.%u.%u.%u.\n"), interfaces, PRIP (ntohl (dwIP)));
+                  "use %u.%u.%u.%u.\n"), interfaces,
+                GNUNET_PRIP (ntohl (dwIP)));
 
       identity->addr = dwIP;
 
@@ -297,7 +300,7 @@
                   _("Could not resolve `%s' to "
                     "determine our IP address: %s\n"),
                   "www.example.com", STRERROR (errno));
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
 
       theHost.sin_family = AF_INET;
@@ -309,14 +312,14 @@
                    sizeof (theHost)) == SOCKET_ERROR && errno != EWOULDBLOCK)
         {
           GE_LOG_STRERROR (ectx, GE_ERROR | GE_BULK | GE_USER, "connect");
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
 
       i = sizeof (theHost);
       if (GETSOCKNAME (s, (SOCKADDR *) & theHost, &i) == SOCKET_ERROR)
         {
           GE_LOG_STRERROR (ectx, GE_ERROR | GE_BULK | GE_USER, "getsockname");
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       closesocket (s);
       identity->addr = theHost.sin_addr.S_un.S_addr;
@@ -324,9 +327,9 @@
 
   GE_LOG (ectx, GE_DEBUG | GE_REQUEST | GE_USER,
           _("GNUnet now uses the IP address %u.%u.%u.%u.\n"),
-          PRIP (ntohl (identity->addr)));
+          GNUNET_PRIP (ntohl (identity->addr)));
 
-  return OK;
+  return GNUNET_OK;
 #endif
 }
 
@@ -337,43 +340,44 @@
  * @return NULL on error, IP as string otherwise
  */
 char *
-network_get_local_ip (struct GC_Configuration *cfg,
-                      struct GE_Context *ectx, IPaddr * addr)
+GNUNET_get_local_ip (struct GC_Configuration *cfg,
+                     struct GE_Context *ectx, GNUNET_IPv4Address * addr)
 {
-  IPaddr address;
+  GNUNET_IPv4Address address;
   char *ipString;
   int retval;
   char buf[65];
 
-  retval = SYSERR;
+  retval = GNUNET_SYSERR;
   if (GC_have_configuration_value (cfg, "NETWORK", "IP"))
     {
       ipString = NULL;
       GC_get_configuration_value_string (cfg, "NETWORK", "IP", "", &ipString);
       if (strlen (ipString) > 0)
         {
-          retval = get_host_by_name (ectx, ipString, &address);
+          retval = GNUNET_get_host_by_name (ectx, ipString, &address);
         }
-      FREE (ipString);
+      GNUNET_free (ipString);
     }
 #if LINUX || SOMEBSD || MINGW
-  if (retval == SYSERR)
-    if (OK == getAddressFromIOCTL (cfg, ectx, &address))
-      retval = OK;
+  if (retval == GNUNET_SYSERR)
+    if (GNUNET_OK == getAddressFromIOCTL (cfg, ectx, &address))
+      retval = GNUNET_OK;
 #endif
-#if HAVE_GETIFADDRS && HAVE_FREEIFADDRS
-  if (retval == SYSERR)
-    if (OK == getAddressFromGetIfAddrs (cfg, ectx, &address))
-      retval = OK;
+#if HAVE_GETIFADDRS && HAVE_GNUNET_freeIFADDRS
+  if (retval == GNUNET_SYSERR)
+    if (GNUNET_OK == getAddressFromGetIfAddrs (cfg, ectx, &address))
+      retval = GNUNET_OK;
 #endif
-  if (retval == SYSERR)
+  if (retval == GNUNET_SYSERR)
     retval = getAddressFromHostname (ectx, &address);
-  if (retval == SYSERR)
+  if (retval == GNUNET_SYSERR)
     return NULL;
-  SNPRINTF (buf, 64, "%u.%u.%u.%u", PRIP (ntohl (*(int *) &address)));
+  GNUNET_snprintf (buf, 64, "%u.%u.%u.%u",
+                   GNUNET_PRIP (ntohl (*(int *) &address)));
   if (addr != NULL)
     *addr = address;
-  return STRDUP (buf);
+  return GNUNET_strdup (buf);
 }
 
 

Modified: GNUnet/src/util/network/ipcheck.c
===================================================================
--- GNUnet/src/util/network/ipcheck.c   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/network/ipcheck.c   2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,19 +32,19 @@
 /**
  * @brief IPV4 network in CIDR notation.
  */
-typedef struct CIDRNetwork
+typedef struct GNUNET_IPv4NetworkSet
 {
-  IPaddr network;
-  IPaddr netmask;
+  GNUNET_IPv4Address network;
+  GNUNET_IPv4Address netmask;
 } CIDRNetwork;
 
 /**
  * @brief network in CIDR notation for IPV6.
  */
-typedef struct CIDR6Network
+typedef struct GNUNET_IPv6NetworkSet
 {
-  IP6addr network;
-  IP6addr netmask;
+  GNUNET_IPv6Address network;
+  GNUNET_IPv6Address netmask;
 } CIDR6Network;
 
 
@@ -60,8 +60,8 @@
  * @return the converted list, NULL if the synatx is flawed
  */
 CIDRNetwork *
-parse_ipv4_network_specification (struct GE_Context *ectx,
-                                  const char *routeList)
+GNUNET_parse_ipv4_network_specification (struct GE_Context *ectx,
+                                         const char *routeList)
 {
   unsigned int count;
   unsigned int i;
@@ -82,7 +82,7 @@
   for (i = 0; i < len; i++)
     if (routeList[i] == ';')
       count++;
-  result = MALLOC (sizeof (CIDRNetwork) * (count + 1));
+  result = GNUNET_malloc (sizeof (CIDRNetwork) * (count + 1));
   /* add termination */
   memset (result, 0, sizeof (CIDRNetwork) * (count + 1));
   i = 0;
@@ -103,7 +103,7 @@
                 GE_LOG (ectx,
                         GE_ERROR | GE_USER | GE_IMMEDIATE,
                         _("Invalid format for IP: `%s'\n"), &routeList[pos]);
-                FREE (result);
+                GNUNET_free (result);
                 return NULL;
               }
           result[i].network.addr
@@ -131,7 +131,7 @@
                 GE_LOG (ectx,
                         GE_ERROR | GE_USER | GE_IMMEDIATE,
                         _("Invalid format for IP: `%s'\n"), &routeList[pos]);
-                FREE (result);
+                GNUNET_free (result);
                 return NULL;
               }
           result[i].network.addr
@@ -161,7 +161,7 @@
                       _
                       ("Invalid network notation ('/%d' is not legal in IPv4 
CIDR)."),
                       slash);
-              FREE (result);
+              GNUNET_free (result);
               return NULL;      /* error */
             }
         }
@@ -178,7 +178,7 @@
                 GE_LOG (ectx,
                         GE_ERROR | GE_USER | GE_IMMEDIATE,
                         _("Invalid format for IP: `%s'\n"), &routeList[pos]);
-                FREE (result);
+                GNUNET_free (result);
                 return NULL;
               }
           result[i].network.addr
@@ -202,7 +202,7 @@
       GE_LOG (ectx,
               GE_ERROR | GE_USER | GE_IMMEDIATE,
               _("Invalid format for IP: `%s'\n"), &routeList[pos]);
-      FREE (result);
+      GNUNET_free (result);
       return NULL;              /* error */
     }
   if (pos < strlen (routeList))
@@ -210,7 +210,7 @@
       GE_LOG (ectx,
               GE_ERROR | GE_USER | GE_IMMEDIATE,
               _("Invalid format for IP: `%s'\n"), &routeList[pos]);
-      FREE (result);
+      GNUNET_free (result);
       return NULL;              /* oops */
     }
   return result;                /* ok */
@@ -229,8 +229,8 @@
  * @return the converted list, NULL if the synatx is flawed
  */
 CIDR6Network *
-parse_ipv6_network_specification (struct GE_Context * ectx,
-                                  const char *routeListX)
+GNUNET_parse_ipv6_network_specification (struct GE_Context * ectx,
+                                         const char *routeListX)
 {
   unsigned int count;
   unsigned int i;
@@ -247,7 +247,7 @@
   len = strlen (routeListX);
   if (len == 0)
     return NULL;
-  routeList = STRDUP (routeListX);
+  routeList = GNUNET_strdup (routeListX);
   count = 0;
   for (i = 0; i < len; i++)
     if (routeList[i] == ';')
@@ -258,11 +258,11 @@
               GE_ERROR | GE_USER | GE_IMMEDIATE,
               _("Invalid network notation (does not end with ';': `%s')\n"),
               routeList);
-      FREE (routeList);
+      GNUNET_free (routeList);
       return NULL;
     }
 
-  result = MALLOC (sizeof (CIDR6Network) * (count + 1));
+  result = GNUNET_malloc (sizeof (CIDR6Network) * (count + 1));
   memset (result, 0, sizeof (CIDR6Network) * (count + 1));
   i = 0;
   pos = 0;
@@ -276,7 +276,7 @@
         slash--;
       if (slash < start)
         {
-          memset (&result[i].netmask, 0xFF, sizeof (IP6addr));
+          memset (&result[i].netmask, 0xFF, sizeof (GNUNET_IPv6Address));
           slash = pos;
         }
       else
@@ -290,8 +290,8 @@
                       GE_ERROR | GE_USER | GE_IMMEDIATE,
                       _("Wrong format `%s' for netmask: %s\n"),
                       &routeList[slash + 1], STRERROR (errno));
-              FREE (result);
-              FREE (routeList);
+              GNUNET_free (result);
+              GNUNET_free (routeList);
               return NULL;
             }
         }
@@ -303,13 +303,13 @@
                   GE_ERROR | GE_USER | GE_IMMEDIATE,
                   _("Wrong format `%s' for network: %s\n"),
                   &routeList[slash + 1], STRERROR (errno));
-          FREE (result);
-          FREE (routeList);
+          GNUNET_free (result);
+          GNUNET_free (routeList);
           return NULL;
         }
       pos++;
     }
-  FREE (routeList);
+  GNUNET_free (routeList);
   return result;
 }
 
@@ -319,27 +319,27 @@
  *
  * @param list a list of networks
  * @param ip the IP to check (in network byte order)
- * @return NO if the IP is not in the list, YES if it it is
+ * @return GNUNET_NO if the IP is not in the list, GNUNET_YES if it it is
  */
 int
-check_ipv4_listed (const CIDRNetwork * list, IPaddr ip)
+GNUNET_check_ipv4_listed (const CIDRNetwork * list, GNUNET_IPv4Address ip)
 {
   int i;
-  IPaddr add;
+  GNUNET_IPv4Address add;
 
   add = ip;
   i = 0;
   if (list == NULL)
-    return NO;
+    return GNUNET_NO;
 
   while ((list[i].network.addr != 0) || (list[i].netmask.addr != 0))
     {
       if ((add.addr & list[i].netmask.addr) ==
           (list[i].network.addr & list[i].netmask.addr))
-        return YES;
+        return GNUNET_YES;
       i++;
     }
-  return NO;
+  return GNUNET_NO;
 }
 
 /**
@@ -347,10 +347,10 @@
  *
  * @param list a list of networks
  * @param ip the IP to check (in network byte order)
- * @return NO if the IP is not in the list, YES if it it is
+ * @return GNUNET_NO if the IP is not in the list, GNUNET_YES if it it is
  */
 int
-check_ipv6_listed (const CIDR6Network * list, IP6addr ip)
+GNUNET_check_ipv6_listed (const CIDR6Network * list, GNUNET_IPv6Address ip)
 {
   unsigned int i;
   unsigned int j;
@@ -358,7 +358,7 @@
 
   i = 0;
   if (list == NULL)
-    return NO;
+    return GNUNET_NO;
 
   memset (&zero, 0, sizeof (struct in6_addr));
   while ((memcmp (&zero, &list[i].network, sizeof (struct in6_addr)) != 0) ||
@@ -371,9 +371,9 @@
             i++;
             continue;
           }
-      return YES;
+      return GNUNET_YES;
     }
-  return NO;
+  return GNUNET_NO;
 }
 
 /* end of ipcheck.c */

Modified: GNUnet/src/util/network/ipchecktest.c
===================================================================
--- GNUnet/src/util/network/ipchecktest.c       2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/network/ipchecktest.c       2007-11-23 11:51:54 UTC (rev 
5742)
@@ -29,20 +29,20 @@
 int
 test ()
 {
-  struct CIDRNetwork *cidr;
+  struct GNUNET_IPv4NetworkSet *cidr;
 
-  cidr = parse_ipv4_network_specification (NULL, "127.0.0.1;");
+  cidr = GNUNET_parse_ipv4_network_specification (NULL, "127.0.0.1;");
   if (cidr == NULL)
     return 1;
-  FREE (cidr);
-  cidr = parse_ipv4_network_specification (NULL, "127.0.0.1/8;");
+  GNUNET_free (cidr);
+  cidr = GNUNET_parse_ipv4_network_specification (NULL, "127.0.0.1/8;");
   if (cidr == NULL)
     return 2;
-  FREE (cidr);
-  cidr = parse_ipv4_network_specification (NULL, "0.0.0.0/0;");
+  GNUNET_free (cidr);
+  cidr = GNUNET_parse_ipv4_network_specification (NULL, "0.0.0.0/0;");
   if (cidr == NULL)
     return 4;
-  FREE (cidr);
+  GNUNET_free (cidr);
   return 0;
 }
 

Modified: GNUnet/src/util/network/network.h
===================================================================
--- GNUnet/src/util/network/network.h   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/network/network.h   2007-11-23 11:51:54 UTC (rev 5742)
@@ -28,10 +28,10 @@
 #define NETWORK_H
 
 
-typedef struct SocketHandle
+typedef struct GNUNET_SocketHandle
 {
 
-  struct LoadMonitor *mon;
+  struct GNUNET_LoadMonitor *mon;
 
   struct GE_Context *ectx;
 

Modified: GNUnet/src/util/network/select.c
===================================================================
--- GNUnet/src/util/network/select.c    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/network/select.c    2007-11-23 11:51:54 UTC (rev 5742)
@@ -28,7 +28,7 @@
 #include "platform.h"
 #include "network.h"
 
-#define DEBUG_SELECT NO
+#define DEBUG_SELECT GNUNET_NO
 
 /**
  * Select Session handle.
@@ -39,7 +39,7 @@
   /**
    * the socket
    */
-  struct SocketHandle *sock;
+  struct GNUNET_SocketHandle *sock;
 
   /**
    * Client connection context.
@@ -56,13 +56,13 @@
    */
   char *wbuff;
 
-  cron_t lastUse;
+  GNUNET_CronTime lastUse;
 
   /**
    * Set to 0 initially, set to a much lower value
    * if a "fast timeout" is desired.
    */
-  cron_t timeout;
+  GNUNET_CronTime timeout;
 
   /**
    * 0 : can be destroyed
@@ -105,7 +105,7 @@
 
 } Session;
 
-typedef struct SelectHandle
+typedef struct GNUNET_SelectHandle
 {
 
   const char *description;
@@ -113,34 +113,34 @@
   /**
    * mutex for synchronized access
    */
-  struct MUTEX *lock;
+  struct GNUNET_Mutex *lock;
 
   /**
    * one thread for listening for new connections,
    * and for reading on all open sockets
    */
-  struct PTHREAD *thread;
+  struct GNUNET_ThreadHandle *thread;
 
   /**
    * sock is the tcp socket that we listen on for new inbound
    * connections.  Maybe NULL if we are not listening.
    */
-  struct SocketHandle *listen_sock;
+  struct GNUNET_SocketHandle *listen_sock;
 
   struct GE_Context *ectx;
 
-  struct LoadMonitor *load_monitor;
+  struct GNUNET_LoadMonitor *load_monitor;
 
   /**
    * Array of currently active TCP sessions.
    */
   Session **sessions;
 
-  SelectMessageHandler mh;
+  GNUNET_SelectMessageHandler mh;
 
-  SelectAcceptHandler ah;
+  GNUNET_SelectAcceptHandler ah;
 
-  SelectCloseHandler ch;
+  GNUNET_SelectCloseHandler ch;
 
   void *mh_cls;
 
@@ -148,7 +148,7 @@
 
   void *ch_cls;
 
-  cron_t timeout;
+  GNUNET_CronTime timeout;
 
   /**
    * tcp_pipe is used to signal the thread that is
@@ -174,7 +174,7 @@
 } SelectHandle;
 
 static void
-add_to_select_set (struct SocketHandle *s, fd_set * set, int *max)
+add_to_select_set (struct GNUNET_SocketHandle *s, fd_set * set, int *max)
 {
   FD_SET (s->handle, set);
   if (*max < s->handle)
@@ -243,15 +243,16 @@
         }
     }
   if (sh->sessionCount * 2 < sh->sessionArrayLength)
-    GROW (sh->sessions, sh->sessionArrayLength, sh->sessionCount);
-  MUTEX_UNLOCK (sh->lock);
+    GNUNET_array_grow (sh->sessions, sh->sessionArrayLength,
+                       sh->sessionCount);
+  GNUNET_mutex_unlock (sh->lock);
   sh->ch (sh->ch_cls, sh, s->sock, s->sock_ctx);
-  MUTEX_LOCK (sh->lock);
-  socket_destroy (s->sock);
+  GNUNET_mutex_lock (sh->lock);
+  GNUNET_socket_destroy (s->sock);
   sh->socket_quota++;
-  GROW (s->rbuff, s->rsize, 0);
-  GROW (s->wbuff, s->wsize, 0);
-  FREE (s);
+  GNUNET_array_grow (s->rbuff, s->rsize, 0);
+  GNUNET_array_grow (s->wbuff, s->wsize, 0);
+  GNUNET_free (s);
 }
 
 /**
@@ -260,12 +261,12 @@
  *
  * This function may only be called if the lock is
  * already held by the caller.
- * @return OK for success, SYSERR if session was destroyed
+ * @return GNUNET_OK for success, GNUNET_SYSERR if session was destroyed
  */
 static int
 readAndProcess (SelectHandle * sh, Session * session)
 {
-  const MESSAGE_HEADER *pack;
+  const GNUNET_MessageHeader *pack;
   int ret;
   size_t recvd;
   unsigned short len;
@@ -273,62 +274,64 @@
   if (session->rsize == session->pos)
     {
       /* read buffer too small, grow */
-      GROW (session->rbuff, session->rsize, session->rsize + 1024);
+      GNUNET_array_grow (session->rbuff, session->rsize,
+                         session->rsize + 1024);
     }
-  ret = socket_recv (session->sock,
-                     NC_Nonblocking | NC_IgnoreInt,
-                     &session->rbuff[session->pos],
-                     session->rsize - session->pos, &recvd);
+  ret = GNUNET_socket_recv (session->sock,
+                            GNUNET_NC_NONBLOCKING | GNUNET_NC_IGNORE_INT,
+                            &session->rbuff[session->pos],
+                            session->rsize - session->pos, &recvd);
 #if DEBUG_SELECT
   GE_LOG (sh->ectx,
           GE_DEBUG | GE_DEVELOPER | GE_BULK,
           "Receiving from session %p of select %p return %d-%u (%s).\n",
           sh, session, ret, recvd, STRERROR (errno));
 #endif
-  if (ret != OK)
+  if (ret != GNUNET_OK)
     {
       destroySession (sh, session);
-      return SYSERR;            /* other side closed connection */
+      return GNUNET_SYSERR;     /* other side closed connection */
     }
   session->pos += recvd;
-  while ((sh->shutdown == NO) && (session->pos >= sizeof (MESSAGE_HEADER)))
+  while ((sh->shutdown == GNUNET_NO)
+         && (session->pos >= sizeof (GNUNET_MessageHeader)))
     {
-      pack = (const MESSAGE_HEADER *) &session->rbuff[0];
+      pack = (const GNUNET_MessageHeader *) &session->rbuff[0];
       len = ntohs (pack->size);
       /* check minimum size */
-      if (len < sizeof (MESSAGE_HEADER))
+      if (len < sizeof (GNUNET_MessageHeader))
         {
           GE_LOG (sh->ectx,
                   GE_WARNING | GE_USER | GE_BULK,
                   _
                   ("Received malformed message (too small) from connection. 
Closing.\n"));
           destroySession (sh, session);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if (len > session->rsize) /* if message larger than read buffer, grow! */
-        GROW (session->rbuff, session->rsize, len);
+        GNUNET_array_grow (session->rbuff, session->rsize, len);
 
       /* do we have the entire message? */
       if (session->pos < len)
         break;                  /* wait for more */
       if (session->locked == 0)
         session->locked = 1;
-      MUTEX_UNLOCK (sh->lock);
-      if (OK != sh->mh (sh->mh_cls,
-                        sh, session->sock, session->sock_ctx, pack))
+      GNUNET_mutex_unlock (sh->lock);
+      if (GNUNET_OK != sh->mh (sh->mh_cls,
+                               sh, session->sock, session->sock_ctx, pack))
         {
-          MUTEX_LOCK (sh->lock);
+          GNUNET_mutex_lock (sh->lock);
           if (session->locked == 1)
             session->locked = 0;
           destroySession (sh, session);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
-      MUTEX_LOCK (sh->lock);
+      GNUNET_mutex_lock (sh->lock);
       if (session->locked == -1)
         {
           session->locked = 0;
           destroySession (sh, session);
-          return OK;
+          return GNUNET_OK;
         }
       if (session->locked == 1)
         session->locked = 0;
@@ -336,8 +339,8 @@
       memmove (&session->rbuff[0], &session->rbuff[len], session->pos - len);
       session->pos -= len;
     }
-  session->lastUse = get_time ();
-  return OK;
+  session->lastUse = GNUNET_get_time ();
+  return GNUNET_OK;
 }
 
 /**
@@ -346,7 +349,7 @@
  *
  * This function may only be called if the lock is
  * already held by the caller.
- * @return OK for success, SYSERR if session was destroyed
+ * @return GNUNET_OK for success, GNUNET_SYSERR if session was destroyed
  */
 static int
 writeAndProcess (SelectHandle * sh, Session * session)
@@ -362,26 +365,26 @@
           sh, session, sh->shutdown);
 #endif
   sock = session->sock;
-  while (sh->shutdown == NO)
+  while (sh->shutdown == GNUNET_NO)
     {
-      ret = socket_send (sock,
-                         NC_Nonblocking,
-                         &session->wbuff[session->wspos],
-                         session->wapos - session->wspos, &size);
+      ret = GNUNET_socket_send (sock,
+                                GNUNET_NC_NONBLOCKING,
+                                &session->wbuff[session->wspos],
+                                session->wapos - session->wspos, &size);
 #if DEBUG_SELECT
       GE_LOG (sh->ectx,
               GE_DEBUG | GE_DEVELOPER | GE_BULK,
               "Sending %d bytes from session %p of select %p return %d.\n",
               session->wapos - session->wspos, sh, session, ret);
 #endif
-      if (ret == SYSERR)
+      if (ret == GNUNET_SYSERR)
         {
           GE_LOG_STRERROR (sh->ectx,
                            GE_WARNING | GE_USER | GE_ADMIN | GE_BULK, "send");
           destroySession (sh, session);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
-      if (ret == OK)
+      if (ret == GNUNET_OK)
         {
           if (size == 0)
             {
@@ -389,7 +392,7 @@
                  other side closed connection), so close
                  the session */
               destroySession (sh, session);
-              return SYSERR;
+              return GNUNET_SYSERR;
             }
           session->wspos += size;
           if (session->wspos == session->wapos)
@@ -397,25 +400,26 @@
               /* free compaction! */
               session->wspos = 0;
               session->wapos = 0;
-              session->no_read = NO;
+              session->no_read = GNUNET_NO;
               if (session->wsize > sh->memory_quota)
                 {
                   /* if we went over quota before because of
                      force, use this opportunity to shrink
                      back to size! */
-                  GROW (session->wbuff, session->wsize, sh->memory_quota);
+                  GNUNET_array_grow (session->wbuff, session->wsize,
+                                     sh->memory_quota);
                 }
             }
           break;
         }
-      GE_ASSERT (sh->ectx, ret == NO);
+      GE_ASSERT (sh->ectx, ret == GNUNET_NO);
       /* this should only happen under Win9x because
          of a bug in the socket implementation (KB177346).
          Let's sleep and try again. */
-      PTHREAD_SLEEP (20 * cronMILLIS);
+      GNUNET_thread_sleep (20 * GNUNET_CRON_MILLISECONDS);
     }
-  session->lastUse = get_time ();
-  return OK;
+  session->lastUse = GNUNET_get_time ();
+  return GNUNET_OK;
 }
 
 /**
@@ -424,7 +428,7 @@
 static void *
 selectThread (void *ctx)
 {
-  struct SelectHandle *sh = ctx;
+  struct GNUNET_SelectHandle *sh = ctx;
   char *clientAddr;
   fd_set readSet;
   fd_set errorSet;
@@ -441,9 +445,9 @@
   size_t size;
   int old_errno;
 
-  clientAddr = MALLOC (sh->max_addr_len);
-  MUTEX_LOCK (sh->lock);
-  while (sh->shutdown == NO)
+  clientAddr = GNUNET_malloc (sh->max_addr_len);
+  GNUNET_mutex_lock (sh->lock);
+  while (sh->shutdown == GNUNET_NO)
     {
       FD_ZERO (&readSet);
       FD_ZERO (&errorSet);
@@ -465,9 +469,9 @@
       max = sh->signal_pipe[0];
       if (sh->listen_sock != NULL)
         {
-          if (!socket_test_valid (sh->listen_sock))
+          if (!GNUNET_socket_test_valid (sh->listen_sock))
             {
-              socket_destroy (sh->listen_sock);
+              GNUNET_socket_destroy (sh->listen_sock);
               GE_LOG (sh->ectx,
                       GE_USER | GE_ERROR | GE_BULK,
                       _("select listen socket for `%s' not valid!\n"),
@@ -482,9 +486,9 @@
       for (i = 0; i < sh->sessionCount; i++)
         {
           Session *session = sh->sessions[i];
-          struct SocketHandle *sock = session->sock;
+          struct GNUNET_SocketHandle *sock = session->sock;
 
-          if (!socket_test_valid (sock))
+          if (!GNUNET_socket_test_valid (sock))
             {
 #if DEBUG_SELECT
               GE_LOG (sh->ectx,
@@ -497,17 +501,17 @@
           else
             {
               add_to_select_set (sock, &errorSet, &max);
-              if (session->no_read != YES)
+              if (session->no_read != GNUNET_YES)
                 add_to_select_set (sock, &readSet, &max);
               GE_ASSERT (NULL, session->wapos >= session->wspos);
               if (session->wapos > session->wspos)
                 add_to_select_set (sock, &writeSet, &max);      /* do we have 
a pending write request? */
             }
         }
-      MUTEX_UNLOCK (sh->lock);
+      GNUNET_mutex_unlock (sh->lock);
       ret = SELECT (max + 1, &readSet, &writeSet, &errorSet, NULL);
       old_errno = errno;
-      MUTEX_LOCK (sh->lock);
+      GNUNET_mutex_lock (sh->lock);
       if ((ret == -1) && ((old_errno == EAGAIN) || (old_errno == EINTR)))
         continue;
       if (ret == -1)
@@ -526,7 +530,7 @@
             }
           continue;
         }
-      if (sh->is_udp == NO)
+      if (sh->is_udp == GNUNET_NO)
         {
           if ((sh->listen_sock != NULL) &&
               (FD_ISSET (sh->listen_sock->handle, &readSet)))
@@ -534,7 +538,7 @@
               lenOfIncomingAddr = sh->max_addr_len;
               memset (clientAddr, 0, lenOfIncomingAddr);
               /* make sure this is non-blocking */
-              socket_set_blocking (sh->listen_sock, NO);
+              GNUNET_socket_set_blocking (sh->listen_sock, GNUNET_NO);
               s = ACCEPT (sh->listen_sock->handle,
                           (struct sockaddr *) clientAddr, &lenOfIncomingAddr);
               if (s == -1)
@@ -565,10 +569,10 @@
                       "Select %p is accepting connection: %d\n", sh, s);
 #endif
               sock = socket_create (sh->ectx, sh->load_monitor, s);
-              MUTEX_UNLOCK (sh->lock);
+              GNUNET_mutex_unlock (sh->lock);
               sctx = sh->ah (sh->ah_cls,
                              sh, sock, clientAddr, lenOfIncomingAddr);
-              MUTEX_LOCK (sh->lock);
+              GNUNET_mutex_lock (sh->lock);
 #if DEBUG_SELECT
               GE_LOG (sh->ectx,
                       GE_DEBUG | GE_DEVELOPER | GE_BULK,
@@ -576,25 +580,26 @@
 #endif
               if (sctx == NULL)
                 {
-                  socket_destroy (sock);
+                  GNUNET_socket_destroy (sock);
                   sh->socket_quota++;
                 }
               else
                 {
-                  session = MALLOC (sizeof (Session));
+                  session = GNUNET_malloc (sizeof (Session));
                   memset (session, 0, sizeof (Session));
                   session->sock = sock;
                   session->sock_ctx = sctx;
-                  session->lastUse = get_time ();
+                  session->lastUse = GNUNET_get_time ();
                   if (sh->sessionArrayLength == sh->sessionCount)
-                    GROW (sh->sessions,
-                          sh->sessionArrayLength, sh->sessionArrayLength + 4);
+                    GNUNET_array_grow (sh->sessions,
+                                       sh->sessionArrayLength,
+                                       sh->sessionArrayLength + 4);
                   sh->sessions[sh->sessionCount++] = session;
                 }
             }
         }
       else
-        {                       /* is_udp == YES */
+        {                       /* is_udp == GNUNET_YES */
           if ((sh->listen_sock != NULL) &&
               (FD_ISSET (sh->listen_sock->handle, &readSet)))
             {
@@ -635,47 +640,49 @@
                 {
                   /* maybe empty UDP packet was sent (see report on bug-gnunet,
                      5/11/6; read 0 bytes from UDP just to kill potential 
empty packet! */
-                  socket_recv_from (sh->listen_sock,
-                                    NC_Nonblocking,
-                                    NULL,
-                                    0, &size, clientAddr, &lenOfIncomingAddr);
+                  GNUNET_socket_recv_from (sh->listen_sock,
+                                           GNUNET_NC_NONBLOCKING,
+                                           NULL,
+                                           0, &size, clientAddr,
+                                           &lenOfIncomingAddr);
                 }
               else
                 {
                   char *msg;
 
-                  msg = MALLOC (pending);
+                  msg = GNUNET_malloc (pending);
                   size = 0;
-                  ret = socket_recv_from (sh->listen_sock,
-                                          NC_Nonblocking,
-                                          msg,
-                                          pending,
-                                          &size,
-                                          clientAddr, &lenOfIncomingAddr);
-                  if (ret == SYSERR)
+                  ret = GNUNET_socket_recv_from (sh->listen_sock,
+                                                 GNUNET_NC_NONBLOCKING,
+                                                 msg,
+                                                 pending,
+                                                 &size,
+                                                 clientAddr,
+                                                 &lenOfIncomingAddr);
+                  if (ret == GNUNET_SYSERR)
                     {
-                      socket_close (sh->listen_sock);
+                      GNUNET_socket_close (sh->listen_sock);
                     }
-                  else if (ret == OK)
+                  else if (ret == GNUNET_OK)
                     {
                       /* validate msg format! */
-                      const MESSAGE_HEADER *hdr;
+                      const GNUNET_MessageHeader *hdr;
 
                       /* if size < pending, set pending to size */
                       if (size < pending)
                         pending = size;
-                      hdr = (const MESSAGE_HEADER *) msg;
+                      hdr = (const GNUNET_MessageHeader *) msg;
                       if ((size == pending) &&
-                          (size >= sizeof (MESSAGE_HEADER)) &&
+                          (size >= sizeof (GNUNET_MessageHeader)) &&
                           (ntohs (hdr->size) == size))
                         {
                           void *sctx;
 
-                          MUTEX_UNLOCK (sh->lock);
+                          GNUNET_mutex_unlock (sh->lock);
                           sctx = sh->ah (sh->ah_cls,
                                          sh,
                                          NULL, clientAddr, lenOfIncomingAddr);
-                          MUTEX_LOCK (sh->lock);
+                          GNUNET_mutex_lock (sh->lock);
                           if (sctx != NULL)
                             {
 #if DEBUG_SELECT
@@ -702,14 +709,14 @@
 #if DEBUG_SELECT
                           GE_BREAK (sh->ectx, size == pending);
                           GE_BREAK (sh->ectx,
-                                    size >= sizeof (MESSAGE_HEADER));
+                                    size >= sizeof (GNUNET_MessageHeader));
                           GE_BREAK (sh->ectx,
-                                    (size >= sizeof (MESSAGE_HEADER))
+                                    (size >= sizeof (GNUNET_MessageHeader))
                                     && (ntohs (hdr->size) == size));
 #endif
                         }
                     }
-                  FREE (msg);
+                  GNUNET_free (msg);
                 }
             }
         }                       /* end UDP processing */
@@ -731,13 +738,13 @@
           session = sh->sessions[i];
           sock = session->sock;
           if ((FD_ISSET (sock->handle, &readSet)) &&
-              (SYSERR == readAndProcess (sh, session)))
+              (GNUNET_SYSERR == readAndProcess (sh, session)))
             {
               i--;
               continue;
             }
           if ((FD_ISSET (sock->handle, &writeSet)) &&
-              (SYSERR == writeAndProcess (sh, session)))
+              (GNUNET_SYSERR == writeAndProcess (sh, session)))
             {
               i--;
               continue;
@@ -749,9 +756,9 @@
               continue;
             }
           if (((sh->timeout != 0) &&
-               (get_time () > session->lastUse + sh->timeout)) ||
+               (GNUNET_get_time () > session->lastUse + sh->timeout)) ||
               ((session->timeout != 0) &&
-               (get_time () > session->lastUse + session->timeout)))
+               (GNUNET_get_time () > session->lastUse + session->timeout)))
             {
               destroySession (sh, session);
               i--;
@@ -760,13 +767,13 @@
         }
     }
   sh->description = "DEAD";
-  MUTEX_UNLOCK (sh->lock);
-  FREE (clientAddr);
+  GNUNET_mutex_unlock (sh->lock);
+  GNUNET_free (clientAddr);
   return NULL;
 }
 
 int
-network_make_pipe_nonblocking (struct GE_Context *ectx, int handle)
+GNUNET_pipe_make_nonblocking (struct GE_Context *ectx, int handle)
 {
 #if MINGW
   DWORD mode;
@@ -788,10 +795,10 @@
       GE_LOG_STRERROR (ectx,
                        GE_WARNING | GE_USER | GE_ADMIN | GE_IMMEDIATE,
                        "fcntl");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 #endif
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -808,48 +815,50 @@
  * @return NULL on error
  */
 SelectHandle *
-select_create (const char *description,
-               int is_udp,
-               struct GE_Context * ectx,
-               struct LoadMonitor * mon,
-               int sock,
-               unsigned int max_addr_len,
-               cron_t timeout,
-               SelectMessageHandler mh,
-               void *mh_cls,
-               SelectAcceptHandler ah,
-               void *ah_cls,
-               SelectCloseHandler ch,
-               void *ch_cls, unsigned int memory_quota, int socket_quota)
+GNUNET_select_create (const char *description,
+                      int is_udp,
+                      struct GE_Context * ectx,
+                      struct GNUNET_LoadMonitor * mon,
+                      int sock,
+                      unsigned int max_addr_len,
+                      GNUNET_CronTime timeout,
+                      GNUNET_SelectMessageHandler mh,
+                      void *mh_cls,
+                      GNUNET_SelectAcceptHandler ah,
+                      void *ah_cls,
+                      GNUNET_SelectCloseHandler ch,
+                      void *ch_cls, unsigned int memory_quota,
+                      int socket_quota)
 {
   SelectHandle *sh;
 
-  if ((is_udp == NO) && (sock != -1) && (0 != LISTEN (sock, 5)))
+  if ((is_udp == GNUNET_NO) && (sock != -1) && (0 != LISTEN (sock, 5)))
     {
       GE_LOG_STRERROR (ectx, GE_ERROR | GE_USER | GE_IMMEDIATE, "listen");
       return NULL;
     }
   GE_ASSERT (ectx, description != NULL);
-  sh = MALLOC (sizeof (SelectHandle));
+  sh = GNUNET_malloc (sizeof (SelectHandle));
   memset (sh, 0, sizeof (SelectHandle));
   sh->is_udp = is_udp;
   sh->description = description;
   if (0 != PIPE (sh->signal_pipe))
     {
       GE_LOG_STRERROR (ectx, GE_ERROR | GE_USER | GE_IMMEDIATE, "pipe");
-      FREE (sh);
+      GNUNET_free (sh);
       return NULL;
     }
-  if (OK != network_make_pipe_nonblocking (sh->ectx, sh->signal_pipe[0]))
+  if (GNUNET_OK !=
+      GNUNET_pipe_make_nonblocking (sh->ectx, sh->signal_pipe[0]))
     {
       if ((0 != CLOSE (sh->signal_pipe[0])) ||
           (0 != CLOSE (sh->signal_pipe[1])))
         GE_LOG_STRERROR (ectx, GE_ERROR | GE_IMMEDIATE | GE_ADMIN, "close");
-      FREE (sh);
+      GNUNET_free (sh);
       return NULL;
     }
 
-  sh->shutdown = NO;
+  sh->shutdown = GNUNET_NO;
   sh->ectx = ectx;
   sh->load_monitor = mon;
   sh->max_addr_len = max_addr_len;
@@ -862,23 +871,23 @@
   sh->memory_quota = memory_quota;
   sh->socket_quota = socket_quota;
   sh->timeout = timeout;
-  sh->lock = MUTEX_CREATE (YES);
+  sh->lock = GNUNET_mutex_create (GNUNET_YES);
   if (sock != -1)
     sh->listen_sock = socket_create (ectx, mon, sock);
   else
     sh->listen_sock = NULL;
-  sh->thread = PTHREAD_CREATE (&selectThread, sh, 256 * 1024);
+  sh->thread = GNUNET_thread_create (&selectThread, sh, 256 * 1024);
   if (sh->thread == NULL)
     {
       GE_LOG_STRERROR (ectx,
                        GE_ERROR | GE_IMMEDIATE | GE_ADMIN, "pthread_create");
       if (sh->listen_sock != NULL)
-        socket_destroy (sh->listen_sock);
+        GNUNET_socket_destroy (sh->listen_sock);
       if ((0 != CLOSE (sh->signal_pipe[0])) ||
           (0 != CLOSE (sh->signal_pipe[1])))
         GE_LOG_STRERROR (ectx, GE_ERROR | GE_IMMEDIATE | GE_ADMIN, "close");
-      MUTEX_DESTROY (sh->lock);
-      FREE (sh);
+      GNUNET_mutex_destroy (sh->lock);
+      GNUNET_free (sh);
       return NULL;
     }
   return sh;
@@ -889,7 +898,7 @@
  * all associated connections.
  */
 void
-select_destroy (struct SelectHandle *sh)
+GNUNET_select_destroy (struct GNUNET_SelectHandle *sh)
 {
   void *unused;
 
@@ -897,17 +906,17 @@
   GE_LOG (sh->ectx,
           GE_DEBUG | GE_DEVELOPER | GE_BULK, "Destroying select %p\n", sh);
 #endif
-  sh->shutdown = YES;
+  sh->shutdown = GNUNET_YES;
   signalSelect (sh);
-  PTHREAD_STOP_SLEEP (sh->thread);
-  PTHREAD_JOIN (sh->thread, &unused);
+  GNUNET_thread_stop_sleep (sh->thread);
+  GNUNET_thread_join (sh->thread, &unused);
   sh->thread = NULL;
-  MUTEX_LOCK (sh->lock);
+  GNUNET_mutex_lock (sh->lock);
   while (sh->sessionCount > 0)
     destroySession (sh, sh->sessions[0]);
-  GROW (sh->sessions, sh->sessionArrayLength, 0);
-  MUTEX_UNLOCK (sh->lock);
-  MUTEX_DESTROY (sh->lock);
+  GNUNET_array_grow (sh->sessions, sh->sessionArrayLength, 0);
+  GNUNET_mutex_unlock (sh->lock);
+  GNUNET_mutex_destroy (sh->lock);
   if (0 != CLOSE (sh->signal_pipe[1]))
     GE_LOG_STRERROR (sh->ectx,
                      GE_ERROR | GE_USER | GE_ADMIN | GE_BULK, "close");
@@ -915,25 +924,26 @@
     GE_LOG_STRERROR (sh->ectx,
                      GE_ERROR | GE_USER | GE_ADMIN | GE_BULK, "close");
   if (sh->listen_sock != NULL)
-    socket_destroy (sh->listen_sock);
-  FREE (sh);
+    GNUNET_socket_destroy (sh->listen_sock);
+  GNUNET_free (sh);
 }
 
 /**
  * Queue the given message with the select thread.
  *
- * @param mayBlock if YES, blocks this thread until message
+ * @param mayBlock if GNUNET_YES, blocks this thread until message
  *        has been sent
  * @param force message is important, queue even if
  *        there is not enough space
- * @return OK if the message was sent or queued,
- *         NO if there was not enough memory to queue it,
- *         SYSERR if the sock does not belong with this select
+ * @return GNUNET_OK if the message was sent or queued,
+ *         GNUNET_NO if there was not enough memory to queue it,
+ *         GNUNET_SYSERR if the sock does not belong with this select
  */
 int
-select_write (struct SelectHandle *sh,
-              struct SocketHandle *sock,
-              const MESSAGE_HEADER * msg, int mayBlock, int force)
+GNUNET_select_write (struct GNUNET_SelectHandle *sh,
+                     struct GNUNET_SocketHandle *sock,
+                     const GNUNET_MessageHeader * msg, int mayBlock,
+                     int force)
 {
   Session *session;
   int i;
@@ -949,7 +959,7 @@
 #endif
   session = NULL;
   len = ntohs (msg->size);
-  MUTEX_LOCK (sh->lock);
+  GNUNET_mutex_lock (sh->lock);
   for (i = 0; i < sh->sessionCount; i++)
     if (sh->sessions[i]->sock == sock)
       {
@@ -958,19 +968,20 @@
       }
   if (session == NULL)
     {
-      MUTEX_UNLOCK (sh->lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (sh->lock);
+      return GNUNET_SYSERR;
     }
   GE_ASSERT (NULL, session->wapos >= session->wspos);
-  if ((force == NO) &&
+  if ((force == GNUNET_NO) &&
       (((sh->memory_quota > 0) &&
         (session->wapos - session->wspos + len > sh->memory_quota)) ||
        ((sh->memory_quota == 0) &&
-        (session->wapos - session->wspos + len > MAX_MALLOC_CHECKED / 2))))
+        (session->wapos - session->wspos + len >
+         GNUNET_MAX_GNUNET_malloc_CHECKED / 2))))
     {
       /* not enough free space, not allowed to grow that much */
-      MUTEX_UNLOCK (sh->lock);
-      return NO;
+      GNUNET_mutex_unlock (sh->lock);
+      return GNUNET_NO;
     }
   if (session->wsize - session->wapos < len)
     {
@@ -993,15 +1004,15 @@
           while (newBufferSize < len + session->wapos - session->wspos)
             newBufferSize *= 2;
           if ((sh->memory_quota > 0) &&
-              (newBufferSize > sh->memory_quota) && (force == NO))
+              (newBufferSize > sh->memory_quota) && (force == GNUNET_NO))
             newBufferSize = sh->memory_quota;
           GE_ASSERT (NULL,
                      newBufferSize >= len + session->wapos - session->wspos);
-          newBuffer = MALLOC (newBufferSize);
+          newBuffer = GNUNET_malloc (newBufferSize);
           memcpy (newBuffer,
                   &session->wbuff[session->wspos],
                   session->wapos - session->wspos);
-          FREENONNULL (session->wbuff);
+          GNUNET_free_non_null (session->wbuff);
           session->wbuff = newBuffer;
           session->wsize = newBufferSize;
           session->wapos = session->wapos - session->wspos;
@@ -1012,25 +1023,25 @@
   memcpy (&session->wbuff[session->wapos], msg, len);
   session->wapos += len;
   if (mayBlock)
-    session->no_read = YES;
-  MUTEX_UNLOCK (sh->lock);
+    session->no_read = GNUNET_YES;
+  GNUNET_mutex_unlock (sh->lock);
   signalSelect (sh);
-  return OK;
+  return GNUNET_OK;
 }
 
 
 /**
  */
 int
-select_update_closure (struct SelectHandle *sh,
-                       struct SocketHandle *sock,
-                       void *old_sock_ctx, void *new_sock_ctx)
+GNUNET_select_update_closure (struct GNUNET_SelectHandle *sh,
+                              struct GNUNET_SocketHandle *sock,
+                              void *old_sock_ctx, void *new_sock_ctx)
 {
   Session *session;
   int i;
 
   session = NULL;
-  MUTEX_LOCK (sh->lock);
+  GNUNET_mutex_lock (sh->lock);
   for (i = 0; i < sh->sessionCount; i++)
     if (sh->sessions[i]->sock == sock)
       {
@@ -1039,13 +1050,13 @@
       }
   if (session == NULL)
     {
-      MUTEX_UNLOCK (sh->lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (sh->lock);
+      return GNUNET_SYSERR;
     }
   GE_ASSERT (NULL, session->sock_ctx == old_sock_ctx);
   session->sock_ctx = new_sock_ctx;
-  MUTEX_UNLOCK (sh->lock);
-  return OK;
+  GNUNET_mutex_unlock (sh->lock);
+  return GNUNET_OK;
 }
 
 /**
@@ -1053,8 +1064,8 @@
  * sockets managed by the select.
  */
 int
-select_connect (struct SelectHandle *sh,
-                struct SocketHandle *sock, void *sock_ctx)
+GNUNET_select_connect (struct GNUNET_SelectHandle *sh,
+                       struct GNUNET_SocketHandle *sock, void *sock_ctx)
 {
   Session *session;
 
@@ -1063,23 +1074,24 @@
           GE_DEBUG | GE_DEVELOPER | GE_BULK,
           "Adding connection %p to selector %p\n", sock, sh);
 #endif
-  session = MALLOC (sizeof (Session));
+  session = GNUNET_malloc (sizeof (Session));
   memset (session, 0, sizeof (Session));
   session->sock = sock;
   session->sock_ctx = sock_ctx;
-  session->lastUse = get_time ();
-  MUTEX_LOCK (sh->lock);
+  session->lastUse = GNUNET_get_time ();
+  GNUNET_mutex_lock (sh->lock);
   if (sh->sessionArrayLength == sh->sessionCount)
-    GROW (sh->sessions, sh->sessionArrayLength, sh->sessionArrayLength + 4);
+    GNUNET_array_grow (sh->sessions, sh->sessionArrayLength,
+                       sh->sessionArrayLength + 4);
   sh->sessions[sh->sessionCount++] = session;
   sh->socket_quota--;
-  MUTEX_UNLOCK (sh->lock);
+  GNUNET_mutex_unlock (sh->lock);
   signalSelect (sh);
-  return OK;
+  return GNUNET_OK;
 }
 
 static Session *
-findSession (struct SelectHandle *sh, struct SocketHandle *sock)
+findSession (struct GNUNET_SelectHandle *sh, struct GNUNET_SocketHandle *sock)
 {
   int i;
 
@@ -1094,7 +1106,8 @@
  * set of sockets managed by select.
  */
 int
-select_disconnect (struct SelectHandle *sh, struct SocketHandle *sock)
+GNUNET_select_disconnect (struct GNUNET_SelectHandle *sh,
+                          struct GNUNET_SocketHandle *sock)
 {
   Session *session;
 
@@ -1103,17 +1116,17 @@
           GE_DEBUG | GE_DEVELOPER | GE_BULK,
           "Removing connection %p from selector %p\n", sock, sh);
 #endif
-  MUTEX_LOCK (sh->lock);
+  GNUNET_mutex_lock (sh->lock);
   session = findSession (sh, sock);
   if (session == NULL)
     {
-      MUTEX_UNLOCK (sh->lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (sh->lock);
+      return GNUNET_SYSERR;
     }
   destroySession (sh, session);
-  MUTEX_UNLOCK (sh->lock);
+  GNUNET_mutex_unlock (sh->lock);
   signalSelect (sh);
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
@@ -1122,59 +1135,60 @@
  * this select.
  */
 int
-select_change_timeout (struct SelectHandle *sh,
-                       struct SocketHandle *sock, cron_t timeout)
+GNUNET_select_change_timeout (struct GNUNET_SelectHandle *sh,
+                              struct GNUNET_SocketHandle *sock,
+                              GNUNET_CronTime timeout)
 {
   Session *session;
 
-  MUTEX_LOCK (sh->lock);
+  GNUNET_mutex_lock (sh->lock);
   session = findSession (sh, sock);
   if (session == NULL)
     {
-      MUTEX_UNLOCK (sh->lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (sh->lock);
+      return GNUNET_SYSERR;
     }
   session->timeout = timeout;
-  MUTEX_UNLOCK (sh->lock);
-  return OK;
+  GNUNET_mutex_unlock (sh->lock);
+  return GNUNET_OK;
 }
 
 
 /**
  * Would select queue or send the given message at this time?
  *
- * @param mayBlock if YES, blocks this thread until message
+ * @param mayBlock if GNUNET_YES, blocks this thread until message
  *        has been sent
  * @param size size of the message
  * @param force message is important, queue even if
  *        there is not enough space
- * @return OK if the message would be sent or queued,
- *         NO if there was not enough memory to queue it,
- *         SYSERR if the sock does not belong with this select
+ * @return GNUNET_OK if the message would be sent or queued,
+ *         GNUNET_NO if there was not enough memory to queue it,
+ *         GNUNET_SYSERR if the sock does not belong with this select
  */
 int
-select_would_try (struct SelectHandle *sh,
-                  struct SocketHandle *sock,
-                  unsigned int size, int mayBlock, int force)
+GNUNET_select_test_write_now (struct GNUNET_SelectHandle *sh,
+                              struct GNUNET_SocketHandle *sock,
+                              unsigned int size, int mayBlock, int force)
 {
   Session *session;
 
-  MUTEX_LOCK (sh->lock);
+  GNUNET_mutex_lock (sh->lock);
   session = findSession (sh, sock);
   if (session == NULL)
     {
-      MUTEX_UNLOCK (sh->lock);
-      return SYSERR;
+      GNUNET_mutex_unlock (sh->lock);
+      return GNUNET_SYSERR;
     }
   GE_ASSERT (NULL, session->wapos >= session->wspos);
   if ((sh->memory_quota > 0) &&
       (session->wapos - session->wspos + size > sh->memory_quota) &&
-      (force == NO))
+      (force == GNUNET_NO))
     {
       /* not enough free space, not allowed to grow that much */
-      MUTEX_UNLOCK (sh->lock);
-      return NO;
+      GNUNET_mutex_unlock (sh->lock);
+      return GNUNET_NO;
     }
-  MUTEX_UNLOCK (sh->lock);
-  return YES;
+  GNUNET_mutex_unlock (sh->lock);
+  return GNUNET_YES;
 }

Modified: GNUnet/src/util/network/selecttest.c
===================================================================
--- GNUnet/src/util/network/selecttest.c        2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/network/selecttest.c        2007-11-23 11:51:54 UTC (rev 
5742)
@@ -34,7 +34,7 @@
  * and performance is still erratic due to the sender
  * doing busy-waiting (and thus possibly burning CPU).
  */
-#define DO_SLEEP YES
+#define DO_SLEEP GNUNET_YES
 
 /**
  * The busy-waiting can be helped with yielding; while
@@ -43,7 +43,7 @@
  * useful to show the theoretical performance
  * (on my system about 100 mbps).
  */
-#define DO_YIELD NO
+#define DO_YIELD GNUNET_NO
 
 #if DO_YIELD
 void pthread_yield (void);
@@ -60,9 +60,9 @@
 #endif
 
 
-static struct SocketHandle *out;
+static struct GNUNET_SocketHandle *out;
 
-static struct SocketHandle *in;
+static struct GNUNET_SocketHandle *in;
 
 static unsigned int recvPos;
 
@@ -74,14 +74,14 @@
  *
  * @param sock socket on which the message was received
  *        (should ONLY be used to queue reply using select methods)
- * @return OK if message was valid, SYSERR if corresponding
+ * @return GNUNET_OK if message was valid, GNUNET_SYSERR if corresponding
  *  socket should be closed
  */
 static int
 test_smh (void *mh_cls,
-          struct SelectHandle *sh,
-          struct SocketHandle *sock,
-          void *sock_ctx, const MESSAGE_HEADER * msg)
+          struct GNUNET_SelectHandle *sh,
+          struct GNUNET_SocketHandle *sock,
+          void *sock_ctx, const GNUNET_MessageHeader * msg)
 {
   static int sleeper;
   char *expect;
@@ -89,15 +89,15 @@
 
   size = ntohs (msg->size);
   throughput += size;
-  expect = MALLOC (size);
-  memset (expect, (size - sizeof (MESSAGE_HEADER)) % 251, size);
-  if (0 != memcmp (&msg[1], expect, size - sizeof (MESSAGE_HEADER)))
+  expect = GNUNET_malloc (size);
+  memset (expect, (size - sizeof (GNUNET_MessageHeader)) % 251, size);
+  if (0 != memcmp (&msg[1], expect, size - sizeof (GNUNET_MessageHeader)))
     {
       fprintf (stderr, "Message of size %u corrupt!\n", size);
-      FREE (expect);
-      return OK;
+      GNUNET_free (expect);
+      return GNUNET_OK;
     }
-  FREE (expect);
+  GNUNET_free (expect);
   while (msg->type != htons (recvPos))
     {
       fprintf (stderr, "Message %u lost!\n", recvPos);
@@ -108,10 +108,10 @@
     fprintf (stderr, ".");
 #if DO_SLEEP
   if (sleeper % 5 == 0)
-    PTHREAD_SLEEP (50 * cronMILLIS);
+    GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
 #endif
   sleeper++;
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -128,8 +128,9 @@
  */
 static void *
 test_sah (void *ah_cls,
-          struct SelectHandle *sh,
-          struct SocketHandle *sock, const void *addr, unsigned int addr_len)
+          struct GNUNET_SelectHandle *sh,
+          struct GNUNET_SocketHandle *sock, const void *addr,
+          unsigned int addr_len)
 {
   static int ret_addr;
 
@@ -144,7 +145,8 @@
  */
 static void
 test_sch (void *ch_cls,
-          struct SelectHandle *sh, struct SocketHandle *sock, void *sock_ctx)
+          struct GNUNET_SelectHandle *sh, struct GNUNET_SocketHandle *sock,
+          void *sock_ctx)
 {
   if (sock == in)
     in = NULL;
@@ -160,14 +162,14 @@
 {
   static int zero = 0;
   struct sockaddr_in serverAddr;
-  struct SelectHandle *sh;
+  struct GNUNET_SelectHandle *sh;
   int listen_sock;
   int write_sock;
   int i;
   int msg;
   char *m;
-  MESSAGE_HEADER *h;
-  cron_t start;
+  GNUNET_MessageHeader *h;
+  GNUNET_CronTime start;
 
   listen_sock = SOCKET (PF_INET, SOCK_STREAM, 6);       /* 6: TCP */
   if (listen_sock == -1)
@@ -192,12 +194,12 @@
     }
   LISTEN (listen_sock, 5);
 
-  sh = select_create ("Select Tester", NO,      /* tcp */
-                      NULL,     /* ectx */
-                      NULL,     /* no load monitoring */
-                      listen_sock, sizeof (IPaddr), 15 * cronSECONDS,   /* 
inactive timeout */
-                      test_smh, NULL, test_sah, NULL, test_sch, NULL, 128 * 
1024,       /* memory quota */
-                      128 /* socket quota */ );
+  sh = GNUNET_select_create ("Select Tester", GNUNET_NO,        /* tcp */
+                             NULL,      /* ectx */
+                             NULL,      /* no load monitoring */
+                             listen_sock, sizeof (GNUNET_IPv4Address), 15 * 
GNUNET_CRON_SECONDS,        /* inactive timeout */
+                             test_smh, NULL, test_sah, NULL, test_sch, NULL, 
128 * 1024,        /* memory quota */
+                             128 /* socket quota */ );
 
   write_sock = SOCKET (PF_INET, SOCK_STREAM, 6);
 
@@ -210,33 +212,36 @@
   if ((i < 0) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK))
     {
       CLOSE (write_sock);
-      select_destroy (sh);
+      GNUNET_select_destroy (sh);
       return 1;
     }
   out = socket_create (NULL, NULL, write_sock);
-  if (-1 == socket_set_blocking (out, NO))
+  if (-1 == GNUNET_socket_set_blocking (out, GNUNET_NO))
     {
-      socket_destroy (out);
-      select_destroy (sh);
+      GNUNET_socket_destroy (out);
+      GNUNET_select_destroy (sh);
       return 1;
     }
   msg = 0;
-  m = MALLOC (65536);
-  h = (MESSAGE_HEADER *) m;
-  select_connect (sh, out, NULL);
-  start = get_time ();
+  m = GNUNET_malloc (65536);
+  h = (GNUNET_MessageHeader *) m;
+  GNUNET_select_connect (sh, out, NULL);
+  start = GNUNET_get_time ();
   for (i = 0; i < ITER; i++)
     {
-      if (GNUNET_SHUTDOWN_TEST () == YES)
+      if (GNUNET_shutdown_test () == GNUNET_YES)
         break;
-      if (select_would_try (sh,
-                            out,
-                            (i % 60000) + sizeof (MESSAGE_HEADER), NO, NO))
+      if (GNUNET_select_test_write_now (sh,
+                                        out,
+                                        (i % 60000) +
+                                        sizeof (GNUNET_MessageHeader),
+                                        GNUNET_NO, GNUNET_NO))
         {
-          h->size = htons ((i % 60000) + sizeof (MESSAGE_HEADER));
+          h->size = htons ((i % 60000) + sizeof (GNUNET_MessageHeader));
           h->type = htons (msg++);
-          memset (&m[sizeof (MESSAGE_HEADER)], (i % 60000) % 251, i % 60000);
-          select_write (sh, out, h, NO, NO);
+          memset (&m[sizeof (GNUNET_MessageHeader)], (i % 60000) % 251,
+                  i % 60000);
+          GNUNET_select_write (sh, out, h, GNUNET_NO, GNUNET_NO);
         }
       else
         {
@@ -246,21 +251,22 @@
         }
 #if DO_SLEEP
       if (i % 500 == 0)
-        PTHREAD_SLEEP (500 * cronMILLIS);
+        GNUNET_thread_sleep (500 * GNUNET_CRON_MILLISECONDS);
 #endif
     }
   /* give select time to send the rest... */
 #if DO_SLEEP
-  PTHREAD_SLEEP (2500 * cronMILLIS);
+  GNUNET_thread_sleep (2500 * GNUNET_CRON_MILLISECONDS);
 #endif
-  select_disconnect (sh, out);
-  select_destroy (sh);
-  FREE (m);
+  GNUNET_select_disconnect (sh, out);
+  GNUNET_select_destroy (sh);
+  GNUNET_free (m);
   fprintf (stderr,
            "\nTransmitted %u test messages - received %u (performance: %llu 
kbps)\n",
            msg,
            recvPos,
-           (throughput / 1024) * cronSECONDS / (get_time () - start));
+           (throughput / 1024) * GNUNET_CRON_SECONDS / (GNUNET_get_time () -
+                                                        start));
 #if DO_SLEEP
   if (msg - recvPos > 30)
     return 1;

Modified: GNUnet/src/util/network_client/Makefile.am
===================================================================
--- GNUnet/src/util/network_client/Makefile.am  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/network_client/Makefile.am  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -2,14 +2,12 @@
 
 SUBDIRS = .
 
-lib_LTLIBRARIES = \
-  libgnunetutil_network_client.la
+noinst_LTLIBRARIES = \
+  libnetwork_client.la
 
-libgnunetutil_network_client_la_SOURCES = \
+libnetwork_client_la_SOURCES = \
  daemon.c \
  tcpio.c 
-libgnunetutil_network_client_la_LIBADD = \
- $(top_builddir)/src/util/libgnunetutil.la  
 
 check_PROGRAMS = \
  tcpiotest 
@@ -19,9 +17,7 @@
 tcpiotest_SOURCES = \
  tcpiotest.c
 tcpiotest_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.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 = check.conf
\ No newline at end of file

Modified: GNUnet/src/util/network_client/daemon.c
===================================================================
--- GNUnet/src/util/network_client/daemon.c     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/network_client/daemon.c     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -31,49 +31,51 @@
 #include "gnunet_util_threads.h"
 
 int
-connection_test_running (struct GE_Context *ectx,
-                         struct GC_Configuration *cfg)
+GNUNET_test_daemon_running (struct GE_Context *ectx,
+                            struct GC_Configuration *cfg)
 {
-  struct ClientServerConnection *sock;
-  MESSAGE_HEADER csHdr;
+  struct GNUNET_ClientServerConnection *sock;
+  GNUNET_MessageHeader csHdr;
   int ret;
 
-  sock = client_connection_create (ectx, cfg);
+  sock = GNUNET_client_connection_create (ectx, cfg);
   if (sock == NULL)
-    return SYSERR;
-  csHdr.size = htons (sizeof (MESSAGE_HEADER));
+    return GNUNET_SYSERR;
+  csHdr.size = htons (sizeof (GNUNET_MessageHeader));
   csHdr.type = htons (CS_PROTO_traffic_COUNT);
-  if (SYSERR == connection_write (sock, &csHdr))
+  if (GNUNET_SYSERR == GNUNET_client_connection_write (sock, &csHdr))
     {
-      connection_destroy (sock);
-      return SYSERR;
+      GNUNET_client_connection_destroy (sock);
+      return GNUNET_SYSERR;
     }
-  if (SYSERR == connection_read_result (sock, &ret))
+  if (GNUNET_SYSERR == GNUNET_client_connection_read_result (sock, &ret))
     {
-      connection_destroy (sock);
-      return SYSERR;
+      GNUNET_client_connection_destroy (sock);
+      return GNUNET_SYSERR;
     }
-  connection_destroy (sock);
-  return OK;
+  GNUNET_client_connection_destroy (sock);
+  return GNUNET_OK;
 }
 
 int
-connection_request_shutdown (struct ClientServerConnection *sock)
+GNUNET_client_connection_request_daemon_shutdown (struct
+                                                  GNUNET_ClientServerConnection
+                                                  *sock)
 {
-  MESSAGE_HEADER csHdr;
+  GNUNET_MessageHeader csHdr;
   int ret;
 
-  csHdr.size = htons (sizeof (MESSAGE_HEADER));
+  csHdr.size = htons (sizeof (GNUNET_MessageHeader));
   csHdr.type = htons (CS_PROTO_SHUTDOWN_REQUEST);
-  if (SYSERR == connection_write (sock, &csHdr))
+  if (GNUNET_SYSERR == GNUNET_client_connection_write (sock, &csHdr))
     {
-      connection_close_temporarily (sock);
-      return SYSERR;
+      GNUNET_client_connection_close_temporarily (sock);
+      return GNUNET_SYSERR;
     }
-  if (SYSERR == connection_read_result (sock, &ret))
+  if (GNUNET_SYSERR == GNUNET_client_connection_read_result (sock, &ret))
     {
-      connection_close_temporarily (sock);
-      return SYSERR;
+      GNUNET_client_connection_close_temporarily (sock);
+      return GNUNET_SYSERR;
     }
   return ret;
 }
@@ -83,29 +85,30 @@
  * running.
  *
  * @param timeout how long to wait at most
- * @return OK if gnunetd is now running
+ * @return GNUNET_OK if gnunetd is now running
  */
 int
-connection_wait_for_running (struct GE_Context *ectx,
-                             struct GC_Configuration *cfg, cron_t timeout)
+GNUNET_wait_for_daemon_running (struct GE_Context *ectx,
+                                struct GC_Configuration *cfg,
+                                GNUNET_CronTime timeout)
 {
-  cron_t min;
+  GNUNET_CronTime min;
   int ret;
 
-  timeout += get_time ();
-  while (GNUNET_SHUTDOWN_TEST () == 0)
+  timeout += GNUNET_get_time ();
+  while (GNUNET_shutdown_test () == 0)
     {
-      ret = connection_test_running (ectx, cfg);
-      if (ret == OK)
-        return OK;
-      if (timeout < get_time ())
-        return SYSERR;
-      min = timeout - get_time ();
-      if (min > 100 * cronMILLIS)
-        min = 100 * cronMILLIS;
-      PTHREAD_SLEEP (min);
+      ret = GNUNET_test_daemon_running (ectx, cfg);
+      if (ret == GNUNET_OK)
+        return GNUNET_OK;
+      if (timeout < GNUNET_get_time ())
+        return GNUNET_SYSERR;
+      min = timeout - GNUNET_get_time ();
+      if (min > 100 * GNUNET_CRON_MILLISECONDS)
+        min = 100 * GNUNET_CRON_MILLISECONDS;
+      GNUNET_thread_sleep (min);
     }
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /* end of daemon.c */

Modified: GNUnet/src/util/network_client/tcpio.c
===================================================================
--- GNUnet/src/util/network_client/tcpio.c      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/network_client/tcpio.c      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -43,7 +43,7 @@
 #include "gnunet_protocols.h"
 #include "platform.h"
 
-#define DEBUG_TCPIO NO
+#define DEBUG_TCPIO GNUNET_NO
 
 /**
  * Struct to refer to a GNUnet TCP connection.
@@ -51,19 +51,19 @@
  * drops the connection, the client automatically tries
  * to reconnect (and for that needs connection information).
  */
-typedef struct ClientServerConnection
+typedef struct GNUNET_ClientServerConnection
 {
 
   /**
    * the socket handle, NULL if not life
    */
-  struct SocketHandle *sock;
+  struct GNUNET_SocketHandle *sock;
 
-  struct MUTEX *readlock;
+  struct GNUNET_Mutex *readlock;
 
-  struct MUTEX *writelock;
+  struct GNUNET_Mutex *writelock;
 
-  struct MUTEX *destroylock;
+  struct GNUNET_Mutex *destroylock;
 
   struct GE_Context *ectx;
 
@@ -99,7 +99,7 @@
   pos = strstr (res, ":");
   if (pos == NULL)
     {
-      FREE (res);
+      GNUNET_free (res);
       return 2087;
     }
   pos++;
@@ -110,10 +110,10 @@
               _
               ("Syntax error in configuration entry HOST in section NETWORK: 
`%s'"),
               pos);
-      FREE (res);
+      GNUNET_free (res);
       return 2087;
     }
-  FREE (res);
+  GNUNET_free (res);
   return (unsigned short) port;
 }
 
@@ -146,76 +146,80 @@
   return res;
 }
 
-struct ClientServerConnection *
-client_connection_create (struct GE_Context *ectx,
-                          struct GC_Configuration *cfg)
+struct GNUNET_ClientServerConnection *
+GNUNET_client_connection_create (struct GE_Context *ectx,
+                                 struct GC_Configuration *cfg)
 {
   ClientServerConnection *result;
 
-  result = MALLOC (sizeof (ClientServerConnection));
+  result = GNUNET_malloc (sizeof (ClientServerConnection));
   result->sock = NULL;
-  result->readlock = MUTEX_CREATE (NO);
-  result->writelock = MUTEX_CREATE (NO);
-  result->destroylock = MUTEX_CREATE (YES);
+  result->readlock = GNUNET_mutex_create (GNUNET_NO);
+  result->writelock = GNUNET_mutex_create (GNUNET_NO);
+  result->destroylock = GNUNET_mutex_create (GNUNET_YES);
   result->ectx = ectx;
   result->cfg = cfg;
   return result;
 }
 
 void
-connection_close_temporarily (struct ClientServerConnection *sock)
+GNUNET_client_connection_close_temporarily (struct
+                                            GNUNET_ClientServerConnection
+                                            *sock)
 {
   GE_ASSERT (NULL, sock != NULL);
-  MUTEX_LOCK (sock->destroylock);
+  GNUNET_mutex_lock (sock->destroylock);
   if (sock->sock != NULL)
     {
-      socket_close (sock->sock);
-      MUTEX_LOCK (sock->readlock);
-      MUTEX_LOCK (sock->writelock);
-      socket_destroy (sock->sock);
+      GNUNET_socket_close (sock->sock);
+      GNUNET_mutex_lock (sock->readlock);
+      GNUNET_mutex_lock (sock->writelock);
+      GNUNET_socket_destroy (sock->sock);
       sock->sock = NULL;
-      MUTEX_UNLOCK (sock->writelock);
-      MUTEX_UNLOCK (sock->readlock);
+      GNUNET_mutex_unlock (sock->writelock);
+      GNUNET_mutex_unlock (sock->readlock);
     }
-  MUTEX_UNLOCK (sock->destroylock);
+  GNUNET_mutex_unlock (sock->destroylock);
 }
 
 void
-connection_close_forever (struct ClientServerConnection *sock)
+GNUNET_client_connection_close_forever (struct GNUNET_ClientServerConnection
+                                        *sock)
 {
   GE_ASSERT (NULL, sock != NULL);
-  MUTEX_LOCK (sock->destroylock);
+  GNUNET_mutex_lock (sock->destroylock);
   if (sock->sock != NULL)
     {
-      socket_close (sock->sock);
-      MUTEX_LOCK (sock->readlock);
-      MUTEX_LOCK (sock->writelock);
-      socket_destroy (sock->sock);
+      GNUNET_socket_close (sock->sock);
+      GNUNET_mutex_lock (sock->readlock);
+      GNUNET_mutex_lock (sock->writelock);
+      GNUNET_socket_destroy (sock->sock);
       sock->sock = NULL;
-      sock->dead = YES;
-      MUTEX_UNLOCK (sock->writelock);
-      MUTEX_UNLOCK (sock->readlock);
+      sock->dead = GNUNET_YES;
+      GNUNET_mutex_unlock (sock->writelock);
+      GNUNET_mutex_unlock (sock->readlock);
     }
   else
     {
-      sock->dead = YES;
+      sock->dead = GNUNET_YES;
     }
-  MUTEX_UNLOCK (sock->destroylock);
+  GNUNET_mutex_unlock (sock->destroylock);
 }
 
 void
-connection_destroy (struct ClientServerConnection *sock)
+GNUNET_client_connection_destroy (struct GNUNET_ClientServerConnection *sock)
 {
   GE_ASSERT (NULL, sock != NULL);
-  connection_close_forever (sock);
-  MUTEX_DESTROY (sock->readlock);
-  MUTEX_DESTROY (sock->writelock);
-  MUTEX_DESTROY (sock->destroylock);
-  FREE (sock);
+  GNUNET_client_connection_close_forever (sock);
+  GNUNET_mutex_destroy (sock->readlock);
+  GNUNET_mutex_destroy (sock->writelock);
+  GNUNET_mutex_destroy (sock->destroylock);
+  GNUNET_free (sock);
 }
 
 int
-connection_test_open (struct ClientServerConnection *sock)
+GNUNET_client_connection_test_connected (struct GNUNET_ClientServerConnection
+                                         *sock)
 {
   return (sock->sock != NULL);
 }
@@ -224,7 +228,9 @@
  * Check a socket, open and connect if it is closed and it is a client-socket.
  */
 int
-connection_ensure_connected (struct ClientServerConnection *sock)
+GNUNET_client_connection_ensure_connected (struct
+                                           GNUNET_ClientServerConnection
+                                           *sock)
 {
   struct sockaddr_in soaddr;
   fd_set rset;
@@ -235,51 +241,52 @@
   int osock;
   unsigned short port;
   char *host;
-  IPaddr ip;
+  GNUNET_IPv4Address ip;
 
   GE_ASSERT (NULL, sock != NULL);
   if (sock->sock != NULL)
-    return OK;
-  if (sock->dead == YES)
-    return SYSERR;
+    return GNUNET_OK;
+  if (sock->dead == GNUNET_YES)
+    return GNUNET_SYSERR;
   port = getGNUnetPort (sock->ectx, sock->cfg);
   if (port == 0)
-    return SYSERR;
+    return GNUNET_SYSERR;
   host = getGNUnetdHost (sock->ectx, sock->cfg);
   if (host == NULL)
-    return SYSERR;
-  if (SYSERR == get_host_by_name (sock->ectx, host, &ip))
+    return GNUNET_SYSERR;
+  if (GNUNET_SYSERR == GNUNET_get_host_by_name (sock->ectx, host, &ip))
     {
-      FREE (host);
-      return SYSERR;
+      GNUNET_free (host);
+      return GNUNET_SYSERR;
     }
-  MUTEX_LOCK (sock->destroylock);
+  GNUNET_mutex_lock (sock->destroylock);
   if (sock->sock != NULL)
     {
-      FREE (host);
-      MUTEX_UNLOCK (sock->destroylock);
-      return OK;
+      GNUNET_free (host);
+      GNUNET_mutex_unlock (sock->destroylock);
+      return GNUNET_OK;
     }
-  if (sock->dead == YES)
+  if (sock->dead == GNUNET_YES)
     {
-      FREE (host);
-      MUTEX_UNLOCK (sock->destroylock);
-      return SYSERR;
+      GNUNET_free (host);
+      GNUNET_mutex_unlock (sock->destroylock);
+      return GNUNET_SYSERR;
     }
   osock = SOCKET (PF_INET, SOCK_STREAM, 6);     /* 6: TCP */
   if (osock == -1)
     {
       GE_LOG_STRERROR (sock->ectx,
                        GE_ERROR | GE_USER | GE_ADMIN | GE_BULK, "socket");
-      FREE (host);
-      MUTEX_UNLOCK (sock->destroylock);
-      return SYSERR;
+      GNUNET_free (host);
+      GNUNET_mutex_unlock (sock->destroylock);
+      return GNUNET_SYSERR;
     }
   sock->sock = socket_create (sock->ectx, NULL, osock);
-  socket_set_blocking (sock->sock, NO);
+  GNUNET_socket_set_blocking (sock->sock, GNUNET_NO);
   memset (&soaddr, 0, sizeof (soaddr));
   soaddr.sin_family = AF_INET;
-  GE_ASSERT (sock->ectx, sizeof (struct in_addr) == sizeof (IPaddr));
+  GE_ASSERT (sock->ectx,
+             sizeof (struct in_addr) == sizeof (GNUNET_IPv4Address));
   memcpy (&soaddr.sin_addr, &ip, sizeof (struct in_addr));
   soaddr.sin_port = htons (port);
   ret = CONNECT (osock, (struct sockaddr *) &soaddr, sizeof (soaddr));
@@ -289,11 +296,11 @@
               GE_WARNING | GE_USER | GE_BULK,
               _("Cannot connect to %s:%u: %s\n"),
               host, port, STRERROR (errno));
-      socket_destroy (sock->sock);
+      GNUNET_socket_destroy (sock->sock);
       sock->sock = NULL;
-      FREE (host);
-      MUTEX_UNLOCK (sock->destroylock);
-      return SYSERR;
+      GNUNET_free (host);
+      GNUNET_mutex_unlock (sock->destroylock);
+      return GNUNET_SYSERR;
     }
   /* we call select() first with a timeout of WAIT_SECONDS to
      avoid blocking on a later write indefinitely;
@@ -314,22 +321,22 @@
       if (errno != EINTR)
         GE_LOG_STRERROR (sock->ectx,
                          GE_WARNING | GE_USER | GE_BULK, "select");
-      socket_destroy (sock->sock);
+      GNUNET_socket_destroy (sock->sock);
       sock->sock = NULL;
-      FREE (host);
-      MUTEX_UNLOCK (sock->destroylock);
-      return SYSERR;
+      GNUNET_free (host);
+      GNUNET_mutex_unlock (sock->destroylock);
+      return GNUNET_SYSERR;
     }
   if (FD_ISSET (osock, &eset))
     {
       GE_LOG (sock->ectx,
               GE_WARNING | GE_USER | GE_BULK,
               _("Error connecting to %s:%u\n"), host, port);
-      socket_destroy (sock->sock);
+      GNUNET_socket_destroy (sock->sock);
       sock->sock = NULL;
-      FREE (host);
-      MUTEX_UNLOCK (sock->destroylock);
-      return SYSERR;
+      GNUNET_free (host);
+      GNUNET_mutex_unlock (sock->destroylock);
+      return GNUNET_SYSERR;
     }
   if (!FD_ISSET (osock, &wset))
     {
@@ -337,137 +344,142 @@
               GE_WARNING | GE_USER | GE_BULK,
               _("Failed to connect to %s:%u in %ds\n"),
               host, port, WAIT_SECONDS);
-      socket_destroy (sock->sock);
+      GNUNET_socket_destroy (sock->sock);
       sock->sock = NULL;
-      FREE (host);
-      MUTEX_UNLOCK (sock->destroylock);
-      return SYSERR;
+      GNUNET_free (host);
+      GNUNET_mutex_unlock (sock->destroylock);
+      return GNUNET_SYSERR;
     }
-  FREE (host);
-  socket_set_blocking (sock->sock, YES);
-  MUTEX_UNLOCK (sock->destroylock);
-  return OK;
+  GNUNET_free (host);
+  GNUNET_socket_set_blocking (sock->sock, GNUNET_YES);
+  GNUNET_mutex_unlock (sock->destroylock);
+  return GNUNET_OK;
 }
 
 /**
  * Write to a GNUnet TCP socket.  Will also potentially complete the
- * sending of a previous non-blocking connection_write call.
+ * sending of a previous non-blocking GNUNET_client_connection_write call.
  *
  * @param sock the socket to write to
  * @param buffer the buffer to write
- * @return OK if the write was sucessful, otherwise SYSERR.
+ * @return GNUNET_OK if the write was sucessful, otherwise GNUNET_SYSERR.
  */
 int
-connection_write (struct ClientServerConnection *sock,
-                  const MESSAGE_HEADER * buffer)
+GNUNET_client_connection_write (struct GNUNET_ClientServerConnection *sock,
+                                const GNUNET_MessageHeader * buffer)
 {
   size_t size;
   size_t sent;
   int res;
 
-  MUTEX_LOCK (sock->destroylock);
-  MUTEX_LOCK (sock->writelock);
-  if (SYSERR == connection_ensure_connected (sock))
+  GNUNET_mutex_lock (sock->destroylock);
+  GNUNET_mutex_lock (sock->writelock);
+  if (GNUNET_SYSERR == GNUNET_client_connection_ensure_connected (sock))
     {
-      MUTEX_UNLOCK (sock->writelock);
-      MUTEX_UNLOCK (sock->destroylock);
-      return SYSERR;
+      GNUNET_mutex_unlock (sock->writelock);
+      GNUNET_mutex_unlock (sock->destroylock);
+      return GNUNET_SYSERR;
     }
-  MUTEX_UNLOCK (sock->destroylock);
+  GNUNET_mutex_unlock (sock->destroylock);
   GE_ASSERT (NULL, sock->sock != NULL);
   size = ntohs (buffer->size);
-  res = socket_send (sock->sock, NC_Complete, buffer, size, &sent);
-  if ((res != YES) || (sent != size))
+  res =
+    GNUNET_socket_send (sock->sock, GNUNET_NC_COMPLETE_TRANSFER, buffer, size,
+                        &sent);
+  if ((res != GNUNET_YES) || (sent != size))
     {
-      MUTEX_UNLOCK (sock->writelock);
-      connection_close_temporarily (sock);
-      return SYSERR;
+      GNUNET_mutex_unlock (sock->writelock);
+      GNUNET_client_connection_close_temporarily (sock);
+      return GNUNET_SYSERR;
     }
-  MUTEX_UNLOCK (sock->writelock);
-  return OK;
+  GNUNET_mutex_unlock (sock->writelock);
+  return GNUNET_OK;
 }
 
 int
-connection_read (struct ClientServerConnection *sock,
-                 MESSAGE_HEADER ** buffer)
+GNUNET_client_connection_read (struct GNUNET_ClientServerConnection *sock,
+                               GNUNET_MessageHeader ** buffer)
 {
   int res;
   size_t pos;
   char *buf;
   unsigned short size;
-  RETURN_ERROR_MESSAGE *rem;
+  GNUNET_MessageReturnErrorMessage *rem;
 
-  MUTEX_LOCK (sock->destroylock);
-  MUTEX_LOCK (sock->readlock);
-  if (OK != connection_ensure_connected (sock))
+  GNUNET_mutex_lock (sock->destroylock);
+  GNUNET_mutex_lock (sock->readlock);
+  if (GNUNET_OK != GNUNET_client_connection_ensure_connected (sock))
     {
-      MUTEX_UNLOCK (sock->readlock);
-      MUTEX_UNLOCK (sock->destroylock);
-      return SYSERR;
+      GNUNET_mutex_unlock (sock->readlock);
+      GNUNET_mutex_unlock (sock->destroylock);
+      return GNUNET_SYSERR;
     }
-  MUTEX_UNLOCK (sock->destroylock);
+  GNUNET_mutex_unlock (sock->destroylock);
   GE_ASSERT (NULL, sock->sock != NULL);
   while (1)
     {
       pos = 0;
       res = 0;
-      if ((OK != socket_recv (sock->sock,
-                              NC_Complete,
-                              &size,
-                              sizeof (unsigned short),
-                              &pos)) || (pos != sizeof (unsigned short)))
+      if ((GNUNET_OK != GNUNET_socket_recv (sock->sock,
+                                            GNUNET_NC_COMPLETE_TRANSFER,
+                                            &size,
+                                            sizeof (unsigned short),
+                                            &pos))
+          || (pos != sizeof (unsigned short)))
         {
-          MUTEX_UNLOCK (sock->readlock);
-          connection_close_temporarily (sock);
-          return SYSERR;
+          GNUNET_mutex_unlock (sock->readlock);
+          GNUNET_client_connection_close_temporarily (sock);
+          return GNUNET_SYSERR;
         }
       size = ntohs (size);
-      if (size < sizeof (MESSAGE_HEADER))
+      if (size < sizeof (GNUNET_MessageHeader))
         {
           GE_BREAK (sock->ectx, 0);
-          MUTEX_UNLOCK (sock->readlock);
-          connection_close_temporarily (sock);
-          return SYSERR;        /* invalid header */
+          GNUNET_mutex_unlock (sock->readlock);
+          GNUNET_client_connection_close_temporarily (sock);
+          return GNUNET_SYSERR; /* invalid header */
         }
 
-      buf = MALLOC (size);
-      if ((OK != socket_recv (sock->sock,
-                              NC_Complete,
-                              &buf[pos],
-                              size - pos,
-                              &pos)) ||
+      buf = GNUNET_malloc (size);
+      if ((GNUNET_OK != GNUNET_socket_recv (sock->sock,
+                                            GNUNET_NC_COMPLETE_TRANSFER,
+                                            &buf[pos],
+                                            size - pos,
+                                            &pos)) ||
           (pos + sizeof (unsigned short) != size))
         {
-          FREE (buf);
-          MUTEX_UNLOCK (sock->readlock);
-          connection_close_temporarily (sock);
-          return SYSERR;
+          GNUNET_free (buf);
+          GNUNET_mutex_unlock (sock->readlock);
+          GNUNET_client_connection_close_temporarily (sock);
+          return GNUNET_SYSERR;
         }
 #if DEBUG_TCPIO
       GE_LOG (sock->ectx,
               GE_DEBUG | GE_REQUEST | GE_USER,
               "Successfully received %d bytes from TCP socket.\n", size);
 #endif
-      *buffer = (MESSAGE_HEADER *) buf;
+      *buffer = (GNUNET_MessageHeader *) buf;
       (*buffer)->size = htons (size);
 
       if (ntohs ((*buffer)->type) != CS_PROTO_RETURN_ERROR)
         break;                  /* got actual message! */
-      rem = (RETURN_ERROR_MESSAGE *) * buffer;
-      if (ntohs (rem->header.size) < sizeof (RETURN_ERROR_MESSAGE))
+      rem = (GNUNET_MessageReturnErrorMessage *) * buffer;
+      if (ntohs (rem->header.size) <
+          sizeof (GNUNET_MessageReturnErrorMessage))
         {
           GE_BREAK (sock->ectx, 0);
-          MUTEX_UNLOCK (sock->readlock);
-          connection_close_temporarily (sock);
-          FREE (buf);
-          return SYSERR;
+          GNUNET_mutex_unlock (sock->readlock);
+          GNUNET_client_connection_close_temporarily (sock);
+          GNUNET_free (buf);
+          return GNUNET_SYSERR;
         }
-      size = ntohs (rem->header.size) - sizeof (RETURN_ERROR_MESSAGE);
+      size =
+        ntohs (rem->header.size) - sizeof (GNUNET_MessageReturnErrorMessage);
       GE_LOG (sock->ectx, ntohl (rem->kind), "%.*s", (int) size, &rem[1]);
-      FREE (rem);
+      GNUNET_free (rem);
     }                           /* while (1) */
-  MUTEX_UNLOCK (sock->readlock);
-  return OK;                    /* success */
+  GNUNET_mutex_unlock (sock->readlock);
+  return GNUNET_OK;             /* success */
 }
 
 /**
@@ -475,29 +487,31 @@
  *
  * @param sock the TCP socket
  * @param ret the return value from TCP
- * @return SYSERR on error, OK if the return value was read
+ * @return GNUNET_SYSERR on error, GNUNET_OK if the return value was read
  * successfully
  */
 int
-connection_read_result (struct ClientServerConnection *sock, int *ret)
+GNUNET_client_connection_read_result (struct GNUNET_ClientServerConnection
+                                      *sock, int *ret)
 {
-  RETURN_VALUE_MESSAGE *rv;
+  GNUNET_MessageReturnValue *rv;
 
   rv = NULL;
-  if (SYSERR == connection_read (sock, (MESSAGE_HEADER **) & rv))
-    return SYSERR;
-  if ((ntohs (rv->header.size) != sizeof (RETURN_VALUE_MESSAGE)) ||
+  if (GNUNET_SYSERR ==
+      GNUNET_client_connection_read (sock, (GNUNET_MessageHeader **) & rv))
+    return GNUNET_SYSERR;
+  if ((ntohs (rv->header.size) != sizeof (GNUNET_MessageReturnValue)) ||
       (ntohs (rv->header.type) != CS_PROTO_RETURN_VALUE))
     {
       GE_LOG (sock->ectx,
               GE_WARNING | GE_DEVELOPER | GE_BULK,
               _("`%s' failed, reply invalid!\n"), __FUNCTION__);
-      FREE (rv);
-      return SYSERR;
+      GNUNET_free (rv);
+      return GNUNET_SYSERR;
     }
   *ret = ntohl (rv->return_value);
-  FREE (rv);
-  return OK;
+  GNUNET_free (rv);
+  return GNUNET_OK;
 }
 
 /**
@@ -505,18 +519,19 @@
  * TCP.
  * @param sock the TCP socket
  * @param ret the return value to send via TCP
- * @return SYSERR on error, OK if the return value was
+ * @return GNUNET_SYSERR on error, GNUNET_OK if the return value was
  *         send successfully
  */
 int
-connection_write_result (struct ClientServerConnection *sock, int ret)
+GNUNET_client_connection_write_result (struct GNUNET_ClientServerConnection
+                                       *sock, int ret)
 {
-  RETURN_VALUE_MESSAGE rv;
+  GNUNET_MessageReturnValue rv;
 
-  rv.header.size = htons (sizeof (RETURN_VALUE_MESSAGE));
+  rv.header.size = htons (sizeof (GNUNET_MessageReturnValue));
   rv.header.type = htons (CS_PROTO_RETURN_VALUE);
   rv.return_value = htonl (ret);
-  return connection_write (sock, &rv.header);
+  return GNUNET_client_connection_write (sock, &rv.header);
 }
 
 /*  end of tcpio.c */

Modified: GNUnet/src/util/network_client/tcpiotest.c
===================================================================
--- GNUnet/src/util/network_client/tcpiotest.c  2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/network_client/tcpiotest.c  2007-11-23 11:51:54 UTC (rev 
5742)
@@ -108,58 +108,60 @@
 }
 
 static int
-testTransmission (struct ClientServerConnection *a, struct SocketHandle *b)
+testTransmission (struct GNUNET_ClientServerConnection *a,
+                  struct GNUNET_SocketHandle *b)
 {
-  MESSAGE_HEADER *hdr;
-  MESSAGE_HEADER *buf;
+  GNUNET_MessageHeader *hdr;
+  GNUNET_MessageHeader *buf;
   int i;
   int j;
   size_t rd;
   size_t pos;
 
-  hdr = MALLOC (1024);
-  for (i = 0; i < 1024 - sizeof (MESSAGE_HEADER); i += 7)
+  hdr = GNUNET_malloc (1024);
+  for (i = 0; i < 1024 - sizeof (GNUNET_MessageHeader); i += 7)
     {
       fprintf (stderr, ".");
       for (j = 0; j < i; j++)
         ((char *) &hdr[1])[j] = (char) i + j;
-      hdr->size = htons (i + sizeof (MESSAGE_HEADER));
+      hdr->size = htons (i + sizeof (GNUNET_MessageHeader));
       hdr->type = 0;
-      if (OK != connection_write (a, hdr))
+      if (GNUNET_OK != GNUNET_client_connection_write (a, hdr))
         {
-          FREE (hdr);
+          GNUNET_free (hdr);
           return 1;
         }
-      buf = MALLOC (2048);
+      buf = GNUNET_malloc (2048);
       pos = 0;
-      while (pos < i + sizeof (MESSAGE_HEADER))
+      while (pos < i + sizeof (GNUNET_MessageHeader))
         {
           rd = 0;
-          if (SYSERR == socket_recv (b,
-                                     NC_Nonblocking,
-                                     &buf[pos], 2048 - pos, &rd))
+          if (GNUNET_SYSERR == GNUNET_socket_recv (b,
+                                                   GNUNET_NC_NONBLOCKING,
+                                                   &buf[pos], 2048 - pos,
+                                                   &rd))
             {
-              FREE (hdr);
-              FREE (buf);
+              GNUNET_free (hdr);
+              GNUNET_free (buf);
               return 2;
             }
           pos += rd;
         }
-      if (pos != i + sizeof (MESSAGE_HEADER))
+      if (pos != i + sizeof (GNUNET_MessageHeader))
         {
-          FREE (buf);
-          FREE (hdr);
+          GNUNET_free (buf);
+          GNUNET_free (hdr);
           return 3;
         }
-      if (0 != memcmp (buf, hdr, i + sizeof (MESSAGE_HEADER)))
+      if (0 != memcmp (buf, hdr, i + sizeof (GNUNET_MessageHeader)))
         {
-          FREE (buf);
-          FREE (hdr);
+          GNUNET_free (buf);
+          GNUNET_free (hdr);
           return 4;
         }
-      FREE (buf);
+      GNUNET_free (buf);
     }
-  FREE (hdr);
+  GNUNET_free (hdr);
   return 0;
 }
 
@@ -169,11 +171,11 @@
   int i;
   int ret;
   int serverSocket;
-  struct ClientServerConnection *clientSocket;
+  struct GNUNET_ClientServerConnection *clientSocket;
   int acceptSocket;
-  struct SocketHandle *sh;
+  struct GNUNET_SocketHandle *sh;
 
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   if (-1 == GC_parse_configuration (cfg, "check.conf"))
     {
       GC_free (cfg);
@@ -182,11 +184,12 @@
   serverSocket = openServerSocket ();
   if (serverSocket == -1)
     return 1;
-  clientSocket = client_connection_create (NULL, cfg);
+  clientSocket = GNUNET_client_connection_create (NULL, cfg);
   ret = 0;
   for (i = 0; i < 2; i++)
     {
-      if (OK != connection_ensure_connected (clientSocket))
+      if (GNUNET_OK !=
+          GNUNET_client_connection_ensure_connected (clientSocket))
         {
           ret = 42;
           break;
@@ -199,10 +202,10 @@
         }
       sh = socket_create (NULL, NULL, acceptSocket);
       ret = ret | testTransmission (clientSocket, sh);
-      connection_close_temporarily (clientSocket);
-      socket_destroy (sh);
+      GNUNET_client_connection_close_temporarily (clientSocket);
+      GNUNET_socket_destroy (sh);
     }
-  connection_destroy (clientSocket);
+  GNUNET_client_connection_destroy (clientSocket);
   CLOSE (serverSocket);
   if (ret > 0)
     fprintf (stderr, "Error %d\n", ret);

Modified: GNUnet/src/util/os/Makefile.am
===================================================================
--- GNUnet/src/util/os/Makefile.am      2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/os/Makefile.am      2007-11-23 11:51:54 UTC (rev 5742)
@@ -31,21 +31,15 @@
 daemontest_SOURCES = \
  daemontest.c 
 daemontest_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la 
+ $(top_builddir)/src/util/libgnunetutil.la 
 
 
 semaphoretest_SOURCES = \
  semaphoretest.c
 semaphoretest_LDADD = \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 
 statuscallstest_SOURCES = \
  statuscallstest.c
 statuscallstest_LDADD = \
- $(top_builddir)/src/util/loggers/libgnunetutil_logging.la \
- $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
  $(top_builddir)/src/util/libgnunetutil.la  

Modified: GNUnet/src/util/os/console.c
===================================================================
--- GNUnet/src/util/os/console.c        2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/os/console.c        2007-11-23 11:51:54 UTC (rev 5742)
@@ -53,11 +53,11 @@
 /**
  * Write our process ID to the pid file.
  *
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-os_write_pid_file (struct GE_Context *ectx,
-                   struct GC_Configuration *cfg, unsigned int pid)
+GNUNET_pid_file_write (struct GE_Context *ectx,
+                       struct GC_Configuration *cfg, unsigned int pid)
 {
   FILE *pidfd;
   char *pif;
@@ -67,9 +67,9 @@
 
   pif = getPIDFile (cfg);
   if (pif == NULL)
-    return OK;                  /* no PID file */
+    return GNUNET_OK;           /* no PID file */
   GC_get_configuration_value_string (cfg, "GNUNETD", "USER", "", &user);
-  rdir = STRDUP (pif);
+  rdir = GNUNET_strdup (pif);
   len = strlen (rdir);
   while ((len > 0) && (rdir[len] != DIR_SEPARATOR))
     len--;
@@ -78,28 +78,28 @@
     {
       /* we get to create a directory -- and claim it
          as ours! */
-      disk_directory_create (ectx, rdir);
+      GNUNET_disk_directory_create (ectx, rdir);
       if (strlen (user))
-        os_change_owner (ectx, rdir, user);
+        GNUNET_file_change_owner (ectx, rdir, user);
     }
   if (0 != ACCESS (rdir, W_OK | X_OK))
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
                             "access", rdir);
-      FREE (rdir);
-      FREE (user);
-      return SYSERR;
+      GNUNET_free (rdir);
+      GNUNET_free (user);
+      return GNUNET_SYSERR;
     }
-  FREE (rdir);
+  GNUNET_free (rdir);
   pidfd = FOPEN (pif, "w");
   if (pidfd == NULL)
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_WARNING | GE_ADMIN | GE_BULK, "fopen", pif);
-      FREE (pif);
-      FREE (user);
-      return SYSERR;
+      GNUNET_free (pif);
+      GNUNET_free (user);
+      return GNUNET_SYSERR;
     }
   if (0 > FPRINTF (pidfd, "%u", pid))
     GE_LOG_STRERROR_FILE (ectx,
@@ -108,31 +108,31 @@
     GE_LOG_STRERROR_FILE (ectx,
                           GE_WARNING | GE_ADMIN | GE_BULK, "fclose", pif);
   if (strlen (user))
-    os_change_owner (ectx, pif, user);
-  FREE (user);
-  FREE (pif);
-  return OK;
+    GNUNET_file_change_owner (ectx, pif, user);
+  GNUNET_free (user);
+  GNUNET_free (pif);
+  return GNUNET_OK;
 }
 
 int
-os_delete_pid_file (struct GE_Context *ectx, struct GC_Configuration *cfg)
+GNUNET_pid_file_delete (struct GE_Context *ectx, struct GC_Configuration *cfg)
 {
   char *pif = getPIDFile (cfg);
   if (pif == NULL)
-    return OK;                  /* no PID file */
-  if (YES == disk_file_test (ectx, pif))
+    return GNUNET_OK;           /* no PID file */
+  if (GNUNET_YES == GNUNET_disk_file_test (ectx, pif))
     {
       if (0 != UNLINK (pif))
         {
           GE_LOG_STRERROR_FILE (ectx,
                                 GE_WARNING | GE_ADMIN | GE_BULK,
                                 "unlink", pif);
-          FREE (pif);
-          return SYSERR;
+          GNUNET_free (pif);
+          return GNUNET_SYSERR;
         }
     }
-  FREE (pif);
-  return OK;
+  GNUNET_free (pif);
+  return GNUNET_OK;
 }
 
 
@@ -144,8 +144,8 @@
  *        to complete the detachment protocol (handshake)
  */
 int
-os_terminal_detach (struct GE_Context *ectx,
-                    struct GC_Configuration *cfg, int *filedes)
+GNUNET_terminal_detach (struct GE_Context *ectx,
+                        struct GC_Configuration *cfg, int *filedes)
 {
   pid_t pid;
   int nullfd;
@@ -155,7 +155,7 @@
     {
       GE_LOG_STRERROR (ectx,
                        GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE, "chdir");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
 #ifndef MINGW
@@ -165,7 +165,7 @@
     {
       GE_LOG_STRERROR (ectx,
                        GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE, "fork");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (pid)
     {                           /* Parent */
@@ -174,16 +174,16 @@
 
       if (0 != CLOSE (filedes[1]))
         GE_LOG_STRERROR (ectx, GE_WARNING | GE_USER | GE_BULK, "close");
-      ok = SYSERR;
+      ok = GNUNET_SYSERR;
       while (0 < READ (filedes[0], &c, sizeof (char)))
         {
           if (c == '.')
-            ok = OK;
+            ok = GNUNET_OK;
         }
       fflush (stdout);
-      if (ok == OK)
+      if (ok == GNUNET_OK)
         {
-          os_write_pid_file (ectx, cfg, pid);
+          GNUNET_pid_file_write (ectx, cfg, pid);
           exit (0);
         }
       else
@@ -193,13 +193,13 @@
     }
   if (0 != CLOSE (filedes[0]))
     GE_LOG_STRERROR (ectx, GE_WARNING | GE_USER | GE_BULK, "close");
-  nullfd = disk_file_open (ectx, "/dev/null", O_RDWR | O_APPEND);
+  nullfd = GNUNET_disk_file_open (ectx, "/dev/null", O_RDWR | O_APPEND);
   if (nullfd < 0)
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
                             "fork", "/dev/null");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   /* child - close fds linking to invoking terminal, but
    * close usual incoming fds, but redirect them somewhere
@@ -209,7 +209,7 @@
     {
       GE_LOG_STRERROR (ectx,
                        GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE, "dup2");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   pid = setsid ();              /* Detach from controlling terminal */
   if (pid == -1)
@@ -218,12 +218,12 @@
 #else
   FreeConsole ();
 #endif
-  return OK;
+  return GNUNET_OK;
 }
 
 void
-os_terminal_detach_complete (struct GE_Context *ectx,
-                             int *filedes, int success)
+GNUNET_terminal_detach_complete (struct GE_Context *ectx,
+                                 int *filedes, int success)
 {
 #ifndef MINGW
   char c = '.';

Modified: GNUnet/src/util/os/cpustatus.c
===================================================================
--- GNUnet/src/util/os/cpustatus.c      2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/os/cpustatus.c      2007-11-23 11:51:54 UTC (rev 5742)
@@ -58,13 +58,13 @@
 static processor_cpu_load_info_t prev_cpu_load;
 #endif
 
-#define DEBUG_STATUSCALLS NO
+#define DEBUG_STATUSCALLS GNUNET_NO
 
 #ifdef LINUX
 static FILE *proc_stat;
 #endif
 
-static struct MUTEX *statusMutex;
+static struct GNUNET_Mutex *statusMutex;
 
 /**
  * Current CPU load, as percentage of CPU cycles not idle or
@@ -101,9 +101,9 @@
       GE_LOG (NULL,
               GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
               "host_processor_info failed.");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  prev_cpu_load = MALLOC (cpu_count * sizeof (*prev_cpu_load));
+  prev_cpu_load = GNUNET_malloc (cpu_count * sizeof (*prev_cpu_load));
   for (i = 0; i < cpu_count; i++)
     {
       for (j = 0; j < CPU_STATE_MAX; j++)
@@ -114,7 +114,7 @@
   vm_deallocate (mach_task_self (),
                  (vm_address_t) cpu_load,
                  (vm_size_t) (cpu_msg_count * sizeof (*cpu_load)));
-  return OK;
+  return GNUNET_OK;
 }
 #endif
 
@@ -136,7 +136,7 @@
   if (proc_stat != NULL)
     {
       static unsigned long long last_cpu_results[5] = { 0, 0, 0, 0, 0 };
-      static int have_last_cpu = NO;
+      static int have_last_cpu = GNUNET_NO;
       int ret;
       char line[256];
       unsigned long long user_read, system_read, nice_read, idle_read,
@@ -168,7 +168,7 @@
                                     "fgets-sscanf", "/proc/stat");
               fclose (proc_stat);
               proc_stat = NULL; /* don't try again */
-              have_last_cpu = NO;
+              have_last_cpu = GNUNET_NO;
             }
           else
             {
@@ -181,7 +181,7 @@
               /* Calculate the % usage */
               usage_time = user + system + nice;
               total_time = usage_time + idle + iowait;
-              if ((total_time > 0) && (have_last_cpu == YES))
+              if ((total_time > 0) && (have_last_cpu == GNUNET_YES))
                 {
                   currentCPULoad = (int) (100L * usage_time / total_time);
                   if (ret > 4)
@@ -195,8 +195,8 @@
               last_cpu_results[2] = nice_read;
               last_cpu_results[3] = idle_read;
               last_cpu_results[4] = iowait_read;
-              have_last_cpu = YES;
-              return OK;
+              have_last_cpu = GNUNET_YES;
+              return GNUNET_OK;
             }
         }
     }
@@ -291,14 +291,14 @@
                        (vm_address_t) cpu_load,
                        (vm_size_t) (cpu_msg_count * sizeof (*cpu_load)));
         currentIOLoad = -1;     /* FIXME-OSX! */
-        return OK;
+        return GNUNET_OK;
       }
     else
       {
         GE_LOG (NULL,
                 GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
                 "host_processor_info failed.");
-        return SYSERR;
+        return GNUNET_SYSERR;
       }
   }
 #endif
@@ -369,10 +369,10 @@
     currentIOLoad = -1;         /* FIXME-SOLARIS! */
     last_idlecount = idlecount;
     last_totalcount = totalcount;
-    return OK;
+    return GNUNET_OK;
   ABORT_KSTAT:
     kstat_once = 1;             /* failed, don't try again */
-    return SYSERR;
+    return GNUNET_SYSERR;
   }
 #endif
 
@@ -395,14 +395,14 @@
                              GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
                              "getloadavg");
           }
-        return SYSERR;
+        return GNUNET_SYSERR;
       }
     else
       {
         /* success with getloadavg */
         currentCPULoad = (int) (100 * loadavg);
         currentIOLoad = -1;     /* FIXME */
-        return OK;
+        return GNUNET_OK;
       }
   }
 #endif
@@ -446,7 +446,7 @@
           dLastUser = dUser;
 
           currentIOLoad = -1;   /* FIXME-MINGW */
-          return OK;
+          return GNUNET_OK;
         }
       else
         {
@@ -460,7 +460,7 @@
                       GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
                       _("Cannot query the CPU usage (Windows NT).\n"));
             }
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
     }
   else
@@ -513,7 +513,7 @@
                        NULL, &dwType, (LPBYTE) & dwDummy, &dwDataSize);
       RegCloseKey (hKey);
 
-      return OK;
+      return GNUNET_OK;
     }
 #endif
 
@@ -521,7 +521,7 @@
      specific alternative defined
      => default: error
    */
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 /**
@@ -532,11 +532,12 @@
 static void
 updateAgedLoad (struct GE_Context *ectx, struct GC_Configuration *cfg)
 {
-  static cron_t lastCall;
-  cron_t now;
+  static GNUNET_CronTime lastCall;
+  GNUNET_CronTime now;
 
-  now = get_time ();
-  if ((agedCPULoad == -1) || (now - lastCall > 500 * cronMILLIS))
+  now = GNUNET_get_time ();
+  if ((agedCPULoad == -1)
+      || (now - lastCall > 500 * GNUNET_CRON_MILLISECONDS))
     {
       /* use smoothing, but do NOT update lastRet at frequencies higher
          than 500ms; this makes the smoothing (mostly) independent from
@@ -587,20 +588,20 @@
  *        (100 is equivalent to full load)
  */
 int
-os_cpu_get_load (struct GE_Context *ectx, struct GC_Configuration *cfg)
+GNUNET_cpu_get_load (struct GE_Context *ectx, struct GC_Configuration *cfg)
 {
   unsigned long long maxCPULoad;
   int ret;
 
-  MUTEX_LOCK (statusMutex);
+  GNUNET_mutex_lock (statusMutex);
   updateAgedLoad (ectx, cfg);
   ret = agedCPULoad;
-  MUTEX_UNLOCK (statusMutex);
+  GNUNET_mutex_unlock (statusMutex);
   if (ret == -1)
     return -1;
   if (-1 == GC_get_configuration_value_number (cfg, "LOAD", "MAXCPULOAD", 0, 
10000,     /* more than 1 CPU possible */
                                                100, &maxCPULoad))
-    return SYSERR;
+    return GNUNET_SYSERR;
   return (100 * ret) / maxCPULoad;
 }
 
@@ -611,31 +612,31 @@
  *        (100 is equivalent to full load)
  */
 int
-os_disk_get_load (struct GE_Context *ectx, struct GC_Configuration *cfg)
+GNUNET_disk_get_load (struct GE_Context *ectx, struct GC_Configuration *cfg)
 {
   unsigned long long maxIOLoad;
   int ret;
 
-  MUTEX_LOCK (statusMutex);
+  GNUNET_mutex_lock (statusMutex);
   updateAgedLoad (ectx, cfg);
   ret = agedIOLoad;
-  MUTEX_UNLOCK (statusMutex);
+  GNUNET_mutex_unlock (statusMutex);
   if (ret == -1)
     return -1;
   if (-1 == GC_get_configuration_value_number (cfg, "LOAD", "MAXIOLOAD", 0, 
10000,      /* more than 1 CPU possible */
                                                100, &maxIOLoad))
-    return SYSERR;
+    return GNUNET_SYSERR;
   return (100 * ret) / maxIOLoad;
 }
 
 /**
  * The following method is called in order to initialize the status calls
  * routines.  After that it is safe to call each of the status calls separately
- * @return OK on success and SYSERR on error (or calls errexit).
+ * @return GNUNET_OK on success and GNUNET_SYSERR on error (or calls errexit).
  */
 void __attribute__ ((constructor)) gnunet_cpustats_ltdl_init ()
 {
-  statusMutex = MUTEX_CREATE (NO);
+  statusMutex = GNUNET_mutex_create (GNUNET_NO);
 #ifdef LINUX
   proc_stat = fopen ("/proc/stat", "r");
   if (NULL == proc_stat)
@@ -662,11 +663,11 @@
       proc_stat = NULL;
     }
 #elif OSX
-  FREENONNULL (prev_cpu_load);
+  GNUNET_free_non_null (prev_cpu_load);
 #elif MINGW
   ShutdownWinEnv ();
 #endif
-  MUTEX_DESTROY (statusMutex);
+  GNUNET_mutex_destroy (statusMutex);
 }
 
 

Modified: GNUnet/src/util/os/daemon.c
===================================================================
--- GNUnet/src/util/os/daemon.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/os/daemon.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,7 +32,7 @@
 /**
  * Fork a gnunetd process
  *
- * @param daemonize YES if gnunetd should be daemonized
+ * @param daemonize GNUNET_YES if gnunetd should be daemonized
  * @return pid_t of gnunetd if NOT daemonized, 0 if
  *  daemonized sucessfully, -1 on error
  */
@@ -52,9 +52,9 @@
       int i;
 
       path = NULL;
-      cp = os_get_installation_path (IPK_BINDIR);
+      cp = GNUNET_get_installation_path (GNUNET_IPK_BINDIR);
       i = strlen (cp);
-      path = MALLOC (i + 2 + strlen ("gnunetd.exe"));
+      path = GNUNET_malloc (i + 2 + strlen ("gnunetd.exe"));
       strcpy (path, cp);
       strcat (path, "gnunetd");
 #ifdef MINGW
@@ -66,16 +66,16 @@
         }
       else
         {
-          FREE (path);
+          GNUNET_free (path);
           path = NULL;
           args[0] = "gnunetd";
         }
-      FREE (cp);
+      GNUNET_free (cp);
       if (cfgFile != NULL)
         {
           args[1] = "-c";
           args[2] = cfgFile;
-          if (NO == daemonize)
+          if (GNUNET_NO == daemonize)
             {
               args[3] = "-d";
               args[4] = NULL;
@@ -85,7 +85,7 @@
         }
       else
         {
-          if (NO == daemonize)
+          if (GNUNET_NO == daemonize)
             {
               args[1] = "-d";
               args[2] = NULL;
@@ -109,7 +109,7 @@
       else
         pid = i = spawnvp (_P_NOWAIT, "gnunetd", (const char *const *) args);
 #endif
-      FREENONNULL (path);
+      GNUNET_free_non_null (path);
       if (i == -1)
         GE_LOG_STRERROR_FILE (ectx,
                               GE_ERROR | GE_USER | GE_BULK,
@@ -128,21 +128,21 @@
       if (ret == -1)
         {
           GE_LOG_STRERROR (ectx, GE_ERROR | GE_USER | GE_BULK, "waitpid");
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       if ((WIFEXITED (status) && (0 != WEXITSTATUS (status))))
         {
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
 #ifdef WCOREDUMP
       if (WCOREDUMP (status))
         {
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
 #endif
       if (WIFSIGNALED (status) || WTERMSIG (status))
         {
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       return 0;
     }
@@ -154,14 +154,14 @@
 /**
  * Start gnunetd process
  *
- * @param daemonize YES if gnunetd should be daemonized
+ * @param daemonize GNUNET_YES if gnunetd should be daemonized
  * @return pid_t of gnunetd if NOT daemonized, 0 if
  *  daemonized sucessfully, -1 on error
  */
 int
-os_daemon_start (struct GE_Context *ectx,
-                 struct GC_Configuration *cfg,
-                 const char *cfgFile, int daemonize)
+GNUNET_daemon_start (struct GE_Context *ectx,
+                     struct GC_Configuration *cfg,
+                     const char *cfgFile, int daemonize)
 {
 #if LINUX || OSX || SOLARIS || SOMEBSD || MINGW
   return launchWithExec (ectx, cfgFile, daemonize);
@@ -210,13 +210,13 @@
  * the daemon was started with startGNUnetDaemon in no-daemonize mode.
  * On arbitrary PIDs, this function may fail unexpectedly.
  *
- * @return YES if gnunetd shutdown with
- *  return value 0, SYSERR if waitpid
- *  failed, NO if gnunetd shutdown with
+ * @return GNUNET_YES if gnunetd shutdown with
+ *  return value 0, GNUNET_SYSERR if waitpid
+ *  failed, GNUNET_NO if gnunetd shutdown with
  *  some error
  */
 int
-os_daemon_stop (struct GE_Context *ectx, int pid)
+GNUNET_daemon_stop (struct GE_Context *ectx, int pid)
 {
   pid_t p;
   int status;
@@ -226,12 +226,12 @@
   if (p != WAITPID (p, &status, 0))
     {
       GE_LOG_STRERROR (ectx, GE_ERROR | GE_USER | GE_BULK, "waitpid");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (WEXITSTATUS (status) == 0)
-    return YES;
+    return GNUNET_YES;
   else
-    return NO;
+    return GNUNET_NO;
 }
 
 /* end of daemon.c */

Modified: GNUnet/src/util/os/daemontest.c
===================================================================
--- GNUnet/src/util/os/daemontest.c     2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/os/daemontest.c     2007-11-23 11:51:54 UTC (rev 5742)
@@ -36,15 +36,15 @@
   struct GE_Context *ectx;
   struct GC_Configuration *cfg;
 
-  ectx = GE_create_context_stderr (NO,
+  ectx = GE_create_context_stderr (GNUNET_NO,
                                    GE_WARNING | GE_ERROR | GE_FATAL |
                                    GE_USER | GE_ADMIN | GE_DEVELOPER |
                                    GE_IMMEDIATE | GE_BULK);
   GE_setDefaultContext (ectx);
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   GE_ASSERT (ectx, cfg != NULL);
-  os_init (ectx);
-  daemon = os_daemon_start (ectx, cfg, "check.conf", NO);
+  GNUNET_os_init (ectx);
+  daemon = GNUNET_daemon_start (ectx, cfg, "check.conf", GNUNET_NO);
   if (daemon <= 0)
     {
       fprintf (stderr, "Failed to start daemon.\n");
@@ -52,16 +52,17 @@
       GE_free_context (ectx);
       return 1;
     }
-  if (OK != connection_wait_for_running (ectx, cfg, 30 * cronSECONDS))
+  if (GNUNET_OK !=
+      GNUNET_wait_for_daemon_running (ectx, cfg, 30 * GNUNET_CRON_SECONDS))
     {
       fprintf (stderr, "Failed to confirm daemon running (after 30s).\n");
       /* try killing anyway, just to be sure */
-      os_daemon_stop (ectx, daemon);
+      GNUNET_daemon_stop (ectx, daemon);
       GC_free (cfg);
       GE_free_context (ectx);
       return 1;
     }
-  if (OK != os_daemon_stop (ectx, daemon))
+  if (GNUNET_OK != GNUNET_daemon_stop (ectx, daemon))
     {
       fprintf (stderr, "Failed to stop daemon.\n");
       GC_free (cfg);

Modified: GNUnet/src/util/os/dso.c
===================================================================
--- GNUnet/src/util/os/dso.c    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/os/dso.c    2007-11-23 11:51:54 UTC (rev 5742)
@@ -28,7 +28,7 @@
 #include "gnunet_util_os.h"
 #include "gnunet_util_string.h"
 
-typedef struct PluginHandle
+typedef struct GNUNET_PluginHandle
 {
   struct GE_Context *ectx;
   char *libprefix;
@@ -62,24 +62,24 @@
     }
   opath = lt_dlgetsearchpath ();
   if (opath != NULL)
-    old_dlsearchpath = STRDUP (opath);
-  path = os_get_installation_path (IPK_LIBDIR);
+    old_dlsearchpath = GNUNET_strdup (opath);
+  path = GNUNET_get_installation_path (GNUNET_IPK_LIBDIR);
   if (path != NULL)
     {
       if (opath != NULL)
         {
-          cpath = MALLOC (strlen (path) + strlen (opath) + 4);
+          cpath = GNUNET_malloc (strlen (path) + strlen (opath) + 4);
           strcpy (cpath, opath);
           strcat (cpath, ":");
           strcat (cpath, path);
           lt_dlsetsearchpath (cpath);
-          FREE (path);
-          FREE (cpath);
+          GNUNET_free (path);
+          GNUNET_free (cpath);
         }
       else
         {
           lt_dlsetsearchpath (path);
-          FREE (path);
+          GNUNET_free (path);
         }
     }
 }
@@ -89,7 +89,7 @@
   lt_dlsetsearchpath (old_dlsearchpath);
   if (old_dlsearchpath != NULL)
     {
-      FREE (old_dlsearchpath);
+      GNUNET_free (old_dlsearchpath);
       old_dlsearchpath = NULL;
     }
 
@@ -100,15 +100,15 @@
   // lt_dlexit();
 }
 
-struct PluginHandle *
-os_plugin_load (struct GE_Context *ectx,
-                const char *libprefix, const char *dsoname)
+struct GNUNET_PluginHandle *
+GNUNET_plugin_load (struct GE_Context *ectx,
+                    const char *libprefix, const char *dsoname)
 {
   void *libhandle;
   char *libname;
   Plugin *plug;
 
-  libname = MALLOC (strlen (dsoname) + strlen (libprefix) + 1);
+  libname = GNUNET_malloc (strlen (dsoname) + strlen (libprefix) + 1);
   strcpy (libname, libprefix);
   strcat (libname, dsoname);
   libhandle = lt_dlopenext (libname);
@@ -118,35 +118,36 @@
               GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
               _("`%s' failed for library `%s' with error: %s\n"),
               "lt_dlopenext", libname, lt_dlerror ());
-      FREE (libname);
+      GNUNET_free (libname);
       return NULL;
     }
-  FREE (libname);
-  plug = MALLOC (sizeof (Plugin));
+  GNUNET_free (libname);
+  plug = GNUNET_malloc (sizeof (Plugin));
   plug->handle = libhandle;
-  plug->libprefix = STRDUP (libprefix);
-  plug->dsoname = STRDUP (dsoname);
+  plug->libprefix = GNUNET_strdup (libprefix);
+  plug->dsoname = GNUNET_strdup (dsoname);
   plug->ectx = ectx;
   return plug;
 }
 
 void
-os_plugin_unload (struct PluginHandle *plugin)
+GNUNET_plugin_unload (struct GNUNET_PluginHandle *plugin)
 {
   // lt_dlclose(plugin->handle);
-  FREE (plugin->libprefix);
-  FREE (plugin->dsoname);
-  FREE (plugin);
+  GNUNET_free (plugin->libprefix);
+  GNUNET_free (plugin->dsoname);
+  GNUNET_free (plugin);
 }
 
 void *
-os_plugin_resolve_function (struct PluginHandle *plug,
-                            const char *methodprefix, int logError)
+GNUNET_plugin_resolve_function (struct GNUNET_PluginHandle *plug,
+                                const char *methodprefix, int logError)
 {
   char *initName;
   void *mptr;
 
-  initName = MALLOC (strlen (plug->dsoname) + strlen (methodprefix) + 2);
+  initName =
+    GNUNET_malloc (strlen (plug->dsoname) + strlen (methodprefix) + 2);
   strcpy (initName, "_");
   strcat (initName, methodprefix);
   strcat (initName, plug->dsoname);
@@ -158,7 +159,7 @@
             GE_ERROR | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
             _("`%s' failed to resolve method '%s' with error: %s\n"),
             "lt_dlsym", &initName[1], lt_dlerror ());
-  FREE (initName);
+  GNUNET_free (initName);
   return mptr;
 }
 

Modified: GNUnet/src/util/os/init.c
===================================================================
--- GNUnet/src/util/os/init.c   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/os/init.c   2007-11-23 11:51:54 UTC (rev 5742)
@@ -30,17 +30,17 @@
 /**
  * @brief Perform OS specific initalization
  * @param ectx logging context, NULL means stderr
- * @returns OK on success, SYSERR otherwise
+ * @returns GNUNET_OK on success, GNUNET_SYSERR otherwise
  */
 int
-os_init (struct GE_Context *ectx)
+GNUNET_os_init (struct GE_Context *ectx)
 {
 #ifdef MINGW
   if (InitWinEnv (ectx) != ERROR_SUCCESS)
-    return SYSERR;
+    return GNUNET_SYSERR;
   else
 #endif
-    return OK;
+    return GNUNET_OK;
 }
 
 /**

Modified: GNUnet/src/util/os/installpath.c
===================================================================
--- GNUnet/src/util/os/installpath.c    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/os/installpath.c    2007-11-23 11:51:54 UTC (rev 5742)
@@ -54,15 +54,15 @@
   char *lnk;
   size_t size;
 
-  SNPRINTF (fn, 64, "/proc/%u/exe", getpid ());
-  lnk = MALLOC (1024);
+  GNUNET_snprintf (fn, 64, "/proc/%u/exe", getpid ());
+  lnk = GNUNET_malloc (1024);
   size = readlink (fn, lnk, 1023);
   if ((size == 0) || (size >= 1024))
     {
       GE_LOG_STRERROR_FILE (NULL,
                             GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
                             "readlink", fn);
-      FREE (lnk);
+      GNUNET_free (lnk);
       return NULL;
     }
   lnk[size] = '\0';
@@ -71,7 +71,7 @@
   if ((size < 4) || (lnk[size - 4] != '/'))
     {
       /* not installed in "/bin/" -- binary path probably useless */
-      FREE (lnk);
+      GNUNET_free (lnk);
       return NULL;
     }
   lnk[size] = '\0';
@@ -89,7 +89,7 @@
   char *path;
   char *idx;
 
-  path = MALLOC (4097);
+  path = GNUNET_malloc (4097);
   GetModuleFileName (NULL, path, 4096);
   idx = path + strlen (path);
   while ((idx > path) && (*idx != '\\') && (*idx != '/'))
@@ -123,11 +123,11 @@
       else
         {
           len++;
-          path = (char *) MALLOC (len);
+          path = (char *) GNUNET_malloc (len);
           ret = ((MyNSGetExecutablePathProto) func) (path, &len);
           if (ret != 0)
             {
-              FREE (path);
+              GNUNET_free (path);
               path = NULL;
             }
           else
@@ -155,8 +155,8 @@
   p = getenv ("PATH");
   if (p == NULL)
     return NULL;
-  path = STRDUP (p);            /* because we write on it */
-  buf = MALLOC (strlen (path) + 20);
+  path = GNUNET_strdup (p);     /* because we write on it */
+  buf = GNUNET_malloc (strlen (path) + 20);
   size = strlen (path);
   pos = path;
 
@@ -164,25 +164,25 @@
     {
       *end = '\0';
       sprintf (buf, "%s/%s", pos, "gnunetd");
-      if (disk_file_test (NULL, buf) == YES)
+      if (GNUNET_disk_file_test (NULL, buf) == GNUNET_YES)
         {
-          pos = STRDUP (pos);
-          FREE (buf);
-          FREE (path);
+          pos = GNUNET_strdup (pos);
+          GNUNET_free (buf);
+          GNUNET_free (path);
           return pos;
         }
       pos = end + 1;
     }
   sprintf (buf, "%s/%s", pos, "gnunetd");
-  if (disk_file_test (NULL, buf) == YES)
+  if (GNUNET_disk_file_test (NULL, buf) == GNUNET_YES)
     {
-      pos = STRDUP (pos);
-      FREE (buf);
-      FREE (path);
+      pos = GNUNET_strdup (pos);
+      GNUNET_free (buf);
+      GNUNET_free (path);
       return pos;
     }
-  FREE (buf);
-  FREE (path);
+  GNUNET_free (buf);
+  GNUNET_free (path);
   return NULL;
 }
 
@@ -193,7 +193,7 @@
 
   p = getenv ("GNUNET_PREFIX");
   if (p != NULL)
-    return STRDUP (p);
+    return GNUNET_strdup (p);
   return NULL;
 }
 
@@ -241,7 +241,7 @@
  * @return a pointer to the dir path (to be freed by the caller)
  */
 char *
-os_get_installation_path (enum InstallPathKind dirkind)
+GNUNET_get_installation_path (enum GNUNET_INSTALL_PATH_KIND dirkind)
 {
   size_t n;
   const char *dirname;
@@ -256,7 +256,7 @@
   if (n == 0)
     {
       /* should never happen, but better safe than sorry */
-      FREE (execpath);
+      GNUNET_free (execpath);
       return NULL;
     }
   if (execpath[n - 1] == DIR_SEPARATOR)
@@ -270,33 +270,33 @@
     }
   switch (dirkind)
     {
-    case IPK_PREFIX:
+    case GNUNET_IPK_PREFIX:
       dirname = "";
       break;
-    case IPK_BINDIR:
+    case GNUNET_IPK_BINDIR:
       dirname = DIR_SEPARATOR_STR "bin" DIR_SEPARATOR_STR;
       break;
-    case IPK_LIBDIR:
+    case GNUNET_IPK_LIBDIR:
       dirname =
         DIR_SEPARATOR_STR "lib" DIR_SEPARATOR_STR "GNUnet" DIR_SEPARATOR_STR;
       break;
-    case IPK_DATADIR:
+    case GNUNET_IPK_DATADIR:
       dirname =
         DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR "GNUnet"
         DIR_SEPARATOR_STR;
       break;
-    case IPK_LOCALEDIR:
+    case GNUNET_IPK_LOCALEDIR:
       dirname =
         DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR "locale"
         DIR_SEPARATOR_STR;
       break;
     default:
-      FREE (execpath);
+      GNUNET_free (execpath);
       return NULL;
     }
-  tmp = MALLOC (strlen (execpath) + strlen (dirname) + 1);
+  tmp = GNUNET_malloc (strlen (execpath) + strlen (dirname) + 1);
   sprintf (tmp, "%s%s", execpath, dirname);
-  FREE (execpath);
+  GNUNET_free (execpath);
   return tmp;
 }
 

Modified: GNUnet/src/util/os/osconfig.c
===================================================================
--- GNUnet/src/util/os/osconfig.c       2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/os/osconfig.c       2007-11-23 11:51:54 UTC (rev 5742)
@@ -35,8 +35,9 @@
  * @param callback the callback function
  */
 void
-os_list_network_interfaces (struct GE_Context *ectx,
-                            NetworkIfcProcessor proc, void *cls)
+GNUNET_list_network_interfaces (struct GE_Context *ectx,
+                                GNUNET_NetworkInterfaceProcessor proc,
+                                void *cls)
 {
 #ifdef MINGW
   ListNICs (proc, cls);
@@ -85,7 +86,7 @@
       *dst = 0;
 
       if ((entry[0] != '\0') &&
-          (OK != proc (entry, strcmp (entry, "eth0") == 0, cls)))
+          (GNUNET_OK != proc (entry, strcmp (entry, "eth0") == 0, cls)))
         break;
 
       while ((c != '\n') && (c != EOF))
@@ -97,13 +98,13 @@
 
 /**
  * @brief Set maximum number of open file descriptors
- * @return OK on success, SYSERR on error
+ * @return GNUNET_OK on success, GNUNET_SYSERR on error
  */
 int
-os_set_fd_limit (struct GE_Context *ectx, int n)
+GNUNET_set_fd_limit (struct GE_Context *ectx, int n)
 {
   if (n == 0)
-    return OK;
+    return GNUNET_OK;
 #if HAVE_SETRLIMIT
   struct rlimit rlim;
   int ret;
@@ -116,19 +117,19 @@
       GE_LOG_STRERROR (ectx,
                        GE_INFO | GE_USER | GE_ADMIN | GE_IMMEDIATE,
                        "setrlimit");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 #else
   GE_LOG (ectx,
           GE_INFO | GE_USER | GE_ADMIN,
           _("Setting open descriptor limit not supported.\n"));
 #endif
-  return OK;
+  return GNUNET_OK;
 }
 
 /**
  * @brief Checks if we can start GNUnet automatically
- * @return YES if yes, NO otherwise
+ * @return GNUNET_YES if yes, GNUNET_NO otherwise
  */
 static int
 isOSAutostartCapable ()
@@ -138,14 +139,14 @@
     {
       /* Debian */
       if (ACCESS ("/etc/init.d/", W_OK) == 0)
-        return YES;
+        return GNUNET_YES;
     }
-  return NO;
+  return GNUNET_NO;
 #else
 #ifdef WINDOWS
-  return IsWinNT ()? YES : NO;
+  return IsWinNT ()? GNUNET_YES : GNUNET_NO;
 #else
-  return NO;
+  return GNUNET_NO;
 #endif
 #endif
 }
@@ -153,23 +154,23 @@
 /**
  * @brief Make "application" start automatically
  *
- * @param testCapability YES to merely probe if the OS has this
+ * @param testCapability GNUNET_YES to merely probe if the OS has this
  *        functionality (in that case, no actual operation is
- *        performed).  SYSERR is returned if
+ *        performed).  GNUNET_SYSERR is returned if
  *        a) autostart is not supported,
  *        b) the application does not seem to exist
  *        c) the user or group do not exist
  *        d) the user has insufficient permissions for
  *           changing autostart
- *        e) doAutoStart is NO, but autostart is already
+ *        e) doAutoStart is GNUNET_NO, but autostart is already
  *           disabled
- *        f) doAutoStart is YES, but autostart is already
+ *        f) doAutoStart is GNUNET_YES, but autostart is already
  *           enabled
- * @param doAutoStart YES to enable autostart of the
- *        application, NO to disable it
+ * @param doAutoStart GNUNET_YES to enable autostart of the
+ *        application, GNUNET_NO to disable it
  * @param username name of the user account to use
  * @param groupname name of the group to use
- * @returns YES on success, NO if unsupported, SYSERR on failure or one of
+ * @returns GNUNET_YES on success, GNUNET_NO if unsupported, GNUNET_SYSERR on 
failure or one of
  *          these error codes:
  *  Windows
  *    2 SCM could not be opened
@@ -181,11 +182,11 @@
  *    2 startup script could not be opened
  */
 int
-os_modify_autostart (struct GE_Context *ectx,
-                     int testCapability,
-                     int doAutoStart,
-                     const char *application,
-                     const char *username, const char *groupname)
+GNUNET_configure_autostart (struct GE_Context *ectx,
+                            int testCapability,
+                            int doAutoStart,
+                            const char *application,
+                            const char *username, const char *groupname)
 {
   if (testCapability)
     {
@@ -210,7 +211,7 @@
             case 0:
               break;
             case 1:
-              return NO;
+              return GNUNET_NO;
             case 2:
               return 2;
             case 3:
@@ -218,7 +219,7 @@
                 return 3;
               break;
             default:
-              return SYSERR;
+              return GNUNET_SYSERR;
             }
 
           /* Grant permissions to the GNUnet directory */
@@ -264,7 +265,7 @@
             case 0:
               break;
             case 1:
-              return NO;
+              return GNUNET_NO;
             case 2:
               return 2;
             case 3:
@@ -272,7 +273,7 @@
             case 4:
               return 3;
             default:
-              return SYSERR;
+              return GNUNET_SYSERR;
             }
         }
       else
@@ -291,7 +292,7 @@
         }
     }
 
-  return YES;
+  return GNUNET_YES;
 #else
   struct stat buf;
   int ret;
@@ -302,7 +303,7 @@
       GE_LOG_STRERROR_FILE (ectx,
                             GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
                             "access", "/usr/sbin/update-rc.d");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 
   /* Debian */
@@ -368,7 +369,7 @@
                                     GE_WARNING | GE_USER | GE_ADMIN |
                                     GE_IMMEDIATE, "chmod",
                                     "/etc/init.d/gnunetd");
-              return SYSERR;
+              return GNUNET_SYSERR;
             }
         }
       if (STAT ("/etc/init.d/gnunetd", &buf) != -1)
@@ -392,10 +393,10 @@
                           "/usr/sbin/update-rc.d gnunetd defaults",
                           WEXITSTATUS (ret));
                 }
-              return SYSERR;
+              return GNUNET_SYSERR;
             }
         }
-      return YES;
+      return GNUNET_YES;
     }
   else
     {                           /* REMOVE autostart */
@@ -405,7 +406,7 @@
                                 GE_WARNING | GE_USER | GE_ADMIN |
                                 GE_IMMEDIATE, "unlink",
                                 "/etc/init.d/gnunetd");
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
       errno = 0;
       if (-1 != system ("/usr/sbin/update-rc.d gnunetd remove"))
@@ -414,12 +415,12 @@
                                 GE_WARNING | GE_USER | GE_ADMIN |
                                 GE_IMMEDIATE, "system",
                                 "/usr/sbin/update-rc.d");
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
-      return YES;
+      return GNUNET_YES;
     }
 #endif
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 

Modified: GNUnet/src/util/os/priority.c
===================================================================
--- GNUnet/src/util/os/priority.c       2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/os/priority.c       2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,7 +32,7 @@
  * Set our process priority
  */
 int
-os_set_process_priority (struct GE_Context *ectx, const char *str)
+GNUNET_set_process_priority (struct GE_Context *ectx, const char *str)
 {
   int prio = 0;
 
@@ -76,7 +76,7 @@
           GE_LOG (ectx,
                   GE_USER | GE_BULK | GE_ERROR,
                   _("Invalid process priority `%s'\n"), str);
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
 
 #ifdef MINGW
@@ -103,8 +103,8 @@
   if (errno != 0)
     {
       GE_LOG_STRERROR (ectx, GE_WARNING | GE_ADMIN | GE_BULK, "nice");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
 #endif
-  return OK;
+  return GNUNET_OK;
 }

Modified: GNUnet/src/util/os/semaphore.c
===================================================================
--- GNUnet/src/util/os/semaphore.c      2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/os/semaphore.c      2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,7 +32,7 @@
 #include "gnunet_util_disk.h"
 #include "platform.h"
 
-#if SOLARIS || FREEBSD || OSX
+#if SOLARIS || GNUNET_freeBSD || OSX
 #include <semaphore.h>
 #endif
 #if SOMEBSD
@@ -52,10 +52,10 @@
  */
 #define USE_CHECKING_MUTEX 1
 
-typedef struct IPC_SEMAPHORE
+typedef struct GNUNET_IPC_Semaphore
 {
   struct GE_Context *ectx;
-#if SOLARIS || FREEBSD5 || OSX
+#if SOLARIS || GNUNET_freeBSD5 || OSX
   sem_t *internal;
 #elif WINDOWS
   HANDLE internal;
@@ -65,7 +65,7 @@
 #elif SOMEBSD
   int initialValue;
   int fd;
-  struct MUTEX *internalLock;
+  struct GNUNET_Mutex *internalLock;
   char *filename;
 #elif _MSC_VER
   int internal;                 /* KLB_FIX */
@@ -146,19 +146,20 @@
 }
 #endif
 
-struct IPC_SEMAPHORE *
-IPC_SEMAPHORE_CREATE (struct GE_Context *ectx,
-                      const char *basename, const unsigned int initialValue)
+struct GNUNET_IPC_Semaphore *
+GNUNET_IPC_semaphore_create (struct GE_Context *ectx,
+                             const char *basename,
+                             const unsigned int initialValue)
 {
   /* Could older FreeBSD use this too since this code can shorten the IPC name 
*/
-#if SOLARIS || OSX || FREEBSD5
+#if SOLARIS || OSX || GNUNET_freeBSD5
   char *noslashBasename;
   int i;
-  struct IPC_SEMAPHORE *ret;
+  struct GNUNET_IPC_Semaphore *ret;
 
-  ret = MALLOC (sizeof (struct IPC_SEMAPHORE));
+  ret = GNUNET_malloc (sizeof (struct GNUNET_IPC_Semaphore));
   ret->ectx = ectx;
-  noslashBasename = string_expandFileName (ectx, basename);
+  noslashBasename = GNUNET_expand_file_name (ectx, basename);
   for (i = strlen (noslashBasename); i > 0; i--)
     if (noslashBasename[i] == '/')
       noslashBasename[i] = '.'; /* first character MUST be /, but Solaris
@@ -182,18 +183,18 @@
     GE_DIE_STRERROR_FILE (ectx,
                           GE_FATAL | GE_USER | GE_DEVELOPER | GE_IMMEDIATE,
                           "sem_open", noslashBasename);
-  FREE (noslashBasename);
+  GNUNET_free (noslashBasename);
   return ret;
 #elif WINDOWS
   char *noslashBasename;
   int i;
-  struct IPC_SEMAPHORE *ret;
+  struct GNUNET_IPC_Semaphore *ret;
   SECURITY_ATTRIBUTES sec;
   DWORD dwErr;
 
-  ret = MALLOC (sizeof (struct IPC_SEMAPHORE));
+  ret = GNUNET_malloc (sizeof (struct GNUNET_IPC_Semaphore));
   ret->ectx = ectx;
-  noslashBasename = string_expandFileName (ectx, basename);
+  noslashBasename = GNUNET_expand_file_name (ectx, basename);
   for (i = strlen (noslashBasename); i > 0; i--)
     if (noslashBasename[i] == '\\')
       noslashBasename[i] = '.'; /* must not contain backslashes */
@@ -220,7 +221,7 @@
                             GE_FATAL | GE_USER | GE_DEVELOPER | GE_BULK,
                             "OpenSemaphore", noslashBasename);
     }
-  FREE (noslashBasename);
+  GNUNET_free (noslashBasename);
   return ret;
 #elif LINUX
   union semun
@@ -229,23 +230,23 @@
     struct semid_ds *buf;
     ushort *array;
   } semctl_arg;
-  struct IPC_SEMAPHORE *ret;
+  struct GNUNET_IPC_Semaphore *ret;
   key_t key;
   FILE *fp;
   int pcount;
   char *ebasename;
 
-  ret = MALLOC (sizeof (struct IPC_SEMAPHORE));
+  ret = GNUNET_malloc (sizeof (struct GNUNET_IPC_Semaphore));
   ret->ectx = ectx;
-  ebasename = string_expandFileName (ectx, basename);
-  disk_directory_create_for_file (ectx, ebasename);
+  ebasename = GNUNET_expand_file_name (ectx, basename);
+  GNUNET_disk_directory_create_for_file (ectx, ebasename);
   fp = FOPEN (ebasename, "a+");
   if (NULL == fp)
     {
       GE_LOG_STRERROR_FILE (ectx,
                             GE_ERROR | GE_USER | GE_BULK, "fopen", ebasename);
-      FREE (ret);
-      FREE (ebasename);
+      GNUNET_free (ret);
+      GNUNET_free (ebasename);
       return NULL;
     }
   fclose (fp);
@@ -287,24 +288,25 @@
 #elif SOMEBSD
   int fd;
   int cnt;
-  struct IPC_SEMAPHORE *ret;
+  struct GNUNET_IPC_Semaphore *ret;
 
-  ret = MALLOC (sizeof (struct IPC_SEMAPHORE));
+  ret = GNUNET_malloc (sizeof (struct GNUNET_IPC_Semaphore));
   ret->ectx = ectx;
 
-  MUTEX_CREATE (&ret->internalLock);
-  ret->filename = STRDUP (basename);
+  GNUNET_mutex_create (&ret->internalLock);
+  ret->filename = GNUNET_strdup (basename);
   fd = -1;
   while (fd == -1)
     {
-      fd = disk_file_open (ectx,
-                           basename,
-                           O_CREAT | O_RDWR | O_EXCL,
-                           S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP /* 660 */ );
+      fd = GNUNET_disk_file_open (ectx,
+                                  basename,
+                                  O_CREAT | O_RDWR | O_EXCL,
+                                  S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
+                                  /* 660 */ );
       if ((fd == -1) && (errno == EEXIST))
         {
           /* try without creation */
-          fd = disk_file_open (ectx, basename, O_RDWR, S_IRUSR | S_IWUSR | 
S_IRGRP | S_IWGRP    /* 660 */
+          fd = GNUNET_disk_file_open (ectx, basename, O_RDWR, S_IRUSR | 
S_IWUSR | S_IRGRP | S_IWGRP     /* 660 */
             );
           /* possibly the file was deleted in the meantime,
              then try again with O_CREAT! */
@@ -317,9 +319,9 @@
       GE_LOG_STRERROR_FILE (ectx,
                             GE_ERROR | GE_USER | GE_BULK,
                             "open", ret->filename);
-      MUTEX_DESTROY (&ret->internalLock);
-      FREE (ret->filename);
-      FREE (ret);
+      GNUNET_mutex_destroy (&ret->internalLock);
+      GNUNET_free (ret->filename);
+      GNUNET_free (ret);
       return NULL;
     }
   FLOCK (fd, LOCK_EX);
@@ -356,11 +358,11 @@
 }
 
 void
-IPC_SEMAPHORE_UP (struct IPC_SEMAPHORE *sem)
+GNUNET_IPC_semaphore_up (struct GNUNET_IPC_Semaphore *sem)
 {
   if (sem == NULL)              /* error on creation, optimistic execution; 
good luck */
     return;
-#if SOLARIS || OSX || FREEBSD5
+#if SOLARIS || OSX || GNUNET_freeBSD5
   if (0 != sem_post (sem->internal))
     GE_LOG_STRERROR (sem->ectx, GE_WARNING | GE_USER | GE_BULK, "sem_post");
 #elif WINDOWS
@@ -378,7 +380,7 @@
   {
     int cnt;
 
-    MUTEX_LOCK (&sem->internalLock);
+    GNUNET_mutex_lock (&sem->internalLock);
     FLOCK (sem->fd, LOCK_EX);
     SEMA_LSEEK (sem->fd, 0, SEEK_SET);
     if (sizeof (int) != READ (sem->fd, &cnt, sizeof (int)))
@@ -387,7 +389,7 @@
                               GE_WARNING | GE_USER | GE_BULK,
                               "read", sem->filename);
         FLOCK (sem->fd, LOCK_UN);
-        MUTEX_UNLOCK (&sem->internalLock);
+        GNUNET_mutex_unlock (&sem->internalLock);
         return;
       }
     cnt = htonl (ntohl (cnt) + 1);
@@ -397,18 +399,18 @@
                             GE_WARNING | GE_USER | GE_BULK,
                             "write", sem->filename);
     FLOCK (sem->fd, LOCK_UN);
-    MUTEX_UNLOCK (&sem->internalLock);
+    GNUNET_mutex_unlock (&sem->internalLock);
   }
 #endif
 }
 
 /* FIXME: add support for mayBlock! */
 int
-IPC_SEMAPHORE_DOWN (struct IPC_SEMAPHORE *sem, int mayBlock)
+GNUNET_IPC_semaphore_down (struct GNUNET_IPC_Semaphore *sem, int mayBlock)
 {
   if (sem == NULL)              /* error on creation, optimistic execution; 
good luck */
-    return OK;
-#if OSX || SOLARIS || FREEBSD5
+    return GNUNET_OK;
+#if OSX || SOLARIS || GNUNET_freeBSD5
   while (0 != sem_wait (sem->internal))
     {
       if ((errno == EINTR) || (errno == EAGAIN))
@@ -416,12 +418,12 @@
       GE_DIE_STRERROR (sem->ectx,
                        GE_FATAL | GE_USER | GE_IMMEDIATE, "sem_wait");
     }
-  return OK;
+  return GNUNET_OK;
 #elif WINDOWS
   if (WaitForSingleObject (sem->internal, INFINITE) == WAIT_FAILED)
     GE_LOG_STRERROR (sem->ectx,
                      GE_WARNING | GE_USER | GE_BULK, "WaitForSingleObject");
-  return OK;
+  return GNUNET_OK;
 #elif LINUX
   {
     struct sembuf sops = { 0, -1, SEM_UNDO };
@@ -433,13 +435,13 @@
         GE_DIE_STRERROR (sem->ectx,
                          GE_FATAL | GE_USER | GE_IMMEDIATE, "semop");
       }
-    return OK;
+    return GNUNET_OK;
   }
 #elif SOMEBSD
   {
     int cnt;
 
-    MUTEX_LOCK (&sem->internalLock);
+    GNUNET_mutex_lock (&sem->internalLock);
     FLOCK (sem->fd, LOCK_EX);
     cnt = ntohl (0);
     while (htonl (cnt) == 0)
@@ -451,14 +453,14 @@
                                   GE_WARNING | GE_USER | GE_BULK,
                                   "read", sem->filename);
             FLOCK (sem->fd, LOCK_UN);
-            MUTEX_UNLOCK (&sem->internalLock);
-            return SYSERR;
+            GNUNET_mutex_unlock (&sem->internalLock);
+            return GNUNET_SYSERR;
           }
         if (htonl (cnt) == 0)
           {
             /* busy wait! */
             FLOCK (sem->fd, LOCK_UN);
-            PTHREAD_SLEEP (50 * cronMILLIS);
+            GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
             FLOCK (sem->fd, LOCK_EX);
           }
       }
@@ -470,20 +472,20 @@
                             GE_WARNING | GE_USER | GE_BULK,
                             "write", sem->filename);
     FLOCK (sem->fd, LOCK_UN);
-    MUTEX_UNLOCK (&sem->internalLock);
+    GNUNET_mutex_unlock (&sem->internalLock);
   }
-  return OK;
+  return GNUNET_OK;
 #else
-  return OK;
+  return GNUNET_OK;
 #endif
 }
 
 void
-IPC_SEMAPHORE_DESTROY (struct IPC_SEMAPHORE *sem)
+GNUNET_IPC_semaphore_destroy (struct GNUNET_IPC_Semaphore *sem)
 {
   if (sem == NULL)              /* error on creation, optimistic execution; 
good luck */
     return;
-#if SOLARIS || OSX || FREEBSD5
+#if SOLARIS || OSX || GNUNET_freeBSD5
   if (0 != sem_close (sem->internal))
     GE_LOG_STRERROR (sem->ectx, GE_USER | GE_WARNING | GE_BULK, "sem_close");
 #elif WINDOWS
@@ -516,13 +518,13 @@
           GE_LOG_STRERROR (sem->ectx,
                            GE_USER | GE_WARNING | GE_BULK, "semop");
       }
-    FREE (sem->filename);
+    GNUNET_free (sem->filename);
   }
 #elif SOMEBSD
   {
     int cnt;
 
-    MUTEX_DESTROY (&sem->internalLock);
+    GNUNET_mutex_destroy (&sem->internalLock);
     FLOCK (sem->fd, LOCK_EX);
     SEMA_LSEEK (sem->fd, sizeof (int), SEEK_SET);
     if (sizeof (int) == READ (sem->fd, &cnt, sizeof (int)))
@@ -538,12 +540,12 @@
     else
       GE_LOG_STRERROR (sem->ectx, GE_WARNING | GE_USER | GE_BULK, "read");
     FLOCK (sem->fd, LOCK_UN);
-    disk_file_close (sem->ectx, sem->filename, sem->fd);
-    FREE (sem->filename);
+    GNUNET_disk_file_close (sem->ectx, sem->filename, sem->fd);
+    GNUNET_free (sem->filename);
   }
 #else
 #endif
-  FREE (sem);
+  GNUNET_free (sem);
 }
 
 

Modified: GNUnet/src/util/os/semaphoretest.c
===================================================================
--- GNUnet/src/util/os/semaphoretest.c  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/os/semaphoretest.c  2007-11-23 11:51:54 UTC (rev 5742)
@@ -28,7 +28,7 @@
 
 #include <sys/types.h>
 
-static struct IPC_SEMAPHORE *ipc;
+static struct GNUNET_IPC_Semaphore *ipc;
 
 static struct GE_Context *ectx;
 
@@ -50,14 +50,14 @@
   me = fork ();
   sw = me;
 
-  ipc = IPC_SEMAPHORE_CREATE (ectx, "/tmp/gnunet_ipc_semtest", 0);
+  ipc = GNUNET_IPC_semaphore_create (ectx, "/tmp/gnunet_ipc_semtest", 0);
   for (cnt = 0; cnt < 3; cnt++)
     {
       if (sw == 0)
         {
           for (i = 0; i < 6; i++)
             {
-              IPC_SEMAPHORE_DOWN (ipc, YES);
+              GNUNET_IPC_semaphore_down (ipc, GNUNET_YES);
               fd = FOPEN ("/tmp/gnunet_ipc_xchange", "a+");
               if (fd == NULL)
                 {
@@ -93,7 +93,7 @@
         {
           for (i = 0; i < 6; i++)
             {
-              PTHREAD_SLEEP (50 + i * 50);
+              GNUNET_thread_sleep (50 + i * 50);
               fd = FOPEN ("/tmp/gnunet_ipc_xchange", "a+");
               if (fd == NULL)
                 {
@@ -112,7 +112,7 @@
                   goto END;
                 }
               fclose (fd);
-              IPC_SEMAPHORE_UP (ipc);
+              GNUNET_IPC_semaphore_up (ipc);
             }
           fprintf (stderr, ".");
           sleep (1);            /* give reader ample time to finish */
@@ -120,7 +120,7 @@
         }
     }
 END:
-  IPC_SEMAPHORE_DESTROY (ipc);
+  GNUNET_IPC_semaphore_destroy (ipc);
   REMOVE ("/tmp/gnunet_ipc_xchange");
   if (me == 0)
     {
@@ -146,12 +146,12 @@
 {
   int ret = 0;
 
-  ectx = GE_create_context_stderr (NO,
+  ectx = GE_create_context_stderr (GNUNET_NO,
                                    GE_WARNING | GE_ERROR | GE_FATAL |
                                    GE_USER | GE_ADMIN | GE_DEVELOPER |
                                    GE_IMMEDIATE | GE_BULK);
   GE_setDefaultContext (ectx);
-  os_init (ectx);
+  GNUNET_os_init (ectx);
   ret += testIPCSemaphore ();
   fprintf (stderr, "\n");
   GE_free_context (ectx);

Modified: GNUnet/src/util/os/statuscalls.c
===================================================================
--- GNUnet/src/util/os/statuscalls.c    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/os/statuscalls.c    2007-11-23 11:51:54 UTC (rev 5742)
@@ -56,7 +56,7 @@
 #include <net/if.h>
 #include <net/if_mib.h>
 #endif
-#define DEBUG_STATUSCALLS NO
+#define DEBUG_STATUSCALLS GNUNET_NO
 
 /**
  * where to read network interface information from
@@ -80,13 +80,13 @@
 
   unsigned long long lastSum;
 
-  cron_t lastCall;
+  GNUNET_CronTime lastCall;
 
   int lastValue;
 
   /**
    * Can we compute statistics (because we have a previous
-   * value)?  YES or NO.
+   * value)?  GNUNET_YES or GNUNET_NO.
    */
   int have_last;
 
@@ -97,7 +97,7 @@
 
 } DirectionInfo;
 
-typedef struct LoadMonitor
+typedef struct GNUNET_LoadMonitor
 {
 
   /**
@@ -116,8 +116,8 @@
   unsigned int ifcsSize;
 
   /**
-   * How to measure traffic (YES == only gnunetd,
-   * NO == try to include all apps)
+   * How to measure traffic (GNUNET_YES == only gnunetd,
+   * GNUNET_NO == try to include all apps)
    */
   int useBasicMethod;
 
@@ -128,7 +128,7 @@
   /**
    * Lock.
    */
-  struct MUTEX *statusMutex;
+  struct GNUNET_Mutex *statusMutex;
 
   struct GE_Context *ectx;
 
@@ -138,27 +138,28 @@
 
   DirectionInfo download_info;
 
-  cron_t last_ifc_update;
+  GNUNET_CronTime last_ifc_update;
 
 } LoadMonitor;
 
 void
-os_network_monitor_notify_transmission (struct LoadMonitor *monitor,
-                                        NetworkDirection dir,
-                                        unsigned long long delta)
+GNUNET_network_monitor_notify_transmission (struct GNUNET_LoadMonitor
+                                            *monitor,
+                                            GNUNET_NETWORK_DIRECTION dir,
+                                            unsigned long long delta)
 {
-  MUTEX_LOCK (monitor->statusMutex);
-  if (dir == Download)
+  GNUNET_mutex_lock (monitor->statusMutex);
+  if (dir == GNUNET_ND_DOWNLOAD)
     monitor->globalTrafficBetweenProc.last_in += delta;
   else
     monitor->globalTrafficBetweenProc.last_out += delta;
-  MUTEX_UNLOCK (monitor->statusMutex);
+  GNUNET_mutex_unlock (monitor->statusMutex);
 }
 
 #define MAX_PROC_LINE 5000
 
 static void
-updateInterfaceTraffic (struct LoadMonitor *monitor)
+updateInterfaceTraffic (struct GNUNET_LoadMonitor *monitor)
 {
 #ifdef LINUX
   unsigned long long rxnew;
@@ -354,7 +355,7 @@
                   struct GC_Configuration *cfg,
                   struct GE_Context *ectx, const char *sect, const char *op)
 {
-  struct LoadMonitor *monitor = cls;
+  struct GNUNET_LoadMonitor *monitor = cls;
   char *interfaces;
   int i;
   int numInterfaces;
@@ -363,14 +364,15 @@
   if (0 != strcmp (sect, "LOAD"))
     return 0;                   /* fast path */
   basic = GC_get_configuration_value_yesno (cfg,
-                                            "LOAD", "BASICLIMITING", YES);
-  if (basic == SYSERR)
-    return SYSERR;
+                                            "LOAD", "BASICLIMITING",
+                                            GNUNET_YES);
+  if (basic == GNUNET_SYSERR)
+    return GNUNET_SYSERR;
   if (-1 == GC_get_configuration_value_string (cfg,
                                                "LOAD",
                                                "INTERFACES",
                                                "eth0", &interfaces))
-    return SYSERR;
+    return GNUNET_SYSERR;
   if (interfaces == NULL)
     {
       GE_LOG (ectx,
@@ -378,49 +380,50 @@
               _
               ("No network interfaces defined in configuration section `%s' 
under `%s'!\n"),
               "LOAD", "INTERFACES");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if (strlen (interfaces) == 0)
     {
-      FREE (interfaces);
+      GNUNET_free (interfaces);
       GE_LOG (ectx,
               GE_ERROR | GE_USER | GE_BULK,
               _
               ("No network interfaces defined in configuration section `%s' 
under `%s'!\n"),
               "LOAD", "INTERFACES");
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
-  MUTEX_LOCK (monitor->statusMutex);
+  GNUNET_mutex_lock (monitor->statusMutex);
   for (i = 0; i < monitor->ifcsSize; i++)
-    FREE (monitor->ifcs[i].name);
+    GNUNET_free (monitor->ifcs[i].name);
   numInterfaces = 1;
   for (i = strlen (interfaces) - 1; i >= 0; i--)
     if (interfaces[i] == ',')
       numInterfaces++;
-  GROW (monitor->ifcs, monitor->ifcsSize, numInterfaces);
+  GNUNET_array_grow (monitor->ifcs, monitor->ifcsSize, numInterfaces);
   for (i = strlen (interfaces) - 1; i >= 0; i--)
     {
       if (interfaces[i] == ',')
         {
-          monitor->ifcs[--numInterfaces].name = STRDUP (&interfaces[i + 1]);
+          monitor->ifcs[--numInterfaces].name =
+            GNUNET_strdup (&interfaces[i + 1]);
           numInterfaces++;
           interfaces[i] = '\0';
         }
     }
-  monitor->ifcs[--numInterfaces].name = STRDUP (interfaces);
+  monitor->ifcs[--numInterfaces].name = GNUNET_strdup (interfaces);
   GE_ASSERT (ectx, numInterfaces == 0);
   for (i = 0; i < monitor->ifcsSize; i++)
     {
       monitor->ifcs[i].last_in = 0;
       monitor->ifcs[i].last_out = 0;
     }
-  monitor->upload_info.have_last = NO;
+  monitor->upload_info.have_last = GNUNET_NO;
   monitor->upload_info.lastCall = 0;
   monitor->upload_info.overload = 0;
-  monitor->download_info.have_last = NO;
+  monitor->download_info.have_last = GNUNET_NO;
   monitor->download_info.lastCall = 0;
   monitor->download_info.overload = 0;
-  FREE (interfaces);
+  GNUNET_free (interfaces);
   monitor->useBasicMethod = basic;
   GC_get_configuration_value_number (cfg,
                                      "LOAD",
@@ -434,9 +437,9 @@
                                      0,
                                      (unsigned long long) -1,
                                      50000, &monitor->upload_info.max);
-  monitor->last_ifc_update = get_time ();
+  monitor->last_ifc_update = GNUNET_get_time ();
   updateInterfaceTraffic (monitor);
-  MUTEX_UNLOCK (monitor->statusMutex);
+  GNUNET_mutex_unlock (monitor->statusMutex);
   return 0;
 }
 
@@ -447,19 +450,19 @@
  * @return the maximum bandwidth in bytes per second, -1 for no limit
  */
 unsigned long long
-os_network_monitor_get_limit (struct LoadMonitor *monitor,
-                              NetworkDirection dir)
+GNUNET_network_monitor_get_limit (struct GNUNET_LoadMonitor *monitor,
+                                  GNUNET_NETWORK_DIRECTION dir)
 {
   if (monitor == NULL)
     return -1;
-  if (dir == Upload)
+  if (dir == GNUNET_ND_UPLOAD)
     return monitor->upload_info.max;
-  else if (dir == Download)
+  else if (dir == GNUNET_ND_DOWNLOAD)
     return monitor->download_info.max;
   return -1;
 }
 
-#define INCREMENTAL_INTERVAL (60 * cronSECONDS)
+#define INCREMENTAL_INTERVAL (60 * GNUNET_CRON_SECONDS)
 
 /**
  * Get the load of the network relative to what is allowed.
@@ -467,11 +470,11 @@
  *        (100 is equivalent to full load)
  */
 int
-os_network_monitor_get_load (struct LoadMonitor *monitor,
-                             NetworkDirection dir)
+GNUNET_network_monitor_get_load (struct GNUNET_LoadMonitor *monitor,
+                                 GNUNET_NETWORK_DIRECTION dir)
 {
   DirectionInfo *di;
-  cron_t now;
+  GNUNET_CronTime now;
   unsigned long long maxExpect;
   unsigned long long currentLoadSum;
   unsigned long long currentTotal;
@@ -481,20 +484,20 @@
 
   if (monitor == NULL)
     return 0;                   /* no limits */
-  if (dir == Upload)
+  if (dir == GNUNET_ND_UPLOAD)
     di = &monitor->upload_info;
   else
     di = &monitor->download_info;
 
-  MUTEX_LOCK (monitor->statusMutex);
-  now = get_time ();
-  if ((monitor->useBasicMethod == NO) &&
-      (now - monitor->last_ifc_update > 10 * cronSECONDS))
+  GNUNET_mutex_lock (monitor->statusMutex);
+  now = GNUNET_get_time ();
+  if ((monitor->useBasicMethod == GNUNET_NO) &&
+      (now - monitor->last_ifc_update > 10 * GNUNET_CRON_SECONDS))
     {
       monitor->last_ifc_update = now;
       updateInterfaceTraffic (monitor);
     }
-  if (dir == Upload)
+  if (dir == GNUNET_ND_UPLOAD)
     {
       currentTotal = monitor->globalTrafficBetweenProc.last_out;
       for (i = 0; i < monitor->ifcsSize; i++)
@@ -507,24 +510,24 @@
         currentTotal += monitor->ifcs[i].last_in;
     }
   if ((di->lastSum > currentTotal) ||
-      (di->have_last == NO) || (now < di->lastCall))
+      (di->have_last == GNUNET_NO) || (now < di->lastCall))
     {
       /* integer overflow or first datapoint; since we cannot tell where
          / by how much the overflow happened, all we can do is ignore
          this datapoint.  So we return -1 -- AND reset lastSum / lastCall. */
       di->lastSum = currentTotal;
       di->lastCall = now;
-      di->have_last = YES;
-      MUTEX_UNLOCK (monitor->statusMutex);
+      di->have_last = GNUNET_YES;
+      GNUNET_mutex_unlock (monitor->statusMutex);
       return -1;
     }
   if (di->max == 0)
     {
-      MUTEX_UNLOCK (monitor->statusMutex);
+      GNUNET_mutex_unlock (monitor->statusMutex);
       return -1;
     }
 
-  maxExpect = (now - di->lastCall) * di->max / cronSECONDS;
+  maxExpect = (now - di->lastCall) * di->max / GNUNET_CRON_SECONDS;
   if (now - di->lastCall < INCREMENTAL_INTERVAL)
     {
       /* return weighted average between last return value and
@@ -538,7 +541,7 @@
                                                            di->lastSum +
                                                            di->overload) /
           maxExpect;
-      MUTEX_UNLOCK (monitor->statusMutex);
+      GNUNET_mutex_unlock (monitor->statusMutex);
       return ret;
     }
 
@@ -551,18 +554,18 @@
     di->overload = currentLoadSum - maxExpect;
   ret = currentLoadSum * 100 / maxExpect;
   di->lastValue = ret;
-  MUTEX_UNLOCK (monitor->statusMutex);
+  GNUNET_mutex_unlock (monitor->statusMutex);
   return ret;
 }
 
-struct LoadMonitor *
-os_network_monitor_create (struct GE_Context *ectx,
-                           struct GC_Configuration *cfg)
+struct GNUNET_LoadMonitor *
+GNUNET_network_monitor_create (struct GE_Context *ectx,
+                               struct GC_Configuration *cfg)
 {
-  struct LoadMonitor *monitor;
+  struct GNUNET_LoadMonitor *monitor;
 
-  monitor = MALLOC (sizeof (struct LoadMonitor));
-  memset (monitor, 0, sizeof (struct LoadMonitor));
+  monitor = GNUNET_malloc (sizeof (struct GNUNET_LoadMonitor));
+  memset (monitor, 0, sizeof (struct GNUNET_LoadMonitor));
   monitor->ectx = ectx;
   monitor->cfg = cfg;
 #ifdef LINUX
@@ -572,17 +575,17 @@
                           GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
                           "fopen", PROC_NET_DEV);
 #endif
-  monitor->statusMutex = MUTEX_CREATE (NO);
+  monitor->statusMutex = GNUNET_mutex_create (GNUNET_NO);
   if (-1 == GC_attach_change_listener (cfg, &resetStatusCalls, monitor))
     {
-      os_network_monitor_destroy (monitor);
+      GNUNET_network_monitor_destroy (monitor);
       return NULL;
     }
   return monitor;
 }
 
 void
-os_network_monitor_destroy (struct LoadMonitor *monitor)
+GNUNET_network_monitor_destroy (struct GNUNET_LoadMonitor *monitor)
 {
   int i;
 
@@ -592,10 +595,10 @@
     fclose (monitor->proc_net_dev);
 #endif
   for (i = 0; i < monitor->ifcsSize; i++)
-    FREE (monitor->ifcs[i].name);
-  GROW (monitor->ifcs, monitor->ifcsSize, 0);
-  MUTEX_DESTROY (monitor->statusMutex);
-  FREE (monitor);
+    GNUNET_free (monitor->ifcs[i].name);
+  GNUNET_array_grow (monitor->ifcs, monitor->ifcsSize, 0);
+  GNUNET_mutex_destroy (monitor->statusMutex);
+  GNUNET_free (monitor);
 }
 
 /* end of statuscalls.c */

Modified: GNUnet/src/util/os/statuscallstest.c
===================================================================
--- GNUnet/src/util/os/statuscallstest.c        2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/os/statuscallstest.c        2007-11-23 11:51:54 UTC (rev 
5742)
@@ -32,31 +32,31 @@
 {
   static long k;
   int ret;
-  cron_t start;
+  GNUNET_CronTime start;
   struct GE_Context *ectx;
   struct GC_Configuration *cfg;
 
-  ectx = GE_create_context_stderr (NO,
+  ectx = GE_create_context_stderr (GNUNET_NO,
                                    GE_WARNING | GE_ERROR | GE_FATAL |
                                    GE_USER | GE_ADMIN | GE_DEVELOPER |
                                    GE_IMMEDIATE | GE_BULK);
   GE_setDefaultContext (ectx);
-  cfg = GC_create_C_impl ();
+  cfg = GC_create ();
   GE_ASSERT (ectx, cfg != NULL);
-  os_init (ectx);
+  GNUNET_os_init (ectx);
   /* need to run each phase for more than 10s since
      statuscalls only refreshes that often... */
-  start = get_time ();
-  while (start + 12 * cronSECONDS > get_time ())
-    PTHREAD_SLEEP (1);
-  start = get_time ();
-  ret = os_cpu_get_load (ectx, cfg);
-  while (start + 60 * cronSECONDS > get_time ())
+  start = GNUNET_get_time ();
+  while (start + 12 * GNUNET_CRON_SECONDS > GNUNET_get_time ())
+    GNUNET_thread_sleep (1);
+  start = GNUNET_get_time ();
+  ret = GNUNET_cpu_get_load (ectx, cfg);
+  while (start + 60 * GNUNET_CRON_SECONDS > GNUNET_get_time ())
     k++;                        /* do some processing to drive load up */
-  if (ret > os_cpu_get_load (ectx, cfg))
+  if (ret > GNUNET_cpu_get_load (ectx, cfg))
     {
       printf ("busy loop decreased CPU load: %d < %d.\n",
-              ret, os_cpu_get_load (ectx, cfg));
+              ret, GNUNET_cpu_get_load (ectx, cfg));
       ret = 1;
     }
   else

Modified: GNUnet/src/util/os/time.c
===================================================================
--- GNUnet/src/util/os/time.c   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/os/time.c   2007-11-23 11:51:54 UTC (rev 5742)
@@ -29,14 +29,14 @@
 #include "gnunet_util_string.h"
 
 /**
- * TIME prototype. "man time".
+ * GNUNET_get_time_int32 prototype. "man time".
  */
-TIME_T
-TIME (TIME_T * t)
+GNUNET_Int32Time
+GNUNET_get_time_int32 (GNUNET_Int32Time * t)
 {
-  TIME_T now;
+  GNUNET_Int32Time now;
 
-  now = (TIME_T) time (NULL);   /* potential 64-bit to 32-bit conversion! */
+  now = (GNUNET_Int32Time) time (NULL); /* potential 64-bit to 32-bit 
conversion! */
   if (t != NULL)
     *t = now;
   return now;
@@ -48,17 +48,17 @@
  * epoc if needed.
  */
 char *
-GN_CTIME (const TIME_T * t)
+GNUNET_int32_time_to_string (const GNUNET_Int32Time * t)
 {
-  TIME_T now;
+  GNUNET_Int32Time now;
   time_t tnow;
 
   tnow = time (NULL);
-  now = (TIME_T) tnow;
+  now = (GNUNET_Int32Time) tnow;
   tnow = tnow - now + *t;
 #ifdef ctime_r
-  return ctime_r (&tnow, MALLOC (32));
+  return ctime_r (&tnow, GNUNET_malloc (32));
 #else
-  return STRDUP (ctime (&tnow));
+  return GNUNET_strdup (ctime (&tnow));
 #endif
 }

Modified: GNUnet/src/util/os/user.c
===================================================================
--- GNUnet/src/util/os/user.c   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/os/user.c   2007-11-23 11:51:54 UTC (rev 5742)
@@ -29,8 +29,9 @@
 #include "platform.h"
 
 int
-os_modify_user (int testCapability,
-                int doAdd, const char *group_name, const char *user_name)
+GNUNET_configure_user_account (int testCapability,
+                               int doAdd, const char *group_name,
+                               const char *user_name)
 {
   int haveGroup;
 
@@ -39,38 +40,38 @@
       /* TODO: actually check that group/user
          exists/does not yet exist */
 #ifdef WINDOWS
-      return IsWinNT ()? OK : SYSERR;
+      return IsWinNT ()? GNUNET_OK : GNUNET_SYSERR;
 #endif
 #ifdef LINUX
       if (geteuid () != 0)
-        return SYSERR;
-      if (doAdd == YES)
+        return GNUNET_SYSERR;
+      if (doAdd == GNUNET_YES)
         {
           if (((ACCESS ("/usr/sbin/adduser", X_OK) == 0) ||
                (ACCESS ("/usr/sbin/useradd", X_OK) == 0)) &&
               ((ACCESS ("/usr/sbin/addgroup", X_OK) == 0) ||
                (ACCESS ("/usr/sbin/groupadd", X_OK) == 0)))
-            return OK;
-          return SYSERR;
+            return GNUNET_OK;
+          return GNUNET_SYSERR;
         }
-      else if (doAdd == NO)
+      else if (doAdd == GNUNET_NO)
         {
           if ((ACCESS ("/usr/sbin/deluser", X_OK) == 0) ||
               (ACCESS ("/usr/sbin/userdel", X_OK) == 0))
-            return OK;
-          return SYSERR;
+            return GNUNET_OK;
+          return GNUNET_SYSERR;
         }
-      else if (doAdd == SYSERR)
+      else if (doAdd == GNUNET_SYSERR)
         {
           if (((ACCESS ("/usr/sbin/dleuser", X_OK) == 0) ||
                (ACCESS ("/usr/sbin/userdel", X_OK) == 0)) &&
               ((ACCESS ("/usr/sbin/delgroup", X_OK) == 0) ||
                (ACCESS ("/usr/sbin/groupdel", X_OK) == 0)))
-            return OK;
-          return SYSERR;
+            return GNUNET_OK;
+          return GNUNET_SYSERR;
         }
 #endif
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if ((user_name == NULL) || (0 == strlen (user_name)))
     return 0;
@@ -79,7 +80,7 @@
   if (IsWinNT ())
     return CreateServiceAccount (user_name, "GNUnet service account");
 #elif OSX
-  return SYSERR;                /* TODO */
+  return GNUNET_SYSERR;         /* TODO */
 #else
   if (ACCESS ("/usr/sbin/adduser", X_OK) == 0)
     {
@@ -89,8 +90,8 @@
 
       haveGroup = group_name && strlen (group_name) > 0;
       cmd =
-        MALLOC (256 + (haveGroup ? strlen (group_name) : 0) +
-                strlen (user_name));
+        GNUNET_malloc (256 + (haveGroup ? strlen (group_name) : 0) +
+                       strlen (user_name));
 
       if (haveGroup)
         {
@@ -104,14 +105,14 @@
                haveGroup ? "--ingroup" : "",
                haveGroup ? group_name : "", user_name);
       system (cmd);
-      FREE (cmd);
-      return OK;
+      GNUNET_free (cmd);
+      return GNUNET_OK;
     }
   /* TODO: useradd */
   else
-    return SYSERR;
+    return GNUNET_SYSERR;
 #endif
-  return SYSERR;
+  return GNUNET_SYSERR;
 }
 
 
@@ -120,7 +121,7 @@
  * @brief Change user ID
  */
 int
-os_change_user (struct GE_Context *ectx, const char *user)
+GNUNET_change_user (struct GE_Context *ectx, const char *user)
 {
 #ifndef MINGW
   struct passwd *pws;
@@ -133,7 +134,7 @@
               GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
               _("Cannot obtain information about user `%s': %s\n"),
               user, errno == 0 ? _("No such user") : STRERROR (errno));
-      return SYSERR;
+      return GNUNET_SYSERR;
     }
   if ((0 != setgid (pws->pw_gid)) || (0 != setegid (pws->pw_gid)) ||
 #if HAVE_INITGROUPS
@@ -148,12 +149,12 @@
                   GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
                   _("Cannot change user/group to `%s': %s\n"),
                   user, STRERROR (errno));
-          return SYSERR;
+          return GNUNET_SYSERR;
         }
     }
 #endif
 
-  return OK;
+  return GNUNET_OK;
 }
 
 
@@ -162,8 +163,8 @@
  * @brief Change owner of a file
  */
 int
-os_change_owner (struct GE_Context *ectx,
-                 const char *filename, const char *user)
+GNUNET_file_change_owner (struct GE_Context *ectx,
+                          const char *filename, const char *user)
 {
 #ifndef MINGW
   struct passwd *pws;
@@ -171,16 +172,17 @@
   pws = getpwnam (user);
   if (pws == NULL)
     {
-      GE_LOG (ectx,
-              GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
-              _("Cannot obtain information about user `%s': %s\n"),
-              user, STRERROR (errno));
-      return SYSERR;
+      if (NULL != ectx)
+        GE_LOG (ectx,
+                GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
+                _("Cannot obtain information about user `%s': %s\n"),
+                user, STRERROR (errno));
+      return GNUNET_SYSERR;
     }
-  if (0 != chown (filename, pws->pw_uid, pws->pw_gid))
+  if ((0 != chown (filename, pws->pw_uid, pws->pw_gid)) && (NULL != ectx))
     GE_LOG_STRERROR_FILE (ectx,
                           GE_ERROR | GE_USER | GE_ADMIN | GE_IMMEDIATE,
                           "chown", filename);
 #endif
-  return OK;
+  return GNUNET_OK;
 }

Modified: GNUnet/src/util/string/string.c
===================================================================
--- GNUnet/src/util/string/string.c     2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/string/string.c     2007-11-23 11:51:54 UTC (rev 5742)
@@ -33,7 +33,7 @@
 
 
 int
-SNPRINTF (char *buf, size_t size, const char *format, ...)
+GNUNET_snprintf (char *buf, size_t size, const char *format, ...)
 {
   int ret;
   va_list args;
@@ -45,77 +45,12 @@
   return ret;
 }
 
-#if !HAVE_STRLCPY
 /**
- * @brief Copy a %NUL terminated string into a sized buffer
- * @author Linus Torvalds
- * @param dest Where to copy the string to
- * @param src Where to copy the string from
- * @param size size of destination buffer
- * @remarks Compatible with *BSD: the result is always a valid
- *          NUL-terminated string that fits in the buffer (unless,
- *          of course, the buffer size is zero). It does not pad
- *          out the result like strncpy() does.
- */
-size_t
-strlcpy (char *dest, const char *src, size_t size)
-{
-  size_t ret;
-
-  GE_ASSERT (NULL, dest != NULL);
-  GE_ASSERT (NULL, size > 0);
-  GE_ASSERT (NULL, src != NULL);
-  ret = strlen (src);
-
-  if (size)
-    {
-      size_t len = (ret >= size) ? size - 1 : ret;
-      memcpy (dest, src, len);
-      dest[len] = '\0';
-    }
-  return ret;
-}
-#endif
-
-#if !HAVE_STRLCAT
-/**
- * @brief Append a length-limited, %NUL-terminated string to another
- * @author Linus Torvalds
- * @param dest The string to be appended to
- * @param src The string to append to it
- * @param count The size of the destination buffer.
- */
-size_t
-strlcat (char *dest, const char *src, size_t count)
-{
-  size_t dsize;
-  size_t len;
-  size_t res;
-
-  GE_ASSERT (NULL, dest != NULL);
-  GE_ASSERT (NULL, src != NULL);
-  GE_ASSERT (NULL, count > 0);
-  dsize = strlen (dest);
-  len = strlen (src);
-  res = dsize + len;
-  GE_ASSERT (NULL, dsize < count);
-
-  dest += dsize;
-  count -= dsize;
-  if (len >= count)
-    len = count - 1;
-  memcpy (dest, src, len);
-  dest[len] = 0;
-  return res;
-}
-#endif
-
-/**
  * Give relative time in human-readable fancy format.
  * @param delta time in milli seconds
  */
 char *
-string_get_fancy_time_interval (unsigned long long delta)
+GNUNET_get_time_interval_as_fancy_string (unsigned long long delta)
 {
   const char *unit = _( /* time unit */ "ms");
   char *ret;
@@ -140,8 +75,8 @@
             }
         }
     }
-  ret = MALLOC (32);
-  SNPRINTF (ret, 32, "%llu%s", delta, unit);
+  ret = GNUNET_malloc (32);
+  GNUNET_snprintf (ret, 32, "%llu%s", delta, unit);
   return ret;
 }
 
@@ -149,7 +84,7 @@
  * Convert a given filesize into a fancy human-readable format.
  */
 char *
-string_get_fancy_byte_size (unsigned long long size)
+GNUNET_get_byte_size_as_fancy_string (unsigned long long size)
 {
   const char *unit = _( /* size unit */ "b");
   char *ret;
@@ -174,8 +109,8 @@
             }
         }
     }
-  ret = MALLOC (32);
-  SNPRINTF (ret, 32, "%llu%s", size, unit);
+  ret = GNUNET_malloc (32);
+  GNUNET_snprintf (ret, 32, "%llu%s", size, unit);
   return ret;
 }
 
@@ -191,8 +126,9 @@
  *  string is returned.
  */
 char *
-string_convertToUtf8 (struct GE_Context *ectx,
-                      const char *input, size_t len, const char *charset)
+GNUNET_convert_string_to_utf8 (struct GE_Context *ectx,
+                               const char *input, size_t len,
+                               const char *charset)
 {
   char *ret;
 #if ENABLE_NLS && HAVE_ICONV
@@ -208,34 +144,34 @@
       GE_LOG_STRERROR (ectx,
                        GE_USER | GE_ADMIN | GE_WARNING | GE_BULK,
                        "iconv_open");
-      ret = MALLOC (len + 1);
+      ret = GNUNET_malloc (len + 1);
       memcpy (ret, input, len);
       ret[len] = '\0';
       return ret;
     }
   tmpSize = 3 * len + 4;
-  tmp = MALLOC (tmpSize);
+  tmp = GNUNET_malloc (tmpSize);
   itmp = tmp;
   finSize = tmpSize;
   if (iconv (cd, (char **) &input, &len, &itmp, &finSize) == (size_t) - 1)
     {
       GE_LOG_STRERROR (ectx, GE_USER | GE_WARNING | GE_BULK, "iconv");
       iconv_close (cd);
-      FREE (tmp);
-      ret = MALLOC (len + 1);
+      GNUNET_free (tmp);
+      ret = GNUNET_malloc (len + 1);
       memcpy (ret, input, len);
       ret[len] = '\0';
       return ret;
     }
-  ret = MALLOC (tmpSize - finSize + 1);
+  ret = GNUNET_malloc (tmpSize - finSize + 1);
   memcpy (ret, tmp, tmpSize - finSize);
   ret[tmpSize - finSize] = '\0';
-  FREE (tmp);
+  GNUNET_free (tmp);
   if (0 != iconv_close (cd))
     GE_LOG_STRERROR (ectx, GE_ADMIN | GE_WARNING | GE_REQUEST, "iconv_close");
   return ret;
 #else
-  ret = MALLOC (len + 1);
+  ret = GNUNET_malloc (len + 1);
   memcpy (ret, input, len);
   ret[len] = '\0';
   return ret;
@@ -253,7 +189,7 @@
  *          NULL is returned on error
  */
 char *
-string_expandFileName (struct GE_Context *ectx, const char *fil)
+GNUNET_expand_file_name (struct GE_Context *ectx, const char *fil)
 {
   char *buffer;
 #ifndef MINGW
@@ -272,7 +208,7 @@
 #ifndef MINGW
   if (fil[0] == DIR_SEPARATOR)
     /* absolute path, just copy */
-    return STRDUP (fil);
+    return GNUNET_strdup (fil);
   if (fil[0] == '~')
     {
       fm = getenv ("HOME");
@@ -284,7 +220,7 @@
                   ("Failed to expand `$HOME': environment variable `HOME' not 
set"));
           return NULL;
         }
-      fm = STRDUP (fm);
+      fm = GNUNET_strdup (fm);
       /* do not copy '~' */
       fil_ptr = fil + 1;
 
@@ -300,7 +236,7 @@
       fm = NULL;
       while (1)
         {
-          buffer = MALLOC (len);
+          buffer = GNUNET_malloc (len);
           if (getcwd (buffer, len) != NULL)
             {
               fm = buffer;
@@ -309,10 +245,10 @@
           if ((errno == ERANGE) && (len < 1024 * 1024 * 4))
             {
               len *= 2;
-              FREE (buffer);
+              GNUNET_free (buffer);
               continue;
             }
-          FREE (buffer);
+          GNUNET_free (buffer);
           break;
         }
       if (fm == NULL)
@@ -321,18 +257,18 @@
                            GE_USER | GE_WARNING | GE_IMMEDIATE, "getcwd");
           buffer = getenv ("PWD");      /* alternative */
           if (buffer != NULL)
-            fm = STRDUP (buffer);
+            fm = GNUNET_strdup (buffer);
         }
       if (fm == NULL)
-        fm = STRDUP ("./");     /* give up */
+        fm = GNUNET_strdup ("./");      /* give up */
     }
   n = strlen (fm) + 1 + strlen (fil_ptr) + 1;
-  buffer = MALLOC (n);
-  SNPRINTF (buffer, n, "%s/%s", fm, fil_ptr);
-  FREE (fm);
+  buffer = GNUNET_malloc (n);
+  GNUNET_snprintf (buffer, n, "%s/%s", fm, fil_ptr);
+  GNUNET_free (fm);
   return buffer;
 #else
-  fn = MALLOC (MAX_PATH + 1);
+  fn = GNUNET_malloc (MAX_PATH + 1);
 
   if ((lRet = plibc_conv_to_win_path (fil, fn)) != ERROR_SUCCESS)
     {
@@ -355,9 +291,9 @@
                            "GetCurrentDirectory");
           return NULL;
         }
-      buffer = MALLOC (MAX_PATH + 1);
-      SNPRINTF (buffer, MAX_PATH + 1, "%s\\%s", szCurDir, fn);
-      FREE (fn);
+      buffer = GNUNET_malloc (MAX_PATH + 1);
+      GNUNET_snprintf (buffer, MAX_PATH + 1, "%s\\%s", szCurDir, fn);
+      GNUNET_free (fn);
       fn = buffer;
     }
 

Modified: GNUnet/src/util/string/xmalloc.c
===================================================================
--- GNUnet/src/util/string/xmalloc.c    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/string/xmalloc.c    2007-11-23 11:51:54 UTC (rev 5742)
@@ -37,28 +37,29 @@
  * memory is available.
  *
  * @param size how many bytes of memory to allocate, do NOT use
- *  this function (or MALLOC) to allocate more than several MB
+ *  this function (or GNUNET_malloc) to allocate more than several MB
  *  of memory, if you are possibly needing a very large chunk use
- *  xmalloc_unchecked_ instead.
- * @param filename where in the code was the call to GROW
- * @param linenumber where in the code was the call to GROW
+ *  GNUNET_xmalloc_unchecked_ instead.
+ * @param filename where in the code was the call to GNUNET_array_grow
+ * @param linenumber where in the code was the call to GNUNET_array_grow
  * @return pointer to size bytes of memory
  */
 void *
-xmalloc_ (size_t size,
-          const char *filename, int linenumber, const char *function)
+GNUNET_xmalloc_ (size_t size,
+                 const char *filename, int linenumber, const char *function)
 {
   /* As a security precaution, we generally do not allow very large
-     allocations using the default 'MALLOC' macro */
+     allocations using the default 'GNUNET_malloc' macro */
   GE_ASSERT_FLF (NULL,
-                 size <= MAX_MALLOC_CHECKED, filename, linenumber, function);
-  return xmalloc_unchecked_ (size, filename, linenumber, function);
+                 size <= GNUNET_MAX_GNUNET_malloc_CHECKED, filename,
+                 linenumber, function);
+  return GNUNET_xmalloc_unchecked_ (size, filename, linenumber, function);
 }
 
 void *
-xmalloc_unchecked_ (size_t size,
-                    const char *filename,
-                    int linenumber, const char *function)
+GNUNET_xmalloc_unchecked_ (size_t size,
+                           const char *filename,
+                           int linenumber, const char *function)
 {
   void *result;
 
@@ -78,16 +79,16 @@
  *
  * @ptr the pointer to reallocate
  * @param size how many bytes of memory to allocate, do NOT use
- *  this function (or MALLOC) to allocate more than several MB
+ *  this function (or GNUNET_malloc) to allocate more than several MB
  *  of memory
- * @param filename where in the code was the call to REALLOC
- * @param linenumber where in the code was the call to REALLOC
+ * @param filename where in the code was the call to GNUNET_realloc
+ * @param linenumber where in the code was the call to GNUNET_realloc
  * @return pointer to size bytes of memory
  */
 void *
-xrealloc_ (void *ptr,
-           const size_t n,
-           const char *filename, int linenumber, const char *function)
+GNUNET_xrealloc_ (void *ptr,
+                  const size_t n,
+                  const char *filename, int linenumber, const char *function)
 {
   ptr = realloc (ptr, n);
 
@@ -103,11 +104,12 @@
  * want to keep track of allocations.
  *
  * @param ptr the pointer to free
- * @param filename where in the code was the call to GROW
- * @param linenumber where in the code was the call to GROW
+ * @param filename where in the code was the call to GNUNET_array_grow
+ * @param linenumber where in the code was the call to GNUNET_array_grow
  */
 void
-xfree_ (void *ptr, const char *filename, int linenumber, const char *function)
+GNUNET_xfree_ (void *ptr, const char *filename, int linenumber,
+               const char *function)
 {
   GE_ASSERT_FLF (NULL, ptr != NULL, filename, linenumber, function);
   free (ptr);
@@ -117,51 +119,25 @@
  * Dup a string (same semantics as strdup).
  *
  * @param str the string to dup
- * @param filename where in the code was the call to GROW
- * @param linenumber where in the code was the call to GROW
+ * @param filename where in the code was the call to GNUNET_array_grow
+ * @param linenumber where in the code was the call to GNUNET_array_grow
  * @return strdup(str)
  */
 char *
-xstrdup_ (const char *str,
-          const char *filename, int linenumber, const char *function)
+GNUNET_xstrdup_ (const char *str,
+                 const char *filename, int linenumber, const char *function)
 {
   char *res;
 
   GE_ASSERT_FLF (NULL, str != NULL, filename, linenumber, function);
-  res = (char *) xmalloc_ (strlen (str) + 1, filename, linenumber, function);
+  res =
+    (char *) GNUNET_xmalloc_ (strlen (str) + 1, filename, linenumber,
+                              function);
   memcpy (res, str, strlen (str) + 1);
   return res;
 }
 
 /**
- * Dup a string (same semantics as strdup).
- *
- * @param str the string to dup
- * @param n the maximum number of characters to copy (+1 for 0-termination)
- * @param filename where in the code was the call to GROW
- * @param linenumber where in the code was the call to GROW
- * @return strdup(str)
- */
-char *
-xstrndup_ (const char *str,
-           const size_t n,
-           const char *filename, int linenumber, const char *function)
-{
-  char *res;
-  size_t min;
-
-  GE_ASSERT_FLF (NULL, str != NULL, filename, linenumber, function);
-  min = 0;
-  while ((min < n) && (str[min] != '\0'))
-    min++;
-  res = (char *) xmalloc_ (min + 1, filename, linenumber, function);
-  memcpy (res, str, min);
-  res[min] = '\0';
-  return res;
-}
-
-
-/**
  * Grow an array.  Grows old by (*oldCount-newCount)*elementSize bytes
  * and sets *oldCount to newCount.
  *
@@ -170,15 +146,15 @@
  * @param elementSize the size of the elements of the array
  * @param oldCount address of the number of elements in the *old array
  * @param newCount number of elements in the new array, may be 0
- * @param filename where in the code was the call to GROW
- * @param linenumber where in the code was the call to GROW
+ * @param filename where in the code was the call to GNUNET_array_grow
+ * @param linenumber where in the code was the call to GNUNET_array_grow
  */
 void
-xgrow_ (void **old,
-        size_t elementSize,
-        unsigned int *oldCount,
-        unsigned int newCount,
-        const char *filename, int linenumber, const char *function)
+GNUNET_xgrow_ (void **old,
+               size_t elementSize,
+               unsigned int *oldCount,
+               unsigned int newCount,
+               const char *filename, int linenumber, const char *function)
 {
   void *tmp;
   size_t size;
@@ -193,7 +169,7 @@
     }
   else
     {
-      tmp = xmalloc_ (size, filename, linenumber, function);
+      tmp = GNUNET_xmalloc_ (size, filename, linenumber, function);
       GE_ASSERT (NULL, tmp != NULL);
       memset (tmp, 0, size);    /* client code should not rely on this, 
though... */
       if (*oldCount > newCount)
@@ -203,7 +179,7 @@
 
   if (*old != NULL)
     {
-      xfree_ (*old, filename, linenumber, function);
+      GNUNET_xfree_ (*old, filename, linenumber, function);
     }
   *old = tmp;
   *oldCount = newCount;

Modified: GNUnet/src/util/string/xmalloctest.c
===================================================================
--- GNUnet/src/util/string/xmalloctest.c        2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/string/xmalloctest.c        2007-11-23 11:51:54 UTC (rev 
5742)
@@ -36,11 +36,11 @@
   int k;
   unsigned int ui;
 
-  /* MALLOC/FREE test */
+  /* GNUNET_malloc/GNUNET_free test */
   k = 352;                      /* random start value */
   for (i = 1; i < MAX_TESTVAL; i++)
     {
-      ptrs[i] = MALLOC (i);
+      ptrs[i] = GNUNET_malloc (i);
       for (j = 0; j < i; j++)
         ptrs[i][j] = k++;
     }
@@ -50,49 +50,38 @@
       for (j = i - 1; j >= 0; j--)
         if (ptrs[i][j] != (char) --k)
           return 1;
-      FREE (ptrs[i]);
+      GNUNET_free (ptrs[i]);
     }
 
-  /* STRNDUP tests */
-  FREE (STRNDUP ("foo", 0));
-  ptrs[0] = STRNDUP ("foo", 42);
-  if (0 != strcmp (ptrs[0], "foo"))
-    return 1;
-  FREE (ptrs[0]);
-  ptrs[0] = STRNDUP ("foo", 2);
-  if (0 != strcmp (ptrs[0], "fo"))
-    return 2;
-  FREE (ptrs[0]);
+  /* GNUNET_free_non_null test */
+  GNUNET_free_non_null (NULL);
+  GNUNET_free_non_null (GNUNET_malloc (4));
 
-  /* FREENONNULL test */
-  FREENONNULL (NULL);
-  FREENONNULL (MALLOC (4));
-
-  /* STRDUP tests */
-  ptrs[0] = STRDUP ("bar");
+  /* GNUNET_strdup tests */
+  ptrs[0] = GNUNET_strdup ("bar");
   if (0 != strcmp (ptrs[0], "bar"))
     return 3;
-  FREE (ptrs[0]);
+  GNUNET_free (ptrs[0]);
 
-  /* GROW tests */
+  /* GNUNET_array_grow tests */
   ptrs[0] = NULL;
   ui = 0;
-  GROW (ptrs[0], ui, 42);
+  GNUNET_array_grow (ptrs[0], ui, 42);
   if (ui != 42)
     return 4;
-  GROW (ptrs[0], ui, 22);
+  GNUNET_array_grow (ptrs[0], ui, 22);
   if (ui != 22)
     return 5;
   for (j = 0; j < 22; j++)
     ptrs[0][j] = j;
-  GROW (ptrs[0], ui, 32);
+  GNUNET_array_grow (ptrs[0], ui, 32);
   for (j = 0; j < 22; j++)
     if (ptrs[0][j] != j)
       return 6;
   for (j = 22; j < 32; j++)
     if (ptrs[0][j] != 0)
       return 7;
-  GROW (ptrs[0], ui, 0);
+  GNUNET_array_grow (ptrs[0], ui, 0);
   if (i != 0)
     return 8;
   if (ptrs[0] != NULL)

Modified: GNUnet/src/util/threads/mutex.c
===================================================================
--- GNUnet/src/util/threads/mutex.c     2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/threads/mutex.c     2007-11-23 11:51:54 UTC (rev 5742)
@@ -28,7 +28,7 @@
 #include "gnunet_util_string.h"
 #include "platform.h"
 
-#if SOLARIS || FREEBSD || OSX
+#if SOLARIS || GNUNET_freeBSD || OSX
 #include <semaphore.h>
 #endif
 #if SOMEBSD
@@ -62,17 +62,17 @@
 #endif
 
 
-typedef struct MUTEX
+typedef struct GNUNET_Mutex
 {
   pthread_mutex_t pt;
   const char *locked_file;
-  cron_t locked_time;
+  GNUNET_CronTime locked_time;
   unsigned int locked_line;
   unsigned int locked_depth;
 } Mutex;
 
 Mutex *
-MUTEX_CREATE (int isRecursive)
+GNUNET_mutex_create (int isRecursive)
 {
   pthread_mutexattr_t attr;
   Mutex *mut;
@@ -87,7 +87,7 @@
       GE_ASSERT (NULL,
                  0 == pthread_mutexattr_setkind_np
                  (&attr, PTHREAD_MUTEX_RECURSIVE_NP));
-#elif SOMEBSD || FREEBSD || FREEBSD5
+#elif SOMEBSD || GNUNET_freeBSD || GNUNET_freeBSD5
       GE_ASSERT (NULL,
                  0 == pthread_mutexattr_setkind_np
                  (&attr, PTHREAD_MUTEX_RECURSIVE));
@@ -109,35 +109,36 @@
                  (&attr, PTHREAD_MUTEX_ERRORCHECK));
 #endif
     }
-  mut = MALLOC (sizeof (Mutex));
+  mut = GNUNET_malloc (sizeof (Mutex));
   memset (mut, 0, sizeof (Mutex));
   GE_ASSERT (NULL, 0 == pthread_mutex_init (&mut->pt, &attr));
   return mut;
 }
 
 void
-MUTEX_DESTROY (Mutex * mutex)
+GNUNET_mutex_destroy (Mutex * mutex)
 {
   int ret;
   GE_ASSERT (NULL, mutex != NULL);
   errno = 0;
   ret = pthread_mutex_destroy (&mutex->pt);
   GE_ASSERT (NULL, 0 == ret);
-  FREE (mutex);
+  GNUNET_free (mutex);
 }
 
 void
-MUTEX_LOCK_FL (Mutex * mutex, const char *file, unsigned int line)
+GNUNET_mutex_lock_at_file_line_ (Mutex * mutex, const char *file,
+                                 unsigned int line)
 {
   int ret;
-  cron_t start;
-  cron_t end;
+  GNUNET_CronTime start;
+  GNUNET_CronTime end;
 
   GE_ASSERT (NULL, mutex != NULL);
-  start = get_time ();
+  start = GNUNET_get_time ();
   ret = pthread_mutex_lock (&mutex->pt);
-  end = get_time ();
-  if ((end - start > REALTIME_LIMIT) && (REALTIME_LIMIT != 0))
+  end = GNUNET_get_time ();
+  if ((end - start > GNUNET_REALTIME_LIMIT) && (GNUNET_REALTIME_LIMIT != 0))
     {
       GE_LOG (NULL,
               GE_DEVELOPER | GE_WARNING | GE_IMMEDIATE,
@@ -165,17 +166,17 @@
 }
 
 void
-MUTEX_UNLOCK (Mutex * mutex)
+GNUNET_mutex_unlock (Mutex * mutex)
 {
   int ret;
-  cron_t now;
+  GNUNET_CronTime now;
 
   GE_ASSERT (NULL, mutex != NULL);
   if (0 == --mutex->locked_depth)
     {
-      now = get_time ();
-      if ((now - mutex->locked_time > REALTIME_LIMIT) &&
-          (REALTIME_LIMIT != 0))
+      now = GNUNET_get_time ();
+      if ((now - mutex->locked_time > GNUNET_REALTIME_LIMIT) &&
+          (GNUNET_REALTIME_LIMIT != 0))
         GE_LOG (NULL,
                 GE_DEVELOPER | GE_WARNING | GE_IMMEDIATE,
                 _("Lock aquired for too long (%llu ms) at %s:%u\n"),

Modified: GNUnet/src/util/threads/pthread.c
===================================================================
--- GNUnet/src/util/threads/pthread.c   2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/threads/pthread.c   2007-11-23 11:51:54 UTC (rev 5742)
@@ -28,7 +28,7 @@
 #include "gnunet_util_string.h"
 #include "platform.h"
 
-#if SOLARIS || FREEBSD || OSX
+#if SOLARIS || GNUNET_freeBSD || OSX
 #include <semaphore.h>
 #endif
 #if SOMEBSD
@@ -42,19 +42,19 @@
 #include <pthread.h>
 #endif
 
-typedef struct PTHREAD
+typedef struct GNUNET_ThreadHandle
 {
   pthread_t pt;
 } PThread;
 
 /**
- * Returns YES if pt is the handle for THIS thread.
+ * Returns GNUNET_YES if pt is the handle for THIS thread.
  */
 int
-PTHREAD_TEST_SELF (PThread * handle)
+GNUNET_thread_test_self (PThread * handle)
 {
   if (handle == NULL)
-    return NO;
+    return GNUNET_NO;
 #if HAVE_PTHREAD_EQUAL
   if (pthread_equal (pthread_self (), handle->pt))
 #else
@@ -64,19 +64,19 @@
   if (handle->pt == pthread_self ())
 #endif
 #endif
-    return YES;
+    return GNUNET_YES;
   else
-    return NO;
+    return GNUNET_NO;
 }
 
 /**
  * Get the handle for THIS thread.
  */
 PThread *
-PTHREAD_GET_SELF ()
+GNUNET_thread_get_self ()
 {
   PThread *ret;
-  ret = MALLOC (sizeof (PThread));
+  ret = GNUNET_malloc (sizeof (PThread));
   ret->pt = pthread_self ();
   return ret;
 }
@@ -85,9 +85,9 @@
  * Release handle for a thread.
  */
 void
-PTHREAD_REL_SELF (PThread * handle)
+GNUNET_thread_release_self (PThread * handle)
 {
-  FREE (handle);
+  GNUNET_free (handle);
 }
 
 /**
@@ -103,7 +103,8 @@
  * @return see pthread_create
  */
 PThread *
-PTHREAD_CREATE (PThreadMain main, void *arg, unsigned int stackSize)
+GNUNET_thread_create (GNUNET_ThreadMainFunction main, void *arg,
+                      unsigned int stackSize)
 {
   PThread *handle;
 #ifndef LINUX
@@ -111,7 +112,7 @@
 #endif
   int ret;
 
-  handle = MALLOC (sizeof (PThread));
+  handle = GNUNET_malloc (sizeof (PThread));
 #ifdef MINGW
   memset (handle, 0, sizeof (PThread));
 #endif
@@ -128,33 +129,34 @@
                         main, arg);
   if (ret != 0)
     {
-      FREE (handle);
+      GNUNET_free (handle);
       return NULL;
     }
   return handle;
 }
 
 void
-PTHREAD_JOIN_FL (PThread * handle,
-                 void **ret, const char *file, unsigned int line)
+GNUNET_thread_join_at_file_line_ (PThread * handle,
+                                  void **ret, const char *file,
+                                  unsigned int line)
 {
-  cron_t start;
-  cron_t end;
+  GNUNET_CronTime start;
+  GNUNET_CronTime end;
   int k;
 
   GE_ASSERT (NULL, handle != NULL);
-  GE_ASSERT (NULL, NO == PTHREAD_TEST_SELF (handle));
-  start = get_time ();
+  GE_ASSERT (NULL, GNUNET_NO == GNUNET_thread_test_self (handle));
+  start = GNUNET_get_time ();
   k = pthread_join (handle->pt, ret);
-  end = get_time ();
-  if ((end - start > REALTIME_LIMIT) && (REALTIME_LIMIT != 0))
+  end = GNUNET_get_time ();
+  if ((end - start > GNUNET_REALTIME_LIMIT) && (GNUNET_REALTIME_LIMIT != 0))
     {
       GE_LOG (NULL,
               GE_DEVELOPER | GE_WARNING | GE_IMMEDIATE,
               _("Real-time delay violation (%llu ms) at %s:%u\n"),
               end - start, file, line);
     }
-  FREE (handle);
+  GNUNET_free (handle);
   switch (k)
     {
     case 0:
@@ -201,12 +203,12 @@
 
 
 /**
- * Sleep for the specified time interval.  Use PTHREAD_STOP_SLEEP to
+ * Sleep for the specified time interval.  Use GNUNET_thread_stop_sleep to
  * wake the thread up early.  Caller is responsible to check that the
  * sleep was long enough.
  */
 void
-PTHREAD_SLEEP (unsigned long long delay)
+GNUNET_thread_sleep (unsigned long long delay)
 {
 #if LINUX || SOLARIS || SOMEBSD || OSX
   struct timespec req;
@@ -241,7 +243,7 @@
 }
 
 void
-PTHREAD_STOP_SLEEP (PThread * handle)
+GNUNET_thread_stop_sleep (PThread * handle)
 {
   int ret;
 

Modified: GNUnet/src/util/threads/semaphore.c
===================================================================
--- GNUnet/src/util/threads/semaphore.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/threads/semaphore.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -31,7 +31,7 @@
 #include "gnunet_util_string.h"
 #include "platform.h"
 
-#if SOLARIS || FREEBSD || OSX
+#if SOLARIS || GNUNET_freeBSD || OSX
 #include <semaphore.h>
 #include <sys/file.h>
 #endif
@@ -49,7 +49,7 @@
 /**
  * @brief Internal state of a semaphore.
  */
-typedef struct SEMAPHORE
+typedef struct GNUNET_Semaphore
 {
   /**
    * Counter
@@ -91,7 +91,7 @@
  * be called when the semaphore is no longer needed.
  */
 Semaphore *
-SEMAPHORE_CREATE (int value)
+GNUNET_semaphore_create (int value)
 {
   Semaphore *s;
   pthread_mutexattr_t attr;
@@ -109,7 +109,7 @@
              0 == pthread_mutexattr_settype
              (&attr, PTHREAD_MUTEX_ERRORCHECK));
 #endif
-  s = MALLOC (sizeof (Semaphore));
+  s = GNUNET_malloc (sizeof (Semaphore));
   s->v = value;
   GE_ASSERT (NULL, 0 == pthread_mutex_init (&s->mutex, &attr));
   GE_ASSERT (NULL, 0 == pthread_cond_init (&s->cond, NULL));
@@ -117,16 +117,16 @@
 }
 
 void
-SEMAPHORE_DESTROY (Semaphore * s)
+GNUNET_semaphore_destroy (Semaphore * s)
 {
   GE_ASSERT (NULL, s != NULL);
   GE_ASSERT (NULL, 0 == pthread_cond_destroy (&s->cond));
   GE_ASSERT (NULL, 0 == pthread_mutex_destroy (&s->mutex));
-  FREE (s);
+  GNUNET_free (s);
 }
 
 int
-SEMAPHORE_UP (Semaphore * s)
+GNUNET_semaphore_up (Semaphore * s)
 {
   int ret;
 
@@ -139,27 +139,28 @@
 }
 
 int
-SEMAPHORE_DOWN_FL (Semaphore * s,
-                   int mayblock,
-                   int longwait, const char *file, unsigned int line)
+GNUNET_semaphore_down_at_file_line_ (Semaphore * s,
+                                     int mayblock,
+                                     int longwait, const char *file,
+                                     unsigned int line)
 {
   int ret;
-  cron_t start;
-  cron_t end;
+  GNUNET_CronTime start;
+  GNUNET_CronTime end;
 
   GE_ASSERT (NULL, s != NULL);
-  start = get_time ();
+  start = GNUNET_get_time ();
   GE_ASSERT (NULL, 0 == pthread_mutex_lock (&s->mutex));
   while ((s->v <= 0) && mayblock)
     GE_ASSERT (NULL, 0 == pthread_cond_wait (&s->cond, &s->mutex));
   if (s->v > 0)
     ret = --(s->v);
   else
-    ret = SYSERR;
+    ret = GNUNET_SYSERR;
   GE_ASSERT (NULL, 0 == pthread_mutex_unlock (&s->mutex));
-  end = get_time ();
-  if ((longwait == NO) &&
-      (end - start > REALTIME_LIMIT) && (REALTIME_LIMIT != 0))
+  end = GNUNET_get_time ();
+  if ((longwait == GNUNET_NO) &&
+      (end - start > GNUNET_REALTIME_LIMIT) && (GNUNET_REALTIME_LIMIT != 0))
     {
       GE_LOG (NULL,
               GE_DEVELOPER | GE_WARNING | GE_IMMEDIATE,

Modified: GNUnet/src/util/threads/semaphoretest.c
===================================================================
--- GNUnet/src/util/threads/semaphoretest.c     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/threads/semaphoretest.c     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -27,9 +27,9 @@
 
 #include <sys/types.h>
 
-static struct MUTEX *lock;
+static struct GNUNET_Mutex *lock;
 
-static struct SEMAPHORE *sem;
+static struct GNUNET_Semaphore *sem;
 
 static volatile int sv;
 
@@ -40,10 +40,10 @@
 {
   sv = 0;
   while (sv == 0)
-    PTHREAD_SLEEP (50 * cronMILLIS);    /* busy waiting may not always work */
-  MUTEX_LOCK (lock);
+    GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);        /* busy 
waiting may not always work */
+  GNUNET_mutex_lock (lock);
   sv = 1;
-  MUTEX_UNLOCK (lock);
+  GNUNET_mutex_unlock (lock);
   sv = 2;
   tv = 2;
   return NULL;
@@ -63,58 +63,58 @@
 static int
 testPTHREAD_CREATE ()
 {
-  struct PTHREAD *pt;
+  struct GNUNET_ThreadHandle *pt;
   void *unused;
 
   sv = -1;
   tv = 0;
-  lock = MUTEX_CREATE (NO);
-  pt = PTHREAD_CREATE (&lockIt, NULL, 1024);
+  lock = GNUNET_mutex_create (GNUNET_NO);
+  pt = GNUNET_thread_create (&lockIt, NULL, 1024);
   while (tv != 2)
     {
       sv = 1;
-      PTHREAD_SLEEP (50 * cronMILLIS);  /* busy waiting may not always work */
+      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);      /* busy 
waiting may not always work */
     }
-  PTHREAD_JOIN (pt, &unused);
-  MUTEX_DESTROY (lock);
-  pt = PTHREAD_CREATE (&bigStack, NULL, 1024 * 100 + 25000);    /* fails by 
segfault */
-  PTHREAD_JOIN (pt, &unused);
+  GNUNET_thread_join (pt, &unused);
+  GNUNET_mutex_destroy (lock);
+  pt = GNUNET_thread_create (&bigStack, NULL, 1024 * 100 + 25000);      /* 
fails by segfault */
+  GNUNET_thread_join (pt, &unused);
   return 0;
 }
 
 static int
 testMutex ()
 {
-  struct PTHREAD *pt;
+  struct GNUNET_ThreadHandle *pt;
   void *unused;
 
-  lock = MUTEX_CREATE (NO);
+  lock = GNUNET_mutex_create (GNUNET_NO);
 
   sv = 1;
   tv = 0;
-  pt = PTHREAD_CREATE (&lockIt, NULL, 1024);
+  pt = GNUNET_thread_create (&lockIt, NULL, 1024);
   while (sv == 1)
-    PTHREAD_SLEEP (50 * cronMILLIS);    /* busy waiting may not always work */
-  MUTEX_LOCK (lock);
+    GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);        /* busy 
waiting may not always work */
+  GNUNET_mutex_lock (lock);
   sv = 5;                       /* release lockIt from while sv==0 loop,
                                    blocks it on lock */
 
   if (sv != 5)
     {
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       while (tv != 2)
-        PTHREAD_SLEEP (50 * cronMILLIS);        /* busy waiting may not always 
work */
-      MUTEX_DESTROY (lock);
+        GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);    /* busy 
waiting may not always work */
+      GNUNET_mutex_destroy (lock);
       printf ("MUTEX test failed at %s:%u\n", __FILE__, __LINE__);
       return 1;                 /* error */
     }
   else
     {
-      MUTEX_UNLOCK (lock);
+      GNUNET_mutex_unlock (lock);
       while (tv != 2)
-        PTHREAD_SLEEP (50 * cronMILLIS);        /* busy waiting may not always 
work */
-      PTHREAD_JOIN (pt, &unused);
-      MUTEX_DESTROY (lock);
+        GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);    /* busy 
waiting may not always work */
+      GNUNET_thread_join (pt, &unused);
+      GNUNET_mutex_destroy (lock);
       return 0;                 /* ok */
     }
 }
@@ -124,12 +124,12 @@
 {
   int i;
 
-  lock = MUTEX_CREATE (YES);
+  lock = GNUNET_mutex_create (GNUNET_YES);
   for (i = 0; i < 50; i++)
-    MUTEX_LOCK (lock);
+    GNUNET_mutex_lock (lock);
   for (i = 0; i < 50; i++)
-    MUTEX_UNLOCK (lock);
-  MUTEX_DESTROY (lock);
+    GNUNET_mutex_unlock (lock);
+  GNUNET_mutex_destroy (lock);
   return 0;                     /* ok -- fails by hanging! */
 }
 
@@ -139,16 +139,16 @@
   int i;
 
   for (i = 0; i < 42; i++)
-    SEMAPHORE_DOWN (sem, YES);  /* fails by blocking */
-  if (SEMAPHORE_DOWN (sem, NO) != SYSERR)
+    GNUNET_semaphore_down (sem, GNUNET_YES);    /* fails by blocking */
+  if (GNUNET_semaphore_down (sem, GNUNET_NO) != GNUNET_SYSERR)
     {
-      SEMAPHORE_DESTROY (sem);
-      printf ("SEMAPHORE_DOWN_NONBLOCKING failed at %s:%u\n"
+      GNUNET_semaphore_destroy (sem);
+      printf ("GNUNET_semaphore_down_NONBLOCKING failed at %s:%u\n"
               "Testcase deadlocked.\n", __FILE__, __LINE__);
       return NULL;              /* will halt testcase! */
     }
   for (i = 0; i < 42; i++)
-    SEMAPHORE_UP (sem);
+    GNUNET_semaphore_up (sem);
   return NULL;
 }
 
@@ -156,46 +156,47 @@
 testSemaphore ()
 {
   int i;
-  struct PTHREAD *pt;
+  struct GNUNET_ThreadHandle *pt;
   void *unused;
 
-  sem = SEMAPHORE_CREATE (42);
+  sem = GNUNET_semaphore_create (42);
   for (i = 0; i < 42; i++)
-    SEMAPHORE_DOWN (sem, YES);  /* fails by blocking */
-  if (SEMAPHORE_DOWN (sem, NO) != SYSERR)
+    GNUNET_semaphore_down (sem, GNUNET_YES);    /* fails by blocking */
+  if (GNUNET_semaphore_down (sem, GNUNET_NO) != GNUNET_SYSERR)
     {
-      SEMAPHORE_DESTROY (sem);
-      printf ("SEMAPHORE_DOWN_NONBLOCKING failed at %s:%u\n",
+      GNUNET_semaphore_destroy (sem);
+      printf ("GNUNET_semaphore_down_NONBLOCKING failed at %s:%u\n",
               __FILE__, __LINE__);
       return 1;
     }
   for (i = 0; i < 42; i++)
-    SEMAPHORE_UP (sem);
+    GNUNET_semaphore_up (sem);
   for (i = 0; i < 42; i++)
-    if (SYSERR == SEMAPHORE_DOWN (sem, NO))
+    if (GNUNET_SYSERR == GNUNET_semaphore_down (sem, GNUNET_NO))
       {
-        SEMAPHORE_DESTROY (sem);
-        printf ("SEMAPHORE_DOWN_NONBLOCKING failed at %s:%u iteration %d\n",
-                __FILE__, __LINE__, i);
+        GNUNET_semaphore_destroy (sem);
+        printf
+          ("GNUNET_semaphore_down_NONBLOCKING failed at %s:%u iteration %d\n",
+           __FILE__, __LINE__, i);
         return 1;
       }
-  if (SEMAPHORE_DOWN (sem, NO) != SYSERR)
+  if (GNUNET_semaphore_down (sem, GNUNET_NO) != GNUNET_SYSERR)
     {
-      SEMAPHORE_DESTROY (sem);
-      printf ("SEMAPHORE_DOWN_NONBLOCKING failed at %s:%u\n",
+      GNUNET_semaphore_destroy (sem);
+      printf ("GNUNET_semaphore_down_NONBLOCKING failed at %s:%u\n",
               __FILE__, __LINE__);
       return 1;
     }
-  pt = PTHREAD_CREATE (&semUpDown, NULL, 1024);
+  pt = GNUNET_thread_create (&semUpDown, NULL, 1024);
   for (i = 0; i < 42; i++)
-    SEMAPHORE_UP (sem);
-  PTHREAD_JOIN (pt, &unused);
+    GNUNET_semaphore_up (sem);
+  GNUNET_thread_join (pt, &unused);
   for (i = 0; i < 42; i++)
-    SEMAPHORE_DOWN (sem, YES);
-  if (SEMAPHORE_DOWN (sem, NO) != SYSERR)
+    GNUNET_semaphore_down (sem, GNUNET_YES);
+  if (GNUNET_semaphore_down (sem, GNUNET_NO) != GNUNET_SYSERR)
     {
-      SEMAPHORE_DESTROY (sem);
-      printf ("SEMAPHORE_DOWN_NONBLOCKING failed at %s:%u\n",
+      GNUNET_semaphore_destroy (sem);
+      printf ("GNUNET_semaphore_down_NONBLOCKING failed at %s:%u\n",
               __FILE__, __LINE__);
       return 1;
     }

Modified: GNUnet/src/util/threads/shutdown.c
===================================================================
--- GNUnet/src/util/threads/shutdown.c  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/threads/shutdown.c  2007-11-23 11:51:54 UTC (rev 5742)
@@ -35,40 +35,40 @@
 /**
  * Semaphore used to signal "shutdown"
  */
-static struct SEMAPHORE *shutdown_signal;
+static struct GNUNET_Semaphore *shutdown_signal;
 
 static int shutdown_active;
 
-static struct SignalHandlerContext *shc_int;
+static struct GNUNET_SignalHandlerContext *shc_int;
 
-static struct SignalHandlerContext *shc_term;
+static struct GNUNET_SignalHandlerContext *shc_term;
 
-static struct SignalHandlerContext *shc_quit;
+static struct GNUNET_SignalHandlerContext *shc_quit;
 
 void
-GNUNET_SHUTDOWN_INITIATE ()
+GNUNET_shutdown_initiate ()
 {
   GE_ASSERT (NULL, shutdown_signal != NULL);
-  shutdown_active = YES;
-  SEMAPHORE_UP (shutdown_signal);
+  shutdown_active = GNUNET_YES;
+  GNUNET_semaphore_up (shutdown_signal);
 }
 
 int
-GNUNET_SHUTDOWN_TEST ()
+GNUNET_shutdown_test ()
 {
   return shutdown_active;
 }
 
 void
-GNUNET_SHUTDOWN_WAITFOR ()
+GNUNET_shutdown_wait_for ()
 {
-  SEMAPHORE_DOWN (shutdown_signal, YES);
+  GNUNET_semaphore_down (shutdown_signal, GNUNET_YES);
 }
 
 static void
 run_shutdown ()
 {
-  GNUNET_SHUTDOWN_INITIATE ();
+  GNUNET_shutdown_initiate ();
 }
 
 /**
@@ -86,7 +86,7 @@
     case CTRL_SHUTDOWN_EVENT:
     case CTRL_LOGOFF_EVENT:
     case SERVICE_CONTROL_STOP:
-      GNUNET_SHUTDOWN_INITIATE ();
+      GNUNET_shutdown_initiate ();
     }
 
   return TRUE;
@@ -99,12 +99,12 @@
 void __attribute__ ((constructor)) shutdown_handlers_ltdl_init ()
 {
   GE_ASSERT (NULL, shutdown_signal == NULL);
-  GE_ASSERT (NULL, shutdown_active == NO);
-  shutdown_signal = SEMAPHORE_CREATE (0);
+  GE_ASSERT (NULL, shutdown_active == GNUNET_NO);
+  shutdown_signal = GNUNET_semaphore_create (0);
 #ifndef MINGW
-  shc_int = signal_handler_install (SIGINT, &run_shutdown);
-  shc_term = signal_handler_install (SIGTERM, &run_shutdown);
-  shc_quit = signal_handler_install (SIGQUIT, &run_shutdown);
+  shc_int = GNUNET_signal_handler_install (SIGINT, &run_shutdown);
+  shc_term = GNUNET_signal_handler_install (SIGTERM, &run_shutdown);
+  shc_quit = GNUNET_signal_handler_install (SIGQUIT, &run_shutdown);
 #else
   SetConsoleCtrlHandler (&run_shutdown_win, TRUE);
 #endif
@@ -113,13 +113,13 @@
 void __attribute__ ((destructor)) shutdown_handlers_ltdl_fini ()
 {
 #ifndef MINGW
-  signal_handler_uninstall (SIGINT, &run_shutdown, shc_int);
-  signal_handler_uninstall (SIGTERM, &run_shutdown, shc_term);
-  signal_handler_uninstall (SIGQUIT, &run_shutdown, shc_quit);
+  GNUNET_signal_handler_uninstall (SIGINT, &run_shutdown, shc_int);
+  GNUNET_signal_handler_uninstall (SIGTERM, &run_shutdown, shc_term);
+  GNUNET_signal_handler_uninstall (SIGQUIT, &run_shutdown, shc_quit);
 #else
   SetConsoleCtrlHandler (&run_shutdown_win, FALSE);
 #endif
-  SEMAPHORE_DESTROY (shutdown_signal);
+  GNUNET_semaphore_destroy (shutdown_signal);
   shutdown_signal = NULL;
   shc_int = NULL;
   shc_term = NULL;

Modified: GNUnet/src/util/threads/shutdowntest.c
===================================================================
--- GNUnet/src/util/threads/shutdowntest.c      2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/threads/shutdowntest.c      2007-11-23 11:51:54 UTC (rev 
5742)
@@ -29,12 +29,12 @@
 static int
 check ()
 {
-  if (GNUNET_SHUTDOWN_TEST () != NO)
+  if (GNUNET_shutdown_test () != GNUNET_NO)
     return 1;
-  GNUNET_SHUTDOWN_INITIATE ();
-  if (GNUNET_SHUTDOWN_TEST () != YES)
+  GNUNET_shutdown_initiate ();
+  if (GNUNET_shutdown_test () != GNUNET_YES)
     return 2;
-  GNUNET_SHUTDOWN_WAITFOR ();
+  GNUNET_shutdown_wait_for ();
   return 0;
 }
 

Modified: GNUnet/src/util/threads/shutdowntest2.c
===================================================================
--- GNUnet/src/util/threads/shutdowntest2.c     2007-11-23 11:22:59 UTC (rev 
5741)
+++ GNUnet/src/util/threads/shutdowntest2.c     2007-11-23 11:51:54 UTC (rev 
5742)
@@ -29,16 +29,16 @@
 static int
 check ()
 {
-  if (GNUNET_SHUTDOWN_TEST () != NO)
+  if (GNUNET_shutdown_test () != GNUNET_NO)
     return 1;
 #ifndef MINGW
   kill (getpid (), SIGINT);
 #else
   GenerateConsoleCtrlEvent (CTRL_C_EVENT, 0);
 #endif
-  if (GNUNET_SHUTDOWN_TEST () != YES)
+  if (GNUNET_shutdown_test () != GNUNET_YES)
     return 2;
-  GNUNET_SHUTDOWN_WAITFOR ();
+  GNUNET_shutdown_wait_for ();
   return 0;
 }
 

Modified: GNUnet/src/util/threads/signal.c
===================================================================
--- GNUnet/src/util/threads/signal.c    2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/threads/signal.c    2007-11-23 11:51:54 UTC (rev 5742)
@@ -29,22 +29,22 @@
 #include "platform.h"
 
 #ifndef MINGW
-typedef struct SignalHandlerContext
+typedef struct GNUNET_SignalHandlerContext
 {
   int sig;
 
-  SignalHandler method;
+  GNUNET_SignalHandler method;
 
   struct sigaction oldsig;
 } SignalHandlerContext;
 
-struct SignalHandlerContext *
-signal_handler_install (int signal, SignalHandler handler)
+struct GNUNET_SignalHandlerContext *
+GNUNET_signal_handler_install (int signal, GNUNET_SignalHandler handler)
 {
-  struct SignalHandlerContext *ret;
+  struct GNUNET_SignalHandlerContext *ret;
   struct sigaction sig;
 
-  ret = MALLOC (sizeof (struct SignalHandlerContext));
+  ret = GNUNET_malloc (sizeof (struct GNUNET_SignalHandlerContext));
   ret->sig = signal;
   ret->method = handler;
 
@@ -60,15 +60,15 @@
 }
 
 void
-signal_handler_uninstall (int signal,
-                          SignalHandler handler,
-                          struct SignalHandlerContext *ctx)
+GNUNET_signal_handler_uninstall (int signal,
+                                 GNUNET_SignalHandler handler,
+                                 struct GNUNET_SignalHandlerContext *ctx)
 {
   struct sigaction sig;
 
   GE_ASSERT (NULL, (ctx->sig == signal) && (ctx->method == handler));
   sigemptyset (&sig.sa_mask);
   sigaction (signal, &ctx->oldsig, &sig);
-  FREE (ctx);
+  GNUNET_free (ctx);
 }
 #endif

Modified: GNUnet/src/util/threads/time.c
===================================================================
--- GNUnet/src/util/threads/time.c      2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/threads/time.c      2007-11-23 11:51:54 UTC (rev 5742)
@@ -32,8 +32,8 @@
  *
  * @return the current time
  */
-cron_t
-get_time ()
+GNUNET_CronTime
+GNUNET_get_time ()
 {
   struct timeval tv;
 #ifndef WINDOWS
@@ -44,5 +44,5 @@
 #else
   gettimeofday (&tv, NULL);
 #endif
-  return (((cron_t) tv.tv_sec) * 1000) + (tv.tv_usec / 1000);
+  return (((GNUNET_CronTime) tv.tv_sec) * 1000) + (tv.tv_usec / 1000);
 }

Modified: GNUnet/src/util/threads/timertest.c
===================================================================
--- GNUnet/src/util/threads/timertest.c 2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/threads/timertest.c 2007-11-23 11:51:54 UTC (rev 5742)
@@ -27,15 +27,15 @@
 #include "gnunet_util.h"
 #include "platform.h"
 
-#define VERBOSE NO
+#define VERBOSE GNUNET_NO
 
 static int
 check ()
 {
-  cron_t now;
-  cron_t last;
-  TIME_T tnow;
-  TIME_T tlast;
+  GNUNET_CronTime now;
+  GNUNET_CronTime last;
+  GNUNET_Int32Time tnow;
+  GNUNET_Int32Time tlast;
   int i;
   unsigned long long cumDelta;
 
@@ -43,14 +43,14 @@
      increasing;
      measure precision of sleep and report;
      test that sleep is interrupted by signals; */
-  last = now = get_time ();
+  last = now = GNUNET_get_time ();
   while (now == last)
-    now = get_time ();
+    now = GNUNET_get_time ();
   if (now < last)
     return 1;
-  tnow = tlast = TIME (NULL);
+  tnow = tlast = GNUNET_get_time_int32 (NULL);
   while (tnow == tlast)
-    tnow = TIME (NULL);
+    tnow = GNUNET_get_time_int32 (NULL);
   if (tnow < tlast)
     return 2;
   cumDelta = 0;
@@ -58,27 +58,27 @@
 #define MAXV 1500
   for (i = 0; i < MAXV; i += INCR)
     {
-      last = get_time ();
-      PTHREAD_SLEEP (cronMILLIS * i);
-      now = get_time ();
+      last = GNUNET_get_time ();
+      GNUNET_thread_sleep (GNUNET_CRON_MILLISECONDS * i);
+      now = GNUNET_get_time ();
 #if VERBOSE
       fprintf (stderr,
                "%4llu ms requested, got: %4llu ms\n",
-               i * cronMILLIS, (now - last));
+               i * GNUNET_CRON_MILLISECONDS, (now - last));
 #endif
-      if (last + cronMILLIS * i < now)
-        cumDelta += (now - (last + cronMILLIS * i));
+      if (last + GNUNET_CRON_MILLISECONDS * i < now)
+        cumDelta += (now - (last + GNUNET_CRON_MILLISECONDS * i));
       else
-        cumDelta += ((last + cronMILLIS * i) - now);
+        cumDelta += ((last + GNUNET_CRON_MILLISECONDS * i) - now);
     }
   FPRINTF (stdout,
            "Sleep precision: %llu ms. ",
-           cumDelta / cronMILLIS / (MAXV / INCR));
-  if (cumDelta <= 10 * cronMILLIS * MAXV / INCR)
+           cumDelta / GNUNET_CRON_MILLISECONDS / (MAXV / INCR));
+  if (cumDelta <= 10 * GNUNET_CRON_MILLISECONDS * MAXV / INCR)
     fprintf (stdout, "Timer precision is excellent.\n");
-  else if (cumDelta <= 50 * cronMILLIS * MAXV / INCR)   /* 50 ms average 
deviation */
+  else if (cumDelta <= 50 * GNUNET_CRON_MILLISECONDS * MAXV / INCR)     /* 50 
ms average deviation */
     fprintf (stdout, "Timer precision is good.\n");
-  else if (cumDelta > 250 * cronMILLIS * MAXV / INCR)
+  else if (cumDelta > 250 * GNUNET_CRON_MILLISECONDS * MAXV / INCR)
     fprintf (stdout, "Timer precision is awful.\n");
   else
     fprintf (stdout, "Timer precision is acceptable.\n");

Modified: GNUnet/src/util/win/win.cc
===================================================================
--- GNUnet/src/util/win/win.cc  2007-11-23 11:22:59 UTC (rev 5741)
+++ GNUnet/src/util/win/win.cc  2007-11-23 11:51:54 UTC (rev 5742)
@@ -192,7 +192,7 @@
           
         snprintf(szEntry, 1000, "%s (%d.%d.%d.%d - %I64u)",
           pszIfName ? pszIfName : (char *) pTable->table[dwIfIdx].bDescr,
-          PRIP(ntohl(dwIP)),
+          GNUNET_PRIP(ntohl(dwIP)),
           *((unsigned long long *) bPhysAddr));
         szEntry[1000] = 0;
         
@@ -206,7 +206,7 @@
     GlobalFree(pTable);
   }
   
-  return YES;
+  return GNUNET_YES;
 }
 
 /**
@@ -840,7 +840,7 @@
   
   wbuf.buf = (char *) buf;
   wbuf.len = len;
-  ol = (WSAOVERLAPPED *) MALLOC(sizeof(WSAOVERLAPPED));
+  ol = (WSAOVERLAPPED *) GNUNET_malloc(sizeof(WSAOVERLAPPED));
   memset(ol, 0, sizeof(WSAOVERLAPPED));
   ol->hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
   
@@ -875,7 +875,7 @@
         
         ol = *it;
         CloseHandle(ol->hEvent);
-        FREE(ol);
+        GNUNET_free(ol);
         next = it;
         next++;
         lstOL.erase(it);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]