aboutsummaryrefslogtreecommitdiff
path: root/src/auction
diff options
context:
space:
mode:
Diffstat (limited to 'src/auction')
-rw-r--r--src/auction/Makefile.am4
-rw-r--r--src/auction/gnunet-auction-create.c60
2 files changed, 54 insertions, 10 deletions
diff --git a/src/auction/Makefile.am b/src/auction/Makefile.am
index 18a3e5604..8518244fa 100644
--- a/src/auction/Makefile.am
+++ b/src/auction/Makefile.am
@@ -28,24 +28,28 @@ gnunet_auction_create_SOURCES = \
28 gnunet-auction-create.c 28 gnunet-auction-create.c
29gnunet_auction_create_LDADD = \ 29gnunet_auction_create_LDADD = \
30 $(top_builddir)/src/util/libgnunetutil.la \ 30 $(top_builddir)/src/util/libgnunetutil.la \
31 -ljansson \
31 $(GN_LIBINTL) 32 $(GN_LIBINTL)
32 33
33gnunet_auction_info_SOURCES = \ 34gnunet_auction_info_SOURCES = \
34 gnunet-auction-info.c 35 gnunet-auction-info.c
35gnunet_auction_info_LDADD = \ 36gnunet_auction_info_LDADD = \
36 $(top_builddir)/src/util/libgnunetutil.la \ 37 $(top_builddir)/src/util/libgnunetutil.la \
38 -ljansson \
37 $(GN_LIBINTL) 39 $(GN_LIBINTL)
38 40
39gnunet_auction_join_SOURCES = \ 41gnunet_auction_join_SOURCES = \
40 gnunet-auction-join.c 42 gnunet-auction-join.c
41gnunet_auction_join_LDADD = \ 43gnunet_auction_join_LDADD = \
42 $(top_builddir)/src/util/libgnunetutil.la \ 44 $(top_builddir)/src/util/libgnunetutil.la \
45 -ljansson \
43 $(GN_LIBINTL) 46 $(GN_LIBINTL)
44 47
45gnunet_service_auction_SOURCES = \ 48gnunet_service_auction_SOURCES = \
46 gnunet-service-auction.c 49 gnunet-service-auction.c
47gnunet_service_auction_LDADD = \ 50gnunet_service_auction_LDADD = \
48 $(top_builddir)/src/util/libgnunetutil.la \ 51 $(top_builddir)/src/util/libgnunetutil.la \
52 -ljansson \
49 $(GN_LIBINTL) 53 $(GN_LIBINTL)
50 54
51 55
diff --git a/src/auction/gnunet-auction-create.c b/src/auction/gnunet-auction-create.c
index fd3fcdabe..c21e93f26 100644
--- a/src/auction/gnunet-auction-create.c
+++ b/src/auction/gnunet-auction-create.c
@@ -25,15 +25,21 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_json_lib.h"
28/* #include "gnunet_auction_service.h" */ 29/* #include "gnunet_auction_service.h" */
29 30
31#define FIRST_PRICE 0
32#define OUTCOME_PRIVATE 0
33#define OUTCOME_PUBLIC 1
34
30static int ret; /** Final status code. */ 35static int ret; /** Final status code. */
31static char *fndesc; /** filename of the item description */ 36static char *fndesc; /** filename of the item description */
32static char *fnprices; /** filename of the price map */ 37static char *fnprices; /** filename of the price map */
33static struct GNUNET_TIME_Relative dround; /** max round duration */ 38static struct GNUNET_TIME_Relative dround; /** max round duration */
34static struct GNUNET_TIME_Relative dstart; /** time until auction starts */ 39static struct GNUNET_TIME_Relative dstart; /** time until auction starts */
35static unsigned int m = 0; /** auction parameter m */ 40static unsigned int m = FIRST_PRICE; /** auction parameter m */
36static int public = 0; /** public outcome */ 41static int outcome = OUTCOME_PRIVATE; /** outcome */
42static int interactive; /** keep running in foreground */
37 43
38 44
39/** 45/**
@@ -50,7 +56,35 @@ run (void *cls,
50 const char *cfgfile, 56 const char *cfgfile,
51 const struct GNUNET_CONFIGURATION_Handle *cfg) 57 const struct GNUNET_CONFIGURATION_Handle *cfg)
52{ 58{
53 /* main code here */ 59 /* cmdline parsing */
60 if (GNUNET_TIME_UNIT_ZERO.rel_value_us == dstart.rel_value_us)
61 {
62 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
63 "required argument --regtime missing or invalid (zero)\n");
64 goto fail;
65 }
66 if (GNUNET_TIME_UNIT_ZERO.rel_value_us == dround.rel_value_us)
67 {
68 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
69 "required argument --roundtime missing or invalid (zero)\n");
70 goto fail;
71 }
72 if (!fndesc)
73 {
74 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
75 "required argument --description missing\n");
76 goto fail;
77 }
78 if (!fnprices)
79 {
80 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
81 "required argument --pricemap missing\n");
82 goto fail;
83 }
84
85fail:
86 ret = 1;
87 return;
54} 88}
55 89
56 90
@@ -68,21 +102,26 @@ main (int argc, char *const *argv)
68 {'d', "description", "FILE", 102 {'d', "description", "FILE",
69 gettext_noop ("description of the item to be sold"), 103 gettext_noop ("description of the item to be sold"),
70 1, &GNUNET_GETOPT_set_filename, &fndesc}, 104 1, &GNUNET_GETOPT_set_filename, &fndesc},
71 {'c', "costmap", "FILE", 105 {'p', "pricemap", "FILE",
72 gettext_noop ("mapping of possible prices"), 106 gettext_noop ("mapping of possible prices"),
73 1, &GNUNET_GETOPT_set_filename, &fnprices}, 107 1, &GNUNET_GETOPT_set_filename, &fnprices},
74 {'r', "roundtime", "DURATION", 108 {'r', "roundtime", "DURATION",
75 gettext_noop ("max duration per round"), 109 gettext_noop ("max duration per round"),
76 1, &GNUNET_GETOPT_set_relative_time, &dround}, 110 1, &GNUNET_GETOPT_set_relative_time, &dround},
77 {'s', "starttime", "DURATION", 111 {'s', "regtime", "DURATION",
78 gettext_noop ("duration until auction starts"), 112 gettext_noop ("duration until auction starts"),
79 1, &GNUNET_GETOPT_set_relative_time, &dstart}, 113 1, &GNUNET_GETOPT_set_relative_time, &dstart},
80 {'m', "m", "NUMBER", 114 {'m', "m", "NUMBER",
81 gettext_noop ("number of items to sell, 0 for first price auction"), 115 gettext_noop ("number of items to sell\n"
82 0, &GNUNET_GETOPT_set_uint, &m}, 116 "0 for first price auction\n"
83 {'p', "public", NULL, 117 ">0 for vickrey/M+1st price auction"),
118 1, &GNUNET_GETOPT_set_uint, &m},
119 {'u', "public", NULL,
84 gettext_noop ("public auction outcome"), 120 gettext_noop ("public auction outcome"),
85 0, &GNUNET_GETOPT_set_one, &public}, 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},
86 GNUNET_GETOPT_OPTION_END 125 GNUNET_GETOPT_OPTION_END
87 }; 126 };
88 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 127 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
@@ -91,7 +130,8 @@ main (int argc, char *const *argv)
91 ret = (GNUNET_OK == 130 ret = (GNUNET_OK ==
92 GNUNET_PROGRAM_run (argc, argv, 131 GNUNET_PROGRAM_run (argc, argv,
93 "gnunet-auction-create", 132 "gnunet-auction-create",
94 gettext_noop ("help text"), 133 gettext_noop ("create a new auction and "
134 "start listening for bidders"),
95 options, 135 options,
96 &run, 136 &run,
97 NULL)) ? ret : 1; 137 NULL)) ? ret : 1;