1 // This file is part of Freecell Solver. It is subject to the license terms in
2 // the COPYING.txt file found in the top-level directory of this distribution
3 // and at http://fc-solve.shlomifish.org/docs/distro/COPYING.html . No part of
4 // Freecell Solver, including this file, may be copied, modified, propagated,
5 // or distributed except according to the terms contained in the COPYING file.
6 //
7 // Copyright (c) 2016 Shlomi Fish
8 #pragma once
9 #include <assert.h>
10
11 #ifdef NDEBUG
12 #define my2assert(x) \
13 if (!(x)) \
14 { \
15 abort(); \
16 }
17 #else
18 #define my2assert(x) assert(x)
19 #endif
20 #define USER_STATE_SIZE 1024
21
22 typedef struct
23 {
24 char s[USER_STATE_SIZE];
25 } fcs_user_state_str;
26
read_state(FILE * f)27 static inline fcs_user_state_str read_state(FILE *f)
28 {
29 fcs_user_state_str user_state;
30 memset(user_state.s, '\0', sizeof(user_state));
31 if (f)
32 {
33 if (fread(user_state.s, sizeof(user_state.s[0]), USER_STATE_SIZE - 1,
34 f) == 0)
35 {
36 user_state.s[0] = 0;
37 }
38 fclose(f);
39 }
40
41 return user_state;
42 }
43