| 1 | /* |
| 2 | * puzzles.h: header file for my puzzle collection |
| 3 | */ |
| 4 | |
| 5 | #ifndef PUZZLES_PUZZLES_H |
| 6 | #define PUZZLES_PUZZLES_H |
| 7 | |
| 8 | #ifndef TRUE |
| 9 | #define TRUE 1 |
| 10 | #endif |
| 11 | #ifndef FALSE |
| 12 | #define FALSE 0 |
| 13 | #endif |
| 14 | |
| 15 | #define lenof(array) ( sizeof(array) / sizeof(*(array)) ) |
| 16 | |
| 17 | enum { |
| 18 | LEFT_BUTTON = 0x1000, |
| 19 | MIDDLE_BUTTON, |
| 20 | RIGHT_BUTTON |
| 21 | }; |
| 22 | |
| 23 | /* |
| 24 | * Platform routines |
| 25 | */ |
| 26 | void fatal(char *fmt, ...); |
| 27 | |
| 28 | /* |
| 29 | * malloc.c |
| 30 | */ |
| 31 | void *smalloc(int size); |
| 32 | void *srealloc(void *p, int size); |
| 33 | void sfree(void *p); |
| 34 | char *dupstr(char *s); |
| 35 | #define snew(type) \ |
| 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)) ) |
| 41 | |
| 42 | /* |
| 43 | * random.c |
| 44 | */ |
| 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); |
| 49 | |
| 50 | /* |
| 51 | * Game-specific routines |
| 52 | */ |
| 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); |
| 60 | |
| 61 | #endif /* PUZZLES_PUZZLES_H */ |