aboutsummaryrefslogtreecommitdiff
path: root/src/auction
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
commitc4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch)
treecac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/auction
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/auction')
-rw-r--r--src/auction/auction.h3
-rw-r--r--src/auction/gnunet-auction-create.c225
-rw-r--r--src/auction/gnunet-auction-info.c28
-rw-r--r--src/auction/gnunet-auction-join.c28
-rw-r--r--src/auction/gnunet-service-auction.c46
-rw-r--r--src/auction/test_auction_api.c6
6 files changed, 170 insertions, 166 deletions
diff --git a/src/auction/auction.h b/src/auction/auction.h
index 8324e1cb1..dc8b933f6 100644
--- a/src/auction/auction.h
+++ b/src/auction/auction.h
@@ -34,7 +34,8 @@ GNUNET_NETWORK_STRUCT_BEGIN
34/** 34/**
35 * Auction creation request sent from the client to the service 35 * Auction creation request sent from the client to the service
36 */ 36 */
37struct GNUNET_AUCTION_ClientCreateMessage { 37struct GNUNET_AUCTION_ClientCreateMessage
38{
38 /** 39 /**
39 * Type: GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_CREATE 40 * Type: GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_CREATE
40 */ 41 */
diff --git a/src/auction/gnunet-auction-create.c b/src/auction/gnunet-auction-create.c
index 42ab14aca..90c1d5f10 100644
--- a/src/auction/gnunet-auction-create.c
+++ b/src/auction/gnunet-auction-create.c
@@ -54,10 +54,10 @@ static int interactive; /** keep running in foreground */
54 * @param cfg configuration 54 * @param cfg configuration
55 */ 55 */
56static void 56static void
57run(void *cls, 57run (void *cls,
58 char *const *args, 58 char *const *args,
59 const char *cfgfile, 59 const char *cfgfile,
60 const struct GNUNET_CONFIGURATION_Handle *cfg) 60 const struct GNUNET_CONFIGURATION_Handle *cfg)
61{ 61{
62 unsigned int i; 62 unsigned int i;
63 double cur, prev = DBL_MAX; 63 double cur, prev = DBL_MAX;
@@ -68,72 +68,72 @@ run(void *cls,
68 68
69 /* cmdline parsing */ 69 /* cmdline parsing */
70 if (GNUNET_TIME_UNIT_ZERO.rel_value_us == dstart.rel_value_us) 70 if (GNUNET_TIME_UNIT_ZERO.rel_value_us == dstart.rel_value_us)
71 { 71 {
72 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 72 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
73 "required argument --regtime missing or invalid (zero)\n"); 73 "required argument --regtime missing or invalid (zero)\n");
74 goto fail; 74 goto fail;
75 } 75 }
76 if (GNUNET_TIME_UNIT_ZERO.rel_value_us == dround.rel_value_us) 76 if (GNUNET_TIME_UNIT_ZERO.rel_value_us == dround.rel_value_us)
77 { 77 {
78 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 78 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
79 "required argument --roundtime missing or invalid (zero)\n"); 79 "required argument --roundtime missing or invalid (zero)\n");
80 goto fail; 80 goto fail;
81 } 81 }
82 if (!fndesc) 82 if (! fndesc)
83 { 83 {
84 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 84 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
85 "required argument --description missing\n"); 85 "required argument --description missing\n");
86 goto fail; 86 goto fail;
87 } 87 }
88 if (!fnprices) 88 if (! fnprices)
89 { 89 {
90 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 90 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
91 "required argument --pricemap missing\n"); 91 "required argument --pricemap missing\n");
92 goto fail; 92 goto fail;
93 } 93 }
94 94
95 /* parse and check pricemap validity */ 95 /* parse and check pricemap validity */
96 if (!(pmap = json_load_file(fnprices, JSON_DECODE_INT_AS_REAL, &jerr))) 96 if (! (pmap = json_load_file (fnprices, JSON_DECODE_INT_AS_REAL, &jerr)))
97 { 97 {
98 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 98 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
99 "parsing pricemap json at %d:%d: %s\n", 99 "parsing pricemap json at %d:%d: %s\n",
100 jerr.line, jerr.column, jerr.text); 100 jerr.line, jerr.column, jerr.text);
101 goto fail; 101 goto fail;
102 } 102 }
103 if (-1 == json_unpack_ex(pmap, &jerr, JSON_VALIDATE_ONLY, 103 if (-1 == json_unpack_ex (pmap, &jerr, JSON_VALIDATE_ONLY,
104 "{s:s, s:[]}", "currency", "prices")) 104 "{s:s, s:[]}", "currency", "prices"))
105 { 105 {
106 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 106 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
107 "validating pricemap: %s\n", jerr.text); 107 "validating pricemap: %s\n", jerr.text);
108 goto fail; 108 goto fail;
109 } 109 }
110 if (!(parray = json_object_get(pmap, "prices")) || !json_is_array(parray)) 110 if (! (parray = json_object_get (pmap, "prices")) || ! json_is_array (parray))
111 {
112 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
113 "could not get `prices` array node from pricemap\n");
114 goto fail;
115 }
116 if (0 == json_array_size (parray))
117 {
118 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "empty pricemap array\n");
119 goto fail;
120 }
121 json_array_foreach (parray, i, pnode)
122 {
123 if (-1 == json_unpack_ex (pnode, &jerr, 0, "F", &cur))
111 { 124 {
112 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 125 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
113 "could not get `prices` array node from pricemap\n"); 126 "validating pricearray index %d: %s\n", i, jerr.text);
114 goto fail; 127 goto fail;
115 } 128 }
116 if (0 == json_array_size(parray)) 129 if (prev <= cur)
117 { 130 {
118 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "empty pricemap array\n"); 131 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
132 "validating pricearray index %d: "
133 "prices must be strictly monotonically decreasing\n",
134 i);
119 goto fail; 135 goto fail;
120 } 136 }
121 json_array_foreach(parray, i, pnode)
122 {
123 if (-1 == json_unpack_ex(pnode, &jerr, 0, "F", &cur))
124 {
125 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
126 "validating pricearray index %d: %s\n", i, jerr.text);
127 goto fail;
128 }
129 if (prev <= cur)
130 {
131 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
132 "validating pricearray index %d: "
133 "prices must be strictly monotonically decreasing\n",
134 i);
135 goto fail;
136 }
137 prev = cur; 137 prev = cur;
138 } 138 }
139 139
@@ -153,64 +153,67 @@ fail:
153 * @return 0 ok, 1 on error 153 * @return 0 ok, 1 on error
154 */ 154 */
155int 155int
156main(int argc, char *const *argv) 156main (int argc, char *const *argv)
157{ 157{
158 struct GNUNET_GETOPT_CommandLineOption options[] = { 158 struct GNUNET_GETOPT_CommandLineOption options[] = {
159 GNUNET_GETOPT_option_filename('d', 159 GNUNET_GETOPT_option_filename ('d',
160 "description", 160 "description",
161 "FILE", 161 "FILE",
162 gettext_noop("description of the item to be sold"), 162 gettext_noop (
163 &fndesc), 163 "description of the item to be sold"),
164 164 &fndesc),
165 GNUNET_GETOPT_option_filename('p', 165
166 "pricemap", 166 GNUNET_GETOPT_option_filename ('p',
167 "FILE", 167 "pricemap",
168 gettext_noop("mapping of possible prices"), 168 "FILE",
169 &fnprices), 169 gettext_noop ("mapping of possible prices"),
170 170 &fnprices),
171 GNUNET_GETOPT_option_relative_time('r', 171
172 "roundtime", 172 GNUNET_GETOPT_option_relative_time ('r',
173 "DURATION", 173 "roundtime",
174 gettext_noop("max duration per round"), 174 "DURATION",
175 &dround), 175 gettext_noop ("max duration per round"),
176 176 &dround),
177 GNUNET_GETOPT_option_relative_time('s', 177
178 "regtime", 178 GNUNET_GETOPT_option_relative_time ('s',
179 "DURATION", 179 "regtime",
180 gettext_noop("duration until auction starts"), 180 "DURATION",
181 &dstart), 181 gettext_noop (
182 GNUNET_GETOPT_option_uint('m', 182 "duration until auction starts"),
183 "m", 183 &dstart),
184 "NUMBER", 184 GNUNET_GETOPT_option_uint ('m',
185 gettext_noop("number of items to sell\n" 185 "m",
186 "0 for first price auction\n" 186 "NUMBER",
187 ">0 for vickrey/M+1st price auction"), 187 gettext_noop ("number of items to sell\n"
188 &m), 188 "0 for first price auction\n"
189 189 ">0 for vickrey/M+1st price auction"),
190 GNUNET_GETOPT_option_flag('u', 190 &m),
191 "public", 191
192 gettext_noop("public auction outcome"), 192 GNUNET_GETOPT_option_flag ('u',
193 &outcome), 193 "public",
194 194 gettext_noop ("public auction outcome"),
195 GNUNET_GETOPT_option_flag('i', 195 &outcome),
196 "interactive", 196
197 gettext_noop("keep running in foreground until auction completes"), 197 GNUNET_GETOPT_option_flag ('i',
198 &interactive), 198 "interactive",
199 gettext_noop (
200 "keep running in foreground until auction completes"),
201 &interactive),
199 202
200 GNUNET_GETOPT_OPTION_END 203 GNUNET_GETOPT_OPTION_END
201 }; 204 };
202 205
203 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv)) 206 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
204 return 2; 207 return 2;
205 208
206 ret = (GNUNET_OK == 209 ret = (GNUNET_OK ==
207 GNUNET_PROGRAM_run(argc, argv, 210 GNUNET_PROGRAM_run (argc, argv,
208 "gnunet-auction-create", 211 "gnunet-auction-create",
209 gettext_noop("create a new auction and " 212 gettext_noop ("create a new auction and "
210 "start listening for bidders"), 213 "start listening for bidders"),
211 options, 214 options,
212 &run, 215 &run,
213 NULL)) ? ret : 1; 216 NULL)) ? ret : 1;
214 GNUNET_free((void*)argv); 217 GNUNET_free ((void*) argv);
215 return ret; 218 return ret;
216} 219}
diff --git a/src/auction/gnunet-auction-info.c b/src/auction/gnunet-auction-info.c
index ef46ca212..05bee50ef 100644
--- a/src/auction/gnunet-auction-info.c
+++ b/src/auction/gnunet-auction-info.c
@@ -42,10 +42,10 @@ static int ret;
42 * @param cfg configuration 42 * @param cfg configuration
43 */ 43 */
44static void 44static void
45run(void *cls, 45run (void *cls,
46 char *const *args, 46 char *const *args,
47 const char *cfgfile, 47 const char *cfgfile,
48 const struct GNUNET_CONFIGURATION_Handle *cfg) 48 const struct GNUNET_CONFIGURATION_Handle *cfg)
49{ 49{
50 /* main code here */ 50 /* main code here */
51} 51}
@@ -59,7 +59,7 @@ run(void *cls,
59 * @return 0 ok, 1 on error 59 * @return 0 ok, 1 on error
60 */ 60 */
61int 61int
62main(int argc, char *const *argv) 62main (int argc, char *const *argv)
63{ 63{
64 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 64 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
65 /* FIMXE: add options here */ 65 /* FIMXE: add options here */
@@ -67,18 +67,18 @@ main(int argc, char *const *argv)
67 }; 67 };
68 68
69 if (GNUNET_OK != 69 if (GNUNET_OK !=
70 GNUNET_STRINGS_get_utf8_args(argc, argv, 70 GNUNET_STRINGS_get_utf8_args (argc, argv,
71 &argc, &argv)) 71 &argc, &argv))
72 return 2; 72 return 2;
73 73
74 ret = (GNUNET_OK == 74 ret = (GNUNET_OK ==
75 GNUNET_PROGRAM_run(argc, argv, 75 GNUNET_PROGRAM_run (argc, argv,
76 "gnunet-auction", 76 "gnunet-auction",
77 gettext_noop("help text"), 77 gettext_noop ("help text"),
78 options, 78 options,
79 &run, 79 &run,
80 NULL)) ? ret : 1; 80 NULL)) ? ret : 1;
81 GNUNET_free((void*)argv); 81 GNUNET_free ((void*) argv);
82 return ret; 82 return ret;
83} 83}
84 84
diff --git a/src/auction/gnunet-auction-join.c b/src/auction/gnunet-auction-join.c
index ef46ca212..05bee50ef 100644
--- a/src/auction/gnunet-auction-join.c
+++ b/src/auction/gnunet-auction-join.c
@@ -42,10 +42,10 @@ static int ret;
42 * @param cfg configuration 42 * @param cfg configuration
43 */ 43 */
44static void 44static void
45run(void *cls, 45run (void *cls,
46 char *const *args, 46 char *const *args,
47 const char *cfgfile, 47 const char *cfgfile,
48 const struct GNUNET_CONFIGURATION_Handle *cfg) 48 const struct GNUNET_CONFIGURATION_Handle *cfg)
49{ 49{
50 /* main code here */ 50 /* main code here */
51} 51}
@@ -59,7 +59,7 @@ run(void *cls,
59 * @return 0 ok, 1 on error 59 * @return 0 ok, 1 on error
60 */ 60 */
61int 61int
62main(int argc, char *const *argv) 62main (int argc, char *const *argv)
63{ 63{
64 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 64 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
65 /* FIMXE: add options here */ 65 /* FIMXE: add options here */
@@ -67,18 +67,18 @@ main(int argc, char *const *argv)
67 }; 67 };
68 68
69 if (GNUNET_OK != 69 if (GNUNET_OK !=
70 GNUNET_STRINGS_get_utf8_args(argc, argv, 70 GNUNET_STRINGS_get_utf8_args (argc, argv,
71 &argc, &argv)) 71 &argc, &argv))
72 return 2; 72 return 2;
73 73
74 ret = (GNUNET_OK == 74 ret = (GNUNET_OK ==
75 GNUNET_PROGRAM_run(argc, argv, 75 GNUNET_PROGRAM_run (argc, argv,
76 "gnunet-auction", 76 "gnunet-auction",
77 gettext_noop("help text"), 77 gettext_noop ("help text"),
78 options, 78 options,
79 &run, 79 &run,
80 NULL)) ? ret : 1; 80 NULL)) ? ret : 1;
81 GNUNET_free((void*)argv); 81 GNUNET_free ((void*) argv);
82 return ret; 82 return ret;
83} 83}
84 84
diff --git a/src/auction/gnunet-service-auction.c b/src/auction/gnunet-service-auction.c
index ed1be20d8..82519919d 100644
--- a/src/auction/gnunet-service-auction.c
+++ b/src/auction/gnunet-service-auction.c
@@ -36,7 +36,7 @@
36 * @return #GNUNET_OK (always) 36 * @return #GNUNET_OK (always)
37 */ 37 */
38static int 38static int
39check_create(void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg) 39check_create (void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
40{ 40{
41 /* always well-formed due to arbitrary length description */ 41 /* always well-formed due to arbitrary length description */
42 return GNUNET_OK; 42 return GNUNET_OK;
@@ -50,7 +50,7 @@ check_create(void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
50 * @param msg the actual message received 50 * @param msg the actual message received
51 */ 51 */
52static void 52static void
53handle_create(void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg) 53handle_create (void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
54{ 54{
55 struct GNUNET_SERVICE_Client *client = cls; 55 struct GNUNET_SERVICE_Client *client = cls;
56// struct GNUNET_MQ_Handle *mq; 56// struct GNUNET_MQ_Handle *mq;
@@ -58,10 +58,10 @@ handle_create(void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
58// struct GNUNET_AUCTION_blabla em; 58// struct GNUNET_AUCTION_blabla em;
59 uint16_t size; 59 uint16_t size;
60 60
61 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 61 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
62 "Received CREATE message from client\n"); 62 "Received CREATE message from client\n");
63 63
64 size = ntohs(msg->header.size); 64 size = ntohs (msg->header.size);
65 65
66 /**TODO: create auction and return auction object */ 66 /**TODO: create auction and return auction object */
67// mq = GNUNET_SERVICE_client_get_mq (client); 67// mq = GNUNET_SERVICE_client_get_mq (client);
@@ -69,7 +69,7 @@ handle_create(void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
69// env = GNUNET_MQ_msg_copy (&em.header); 69// env = GNUNET_MQ_msg_copy (&em.header);
70// GNUNET_MQ_send (mq, env); 70// GNUNET_MQ_send (mq, env);
71 71
72 GNUNET_SERVICE_client_continue(client); 72 GNUNET_SERVICE_client_continue (client);
73} 73}
74 74
75 75
@@ -79,7 +79,7 @@ handle_create(void *cls, const struct GNUNET_AUCTION_ClientCreateMessage *msg)
79 * @param cls unused 79 * @param cls unused
80 */ 80 */
81static void 81static void
82cleanup_task(void *cls) 82cleanup_task (void *cls)
83{ 83{
84 /* FIXME: do clean up here */ 84 /* FIXME: do clean up here */
85} 85}
@@ -94,9 +94,9 @@ cleanup_task(void *cls)
94 * @return @a c 94 * @return @a c
95 */ 95 */
96static void * 96static void *
97client_connect_cb(void *cls, 97client_connect_cb (void *cls,
98 struct GNUNET_SERVICE_Client *c, 98 struct GNUNET_SERVICE_Client *c,
99 struct GNUNET_MQ_Handle *mq) 99 struct GNUNET_MQ_Handle *mq)
100{ 100{
101 return c; 101 return c;
102} 102}
@@ -110,11 +110,11 @@ client_connect_cb(void *cls,
110 * @param internal_cls should be equal to @a c 110 * @param internal_cls should be equal to @a c
111 */ 111 */
112static void 112static void
113client_disconnect_cb(void *cls, 113client_disconnect_cb (void *cls,
114 struct GNUNET_SERVICE_Client *c, 114 struct GNUNET_SERVICE_Client *c,
115 void *internal_cls) 115 void *internal_cls)
116{ 116{
117 GNUNET_assert(c == internal_cls); 117 GNUNET_assert (c == internal_cls);
118} 118}
119 119
120 120
@@ -126,12 +126,12 @@ client_disconnect_cb(void *cls,
126 * @param service the initialized service 126 * @param service the initialized service
127 */ 127 */
128static void 128static void
129run(void *cls, 129run (void *cls,
130 const struct GNUNET_CONFIGURATION_Handle *cfg, 130 const struct GNUNET_CONFIGURATION_Handle *cfg,
131 struct GNUNET_SERVICE_Handle *service) 131 struct GNUNET_SERVICE_Handle *service)
132{ 132{
133 /* FIXME: do setup here */ 133 /* FIXME: do setup here */
134 GNUNET_SCHEDULER_add_shutdown(&cleanup_task, NULL); 134 GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL);
135} 135}
136 136
137 137
@@ -145,11 +145,11 @@ GNUNET_SERVICE_MAIN
145 &client_connect_cb, 145 &client_connect_cb,
146 &client_disconnect_cb, 146 &client_disconnect_cb,
147 NULL, 147 NULL,
148 GNUNET_MQ_hd_var_size(create, 148 GNUNET_MQ_hd_var_size (create,
149 GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_CREATE, 149 GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_CREATE,
150 struct GNUNET_AUCTION_ClientCreateMessage, 150 struct GNUNET_AUCTION_ClientCreateMessage,
151 NULL), 151 NULL),
152 GNUNET_MQ_handler_end()) 152 GNUNET_MQ_handler_end ())
153 153
154 154
155/* end of gnunet-service-auction.c */ 155/* end of gnunet-service-auction.c */
diff --git a/src/auction/test_auction_api.c b/src/auction/test_auction_api.c
index 39a002a5f..0ec6f8cc8 100644
--- a/src/auction/test_auction_api.c
+++ b/src/auction/test_auction_api.c
@@ -24,17 +24,17 @@
24#include "platform.h" 24#include "platform.h"
25 25
26static int 26static int
27check() 27check ()
28{ 28{
29 return 0; 29 return 0;
30} 30}
31 31
32int 32int
33main(int argc, char *argv[]) 33main (int argc, char *argv[])
34{ 34{
35 int ret; 35 int ret;
36 36
37 ret = check(); 37 ret = check ();
38 38
39 return ret; 39 return ret;
40} 40}