X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Ftestbed%2Fgenerate-underlay-topology.c;h=2e78c60be196423a061296d0a4b2e96b7d73d8f0;hb=7348fad86391b913ecc41f986066f260efb04633;hp=98d7dfc6f1e819dbc0bb22fec4e1f08fe88c3f08;hpb=8b69aded04512e71f742c2ee60be174af18a8759;p=oweals%2Fgnunet.git diff --git a/src/testbed/generate-underlay-topology.c b/src/testbed/generate-underlay-topology.c index 98d7dfc6f..2e78c60be 100644 --- a/src/testbed/generate-underlay-topology.c +++ b/src/testbed/generate-underlay-topology.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet - (C) 2008--2014 Christian Grothoff (and other contributing authors) + Copyright (C) 2008--2014 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -14,14 +14,14 @@ 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. + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /** * @file testbed/generate-underlay-topology.c * @brief Program to generate a database file containing given underlay topology - * @author Sree Harsha Totakura + * @author Sree Harsha Totakura */ #include "platform.h" @@ -70,7 +70,7 @@ enum GNUNET_TESTBED_TopologyOption topology; /** * The number of peers to include in the topology */ -static int num_peers; +static unsigned int num_peers; /** * program result @@ -165,10 +165,10 @@ setup_db (const char *dbfile) " ?1," " ?2," " ?3," - " ?4," + " ?4," " ?5);"; int ret; - + ret = GNUNET_SYSERR; if (SQLITE_OK != sqlite3_open (dbfile, &db)) { @@ -178,7 +178,9 @@ setup_db (const char *dbfile) if (0 != sqlite3_exec (db, query_create, NULL, NULL, NULL)) { LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_exec"); - FPRINTF (stderr, "Perhaps the database `%s' already exits.\n", dbfile); + FPRINTF (stderr, "Error: %d. Perhaps the database `%s' already exits.\n", + sqlite3_errcode (db), + dbfile); goto err_ret; } GNUNET_break (0 == sqlite3_exec (db, "PRAGMA synchronous = 0;", NULL, NULL, NULL)); @@ -216,9 +218,11 @@ run (void *cls, char *const *args, const char *cfgfile, unsigned int argc; argc = 0; + arg_uint1 = 0; /* make compilers happy */ + arg_uint2 = 0; /* make compilers happy */ if (NULL == args) { - LOG_ERROR (_("Need atleast 2 arguments\n")); + LOG_ERROR (_("Need at least 2 arguments\n")); return; } if (NULL == (dbfile = args[argc++])) @@ -238,6 +242,7 @@ run (void *cls, char *const *args, const char *cfgfile, LOG_ERROR (_("Invalid topology: %s\n"), topology_string); return; } + arg_str1 = NULL; /* parse for first TOPOOPT. This can either be arg_uint1 or arg_str1 */ switch (topology) { @@ -293,6 +298,7 @@ run (void *cls, char *const *args, const char *cfgfile, { case GNUNET_TESTBED_TOPOLOGY_LINE: case GNUNET_TESTBED_TOPOLOGY_RING: + case GNUNET_TESTBED_TOPOLOGY_STAR: case GNUNET_TESTBED_TOPOLOGY_CLIQUE: case GNUNET_TESTBED_TOPOLOGY_2D_TORUS: GNUNET_TESTBED_underlay_construct_ (num_peers, link_processor, NULL, @@ -329,13 +335,17 @@ int main (int argc, char *const argv[]) { struct GNUNET_GETOPT_CommandLineOption option[] = { - {'p', "num-peers", "COUNT", - gettext_noop ("create COUNT number of peers"), - GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers}, + + GNUNET_GETOPT_option_uint ('p', + "num-peers", + "COUNT", + gettext_noop ("create COUNT number of peers"), + &num_peers), GNUNET_GETOPT_OPTION_END }; + int ret; - + exit_result = GNUNET_SYSERR; ret = GNUNET_PROGRAM_run (argc, argv, "gnunet-underlay-topology", @@ -361,7 +371,7 @@ main (int argc, char *const argv[]) if (NULL != stmt_insert) sqlite3_finalize (stmt_insert); if (NULL != db) - sqlite3_close (db); + GNUNET_break (SQLITE_OK == sqlite3_close (db)); if ((GNUNET_OK != ret) || (GNUNET_OK != exit_result)) return 1; return 0;