File: cl_callback_common.h

package info (click to toggle)
freecell-solver 5.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,256 kB
  • sloc: ansic: 28,700; perl: 10,050; xml: 5,600; python: 1,339; sh: 533; cpp: 275; makefile: 20; javascript: 8
file content (94 lines) | stat: -rw-r--r-- 2,752 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
 * This file is part of Freecell Solver. It is subject to the license terms in
 * the COPYING.txt file found in the top-level directory of this distribution
 * and at http://fc-solve.shlomifish.org/docs/distro/COPYING.html . No part of
 * Freecell Solver, including this file, may be copied, modified, propagated,
 * or distributed except according to the terms contained in the COPYING file.
 *
 * Copyright (c) 2016 Shlomi Fish
 */
#pragma once

#define IS_ARG(s) (!strcmp(arg_str, (s)))
#define IS_ARG_LONG(shrt, lng) (IS_ARG("-" shrt) || IS_ARG("--" lng))

static inline void set_iter_handler(void *const instance GCC_UNUSED,
    fc_solve_display_information_context *const dc GCC_UNUSED)
{
#ifndef FCS_WITHOUT_ITER_HANDLER
    freecell_solver_user_set_iter_handler_long(instance, my_iter_handler, dc);
#endif
}

static inline bool cmd_line_cb__handle_common(const char *const arg_str,
    void *const instance, fc_solve_display_information_context *const dc)
{
    if (IS_ARG_LONG("i", "iter-output"))
    {
        set_iter_handler(instance, dc);
        return TRUE;
    }
    else if (IS_ARG_LONG("s", "state-output"))
    {
        set_iter_handler(instance, dc);
        dc->debug_iter_state_output = TRUE;
        return TRUE;
    }
    else if (IS_ARG_LONG("p", "parseable-output"))
    {
#ifndef FC_SOLVE_IMPLICIT_PARSABLE_OUTPUT
        dc->parseable_output = TRUE;
#endif
        return TRUE;
    }
    else if (IS_ARG_LONG("c", "canonized-order-output"))
    {
        dc->canonized_order_output = TRUE;
        return TRUE;
    }
    else if (IS_ARG_LONG("t", "display-10-as-t"))
    {
#ifndef FC_SOLVE_IMPLICIT_T_RANK
        dc->display_10_as_t = TRUE;
#endif
        return TRUE;
    }
    else if (IS_ARG_LONG("m", "display-moves"))
    {
        dc->display_moves = TRUE;
        dc->display_states = FALSE;
        return TRUE;
    }
    else if (IS_ARG_LONG("sn", "standard-notation"))
    {
        dc->standard_notation = FC_SOLVE__STANDARD_NOTATION_REGULAR;
        return TRUE;
    }
    else if (IS_ARG_LONG("snx", "standard-notation-extended"))
    {
        dc->standard_notation = FC_SOLVE__STANDARD_NOTATION_EXTENDED;
        return TRUE;
    }
    else if (IS_ARG_LONG("sam", "display-states-and-moves"))
    {
        dc->display_moves = TRUE;
        dc->display_states = TRUE;
        return TRUE;
    }
    else if (IS_ARG_LONG("pi", "display-parent-iter"))
    {
        dc->display_parent_iter_num = TRUE;
        return TRUE;
    }
    else if (IS_ARG_LONG("sel", "show-exceeded-limits"))
    {
        dc->show_exceeded_limits = TRUE;
        return TRUE;
    }
    else if (IS_ARG_LONG("hoi", "hint-on-intractable"))
    {
        dc->hint_on_intract = TRUE;
        return TRUE;
    }
    return FALSE;
}