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_json_lib.h"
29 /* #include "gnunet_auction_service.h" */
32 #define OUTCOME_PRIVATE 0
33 #define OUTCOME_PUBLIC 1
35 static int ret; /** Final status code. */
36 static char *fndesc; /** filename of the item description */
37 static char *fnprices; /** filename of the price map */
38 static struct GNUNET_TIME_Relative dround; /** max round duration */
39 static struct GNUNET_TIME_Relative dstart; /** time until auction starts */
40 static unsigned int m = FIRST_PRICE; /** auction parameter m */
41 static int outcome = OUTCOME_PRIVATE; /** outcome */
42 static int interactive; /** keep running in foreground */
46 * Main function that will be run by the scheduler.
49 * @param args remaining command-line arguments
50 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
51 * @param cfg configuration
57 const struct GNUNET_CONFIGURATION_Handle *cfg)
60 if (GNUNET_TIME_UNIT_ZERO.rel_value_us == dstart.rel_value_us)
62 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
63 "required argument --regtime missing or invalid (zero)\n");
66 if (GNUNET_TIME_UNIT_ZERO.rel_value_us == dround.rel_value_us)
68 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
69 "required argument --roundtime missing or invalid (zero)\n");
74 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
75 "required argument --description missing\n");
80 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
81 "required argument --pricemap missing\n");
94 * @param argc number of arguments from the command line
95 * @param argv command line arguments
96 * @return 0 ok, 1 on error
99 main (int argc, char *const *argv)
101 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
102 {'d', "description", "FILE",
103 gettext_noop ("description of the item to be sold"),
104 1, &GNUNET_GETOPT_set_filename, &fndesc},
105 {'p', "pricemap", "FILE",
106 gettext_noop ("mapping of possible prices"),
107 1, &GNUNET_GETOPT_set_filename, &fnprices},
108 {'r', "roundtime", "DURATION",
109 gettext_noop ("max duration per round"),
110 1, &GNUNET_GETOPT_set_relative_time, &dround},
111 {'s', "regtime", "DURATION",
112 gettext_noop ("duration until auction starts"),
113 1, &GNUNET_GETOPT_set_relative_time, &dstart},
115 gettext_noop ("number of items to sell\n"
116 "0 for first price auction\n"
117 ">0 for vickrey/M+1st price auction"),
118 1, &GNUNET_GETOPT_set_uint, &m},
119 {'u', "public", NULL,
120 gettext_noop ("public auction outcome"),
121 0, &GNUNET_GETOPT_set_one, &outcome},
122 {'i', "interactive", NULL,
123 gettext_noop ("keep running in foreground until auction completes"),
124 0, &GNUNET_GETOPT_set_one, &interactive},
125 GNUNET_GETOPT_OPTION_END
127 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
131 GNUNET_PROGRAM_run (argc, argv,
132 "gnunet-auction-create",
133 gettext_noop ("create a new auction and "
134 "start listening for bidders"),
138 GNUNET_free ((void*) argv);