2 * puzzles.h: header file for my puzzle collection
5 #ifndef PUZZLES_PUZZLES_H
6 #define PUZZLES_PUZZLES_H
15 #define lenof(array) ( sizeof(array) / sizeof(*(array)) )
23 #define IGNORE(x) ( (x) = (x) )
25 typedef struct midend_data midend_data
;
26 typedef struct random_state random_state
;
27 typedef struct game_params game_params
;
28 typedef struct game_state game_state
;
33 void fatal(char *fmt
, ...);
38 midend_data
*midend_new(void);
39 void midend_free(midend_data
*me
);
40 void midend_set_params(midend_data
*me
, game_params
*params
);
41 void midend_size(midend_data
*me
, int *x
, int *y
);
42 void midend_new_game(midend_data
*me
, char *seed
);
43 void midend_restart_game(midend_data
*me
);
44 void midend_undo(midend_data
*me
);
45 void midend_redo(midend_data
*me
);
46 int midend_process_key(midend_data
*me
, int x
, int y
, int button
);
51 void *smalloc(int size
);
52 void *srealloc(void *p
, int size
);
54 char *dupstr(char *s
);
56 ( (type *) smalloc (sizeof (type)) )
57 #define snewn(number, type) \
58 ( (type *) smalloc ((number) * sizeof (type)) )
59 #define sresize(array, number, type) \
60 ( (type *) srealloc ((array), (number) * sizeof (type)) )
65 random_state
*random_init(char *seed
, int len
);
66 unsigned long random_upto(random_state
*state
, unsigned long limit
);
67 void random_free(random_state
*state
);
70 * Game-specific routines
72 game_params
*default_params(void);
73 void free_params(game_params
*params
);
74 char *new_game_seed(game_params
*params
);
75 game_state
*new_game(game_params
*params
, char *seed
);
76 game_state
*dup_game(game_state
*state
);
77 void free_game(game_state
*state
);
78 game_state
*make_move(game_state
*from
, int x
, int y
, int button
);
79 void game_size(game_params
*params
, int *x
, int *y
);
81 #endif /* PUZZLES_PUZZLES_H */