aboutsummaryrefslogtreecommitdiff
path: root/src/nissy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nissy.c')
-rw-r--r--src/nissy.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/nissy.c b/src/nissy.c
index f1d4cd1..2dd5a41 100644
--- a/src/nissy.c
+++ b/src/nissy.c
@@ -26,7 +26,8 @@ STATIC long long nissy_gendata_unsafe(
26#define GETCUBE_OPTIONS(S, F) { .option = S, .fix = F } 26#define GETCUBE_OPTIONS(S, F) { .option = S, .fix = F }
27struct { 27struct {
28 char *option; 28 char *option;
29 void (*fix)(long long *, long long *, long long *, long long *); 29 void (*fix)(long long *, long long *,
30 long long *, long long *, long long *);
30} getcube_options[] = { 31} getcube_options[] = {
31 GETCUBE_OPTIONS("fix", getcube_fix), 32 GETCUBE_OPTIONS("fix", getcube_fix),
32 GETCUBE_OPTIONS(NULL, NULL) 33 GETCUBE_OPTIONS(NULL, NULL)
@@ -254,12 +255,13 @@ nissy_getcube(
254 long long eo, 255 long long eo,
255 long long cp, 256 long long cp,
256 long long co, 257 long long co,
258 long long orient,
257 const char *options, 259 const char *options,
258 char result[static NISSY_SIZE_CUBE] 260 char result[static NISSY_SIZE_CUBE]
259) 261)
260{ 262{
261 int i; 263 int i;
262 cube_t c; 264 oriented_cube_t oc;
263 265
264 if (options == NULL) { 266 if (options == NULL) {
265 LOG("[getcube] Error: 'options' argument is NULL\n"); 267 LOG("[getcube] Error: 'options' argument is NULL\n");
@@ -268,18 +270,19 @@ nissy_getcube(
268 270
269 for (i = 0; getcube_options[i].option != NULL; i++) 271 for (i = 0; getcube_options[i].option != NULL; i++)
270 if (!strcmp(options, getcube_options[i].option)) 272 if (!strcmp(options, getcube_options[i].option))
271 getcube_options[i].fix(&ep, &eo, &cp, &co); 273 getcube_options[i].fix(&ep, &eo, &cp, &co, &orient);
272 274
273 c = getcube(ep, eo, cp, co); 275 oc.cube = getcube(ep, eo, cp, co);
276 oc.orientation = orient;
274 277
275 if (!isconsistent((oriented_cube_t){ .cube = c, .orientation = 0 })) { 278 if (!isconsistent(oc)) {
276 LOG("[getcube] Error: could not get cube with ep=%lld, " 279 LOG("[getcube] Error: could not get cube with ep=%lld, "
277 "eo=%lld, cp=%lld, co=%lld.\n", ep, eo, cp, co); 280 "eo=%lld, cp=%lld, co=%lld, orient=%lld.\n",
281 ep, eo, cp, co, orient);
278 return NISSY_ERROR_OPTIONS; 282 return NISSY_ERROR_OPTIONS;
279 } 283 }
280 284
281/* TODO: should support orientation */ 285 return write_result(oc, result);
282 return write_result((oriented_cube_t){.cube = c, .orientation = 0}, result);
283} 286}
284 287
285long long 288long long

Generated with cgit - Back to sebastiano.tronto.net