annotate rogue4/extern.h @ 280:70aa5808c782

Fix potential segfaults at restore related to ctime(). In some games, restore() passes the result of ctime() to mvprintw() or some other variadic message-formatting function. If ctime() has not been declared properly, its return type is inferred to be int instead of char *. This does not cause a warning because the compiler does not know the correct type of variadic arguments. On platforms where ints and pointers are not the same size, this can, probably depending on alignment, result in a segfault that is not easy to trace. Including time.h fixes the problem. Some games manually declared ctime() and avoided the bug. These declarations have also been replaced with the include.
author John "Elwin" Edwards
date Fri, 15 Sep 2017 20:51:10 -0400
parents d3968e9cb98d
children e52a8a7ad4c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
1 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
2 * Defines for things used in mach_dep.c
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
3 *
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
4 * @(#)extern.h 4.3 (Berkeley) 4/2/82
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
5 *
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
6 * Rogue: Exploring the Dungeons of Doom
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
7 * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
8 * All rights reserved.
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
9 *
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
10 * See the file LICENSE.TXT for full copyright and licensing information.
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
11 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
13 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
14 * Don't change the constants, since they are used for sizes in many
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
15 * places in the program.
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
16 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
17
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
18 #define MAXSTR 80 /* maximum length of strings */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
19 #define MAXLINES 32 /* maximum number of screen lines used */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
20 #define MAXCOLS 80 /* maximum number of screen columns used */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
21
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
22 #define RN (((seed = seed*11109+13849) >> 16) & 0xffff)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
23
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
24 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
25 * Now all the global variables
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
26 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
27
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
28 extern bool after, amulet, askme, door_stop, fight_flush,
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
29 firstmove, in_shell, jump, noscore, p_know[], passgo,
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
30 playing, r_know[], running, s_know[], save_msg,
13
63b9fd7d70ce rogue4: add -n option and system savedir
edwarj4
parents: 12
diff changeset
31 slow_invent, terse, use_savedir, wizard, ws_know[];
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
32
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
33
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
34 extern const char *p_colors[], *r_stones[], *w_names[],
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
35 *a_names[], *ws_made[];
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
36 extern char _flags[], _level[], file_name[], fruit[],
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
37 home[], huh[], outbuf[], *p_guess[],
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
38 prbuf[], *r_guess[], *release, runch,
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
39 *s_guess[], *s_names[], take, whoami[],
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
40 *ws_guess[], *ws_type[];
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
41
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
42 extern int a_chances[], a_class[], count, dnum, food_left,
279
d3968e9cb98d Use C stdio functions for score files and save files.
John "Elwin" Edwards
parents: 252
diff changeset
43 fung_hit, group, hungry_state, inpack, lastscore,
d3968e9cb98d Use C stdio functions for score files and save files.
John "Elwin" Edwards
parents: 252
diff changeset
44 level, max_level, mpos, no_command, no_food, no_move,
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
45 ntraps, purse, quiet, total;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
46
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
47 extern long seed;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
48
279
d3968e9cb98d Use C stdio functions for score files and save files.
John "Elwin" Edwards
parents: 252
diff changeset
49 extern FILE *score_file, *log_file;
d3968e9cb98d Use C stdio functions for score files and save files.
John "Elwin" Edwards
parents: 252
diff changeset
50
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
51 extern WINDOW *hw;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
52
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
53 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
54 * Function types
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
55 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
56
215
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 26
diff changeset
57 void tstp(), endit(int);
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
58
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
59 long lseek();
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
60
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
61 extern coord ch_ret;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
62 extern shint countch;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
63 extern shint direction;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
64 extern shint newcount;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
65 extern int between;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
66 extern int num_checks;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
67 extern char lvl_mons[27];
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
68 extern char wand_mons[27];
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
69 extern coord nh;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
70 extern bool got_genocide;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
71
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
72 #if defined(__GLIBC__) || defined(__INTERIX)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
73 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
74 O_BINARY flag not provided in Interix/SFU or some versions of Linux.
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
75 It is the same as default behavior so we just zero define it here
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
76 to make source code compatible.
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
77 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
78 #define O_BINARY 0
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
79 #endif
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
80
216
b24545357d2e rogue4: add more function declarations.
John "Elwin" Edwards
parents: 215
diff changeset
81 extern int md_erasechar(void);
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
82 extern FILE *md_fdopen(int fd, char *mode);
216
b24545357d2e rogue4: add more function declarations.
John "Elwin" Edwards
parents: 215
diff changeset
83 extern int md_fileno(FILE *fp);
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
84 extern char *md_getusername(int uid);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
85 extern char *md_gethomedir();
216
b24545357d2e rogue4: add more function declarations.
John "Elwin" Edwards
parents: 215
diff changeset
86 extern int md_getuid(void);
b24545357d2e rogue4: add more function declarations.
John "Elwin" Edwards
parents: 215
diff changeset
87 extern void md_ignore_signals(void);
b24545357d2e rogue4: add more function declarations.
John "Elwin" Edwards
parents: 215
diff changeset
88 extern void md_init(void);
b24545357d2e rogue4: add more function declarations.
John "Elwin" Edwards
parents: 215
diff changeset
89 extern int md_killchar(void);
b24545357d2e rogue4: add more function declarations.
John "Elwin" Edwards
parents: 215
diff changeset
90 extern void md_normaluser(void);
b24545357d2e rogue4: add more function declarations.
John "Elwin" Edwards
parents: 215
diff changeset
91 extern int md_readchar(WINDOW *win);
b24545357d2e rogue4: add more function declarations.
John "Elwin" Edwards
parents: 215
diff changeset
92 extern int md_shellescape(void);
b24545357d2e rogue4: add more function declarations.
John "Elwin" Edwards
parents: 215
diff changeset
93 extern void md_sleep(int s);
b24545357d2e rogue4: add more function declarations.
John "Elwin" Edwards
parents: 215
diff changeset
94 extern int md_unlink(char *file);
279
d3968e9cb98d Use C stdio functions for score files and save files.
John "Elwin" Edwards
parents: 252
diff changeset
95 extern int md_unlink_open_file(char *file, FILE *inf);
252
3d4252fa2ed3 Use more portable random seed generation.
John "Elwin" Edwards
parents: 216
diff changeset
96 extern unsigned int md_random_seed(void);