2 This file is part of GNUnet.
3 Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 GNUnet e.V.
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @file auction/gnunet-auction-create.c
23 * @brief tool to create a new auction
24 * @author Markus Teich
27 #include "gnunet_util_lib.h"
28 /* #include "gnunet_auction_service.h" */
31 #define OUTCOME_PRIVATE 0
32 #define OUTCOME_PUBLIC 1
34 static int ret; /** Final status code. */
35 static char *fndesc; /** filename of the item description */
36 static char *fnprices; /** filename of the price map */
37 static struct GNUNET_TIME_Relative dround; /** max round duration */
38 static struct GNUNET_TIME_Relative dstart; /** time until auction starts */
39 static unsigned int m = FIRST_PRICE; /** auction parameter m */
40 static int outcome = OUTCOME_PRIVATE; /** outcome */
41 static int interactive; /** keep running in foreground */
45 * Main function that will be run by the scheduler.
48 * @param args remaining command-line arguments
49 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
50 * @param cfg configuration
56 const struct GNUNET_CONFIGURATION_Handle *cfg)
59 if (GNUNET_TIME_UNIT_ZERO.rel_value_us == dstart.rel_value_us)
61 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
62 "required argument --regtime missing or invalid (zero)\n");
65 if (GNUNET_TIME_UNIT_ZERO.rel_value_us == dround.rel_value_us)
67 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
68 "required argument --roundtime missing or invalid (zero)\n");
73 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
74 "required argument --description missing\n");
79 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
80 "required argument --pricemap missing\n");
93 * @param argc number of arguments from the command line
94 * @param argv command line arguments
95 * @return 0 ok, 1 on error
98 main (int argc, char *const *argv)
100 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
101 {'d', "description", "FILE",
102 gettext_noop ("description of the item to be sold"),
103 1, &GNUNET_GETOPT_set_filename, &fndesc},
104 {'p', "pricemap", "FILE",
105 gettext_noop ("mapping of possible prices"),
106 1, &GNUNET_GETOPT_set_filename, &fnprices},
107 {'r', "roundtime", "DURATION",
108 gettext_noop ("max duration per round"),
109 1, &GNUNET_GETOPT_set_relative_time, &dround},
110 {'s', "regtime", "DURATION",
111 gettext_noop ("duration until auction starts"),
112 1, &GNUNET_GETOPT_set_relative_time, &dstart},
114 gettext_noop ("number of items to sell\n"
115 "0 for first price auction\n"
116 ">0 for vickrey/M+1st price auction"),
117 1, &GNUNET_GETOPT_set_uint, &m},
118 {'u', "public", NULL,
119 gettext_noop ("public auction outcome"),
120 0, &GNUNET_GETOPT_set_one, &outcome},
121 {'i', "interactive", NULL,
122 gettext_noop ("keep running in foreground until auction completes"),
123 0, &GNUNET_GETOPT_set_one, &interactive},
124 GNUNET_GETOPT_OPTION_END
126 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
130 GNUNET_PROGRAM_run (argc, argv,
131 "gnunet-auction-create",
132 gettext_noop ("create a new auction and "
133 "start listening for bidders"),
137 GNUNET_free ((void*) argv);