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)) )
26 void fatal(char *fmt
, ...);
31 void *smalloc(int size
);
32 void *srealloc(void *p
, int size
);
34 char *dupstr(char *s
);
36 ( (type *) smalloc (sizeof (type)) )
37 #define snewn(number, type) \
38 ( (type *) smalloc ((number) * sizeof (type)) )
39 #define sresize(array, number, type) \
40 ( (type *) srealloc ((array), (len) * sizeof (type)) )
45 typedef struct random_state random_state
;
46 random_state
*random_init(char *seed
, int len
);
47 unsigned long random_upto(random_state
*state
, unsigned long limit
);
48 void random_free(random_state
*state
);
51 * Game-specific routines
53 typedef struct game_params game_params
;
54 typedef struct game_state game_state
;
55 char *new_game_seed(game_params
*params
);
56 game_state
*new_game(game_params
*params
, char *seed
);
57 game_state
*dup_game(game_state
*state
);
58 void free_game(game_state
*state
);
59 game_state
*make_move(game_state
*from
, int x
, int y
, int button
);
61 #endif /* PUZZLES_PUZZLES_H */