annotate arogue5/options.c @ 317:aab761616489 default tip

Rearrange some Autoconf files. Autoconf was failing to detect install-sh at the top level and needed some explicit directions. It also wants config.guess and config.sub to be provided too. A few other macros have also been updated.
author John "Elwin" Edwards
date Tue, 05 Sep 2023 20:05:24 -0400
parents 827441d05b3e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
1 /*
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
2 * This file has all the code for the option command.
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
3 * I would rather this command were not necessary, but
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
4 * it is the only way to keep the wolves off of my back.
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
5 *
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
6 * Advanced Rogue
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
7 * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
8 * All rights reserved.
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
9 *
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
10 * Based on "Rogue: Exploring the Dungeons of Doom"
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
11 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
12 * All rights reserved.
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
13 *
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
14 * See the file LICENSE.TXT for full copyright and licensing information.
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
15 */
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
16
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
17 #include "curses.h"
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
18 #include <ctype.h>
67
c49f7927b0fa arogue5: add missing header files.
elwin
parents: 66
diff changeset
19 #include <string.h>
310
827441d05b3e Advanced Rogue family: fix some potential buffer overflows.
John "Elwin" Edwards
parents: 304
diff changeset
20 #include <limits.h>
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
21 #include "rogue.h"
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
22
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
23 #define NUM_OPTS (sizeof optlist / sizeof (OPTION))
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
24
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
25
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
26 /*
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
27 * description of an option and what to do with it
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
28 */
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
29 struct optstruct {
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
30 char *o_name; /* option name */
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
31 char *o_prompt; /* prompt for interactive entry */
229
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
32 void *o_opt; /* pointer to thing to set */
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
33 void (*o_putfunc)(); /* function to print value */
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
34 int (*o_getfunc)(); /* function to get value interactively */
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
35 };
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
36
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
37 typedef struct optstruct OPTION;
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
38
218
56e748983fa8 Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents: 145
diff changeset
39 int get_ro(WINDOW *win, int oy, int ox);
56e748983fa8 Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents: 145
diff changeset
40 int get_restr(char *optstr, WINDOW *win);
56e748983fa8 Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents: 145
diff changeset
41 int get_score(char *optstr, WINDOW *win);
56e748983fa8 Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents: 145
diff changeset
42 void put_abil(int *ability, WINDOW *win);
229
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
43 int get_abil(int *abil, WINDOW *win);
218
56e748983fa8 Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents: 145
diff changeset
44 void put_quest(int *quest, WINDOW *win);
229
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
45 int get_quest(int *quest, WINDOW *win);
218
56e748983fa8 Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents: 145
diff changeset
46 void put_bool(bool *b, WINDOW *win);
56e748983fa8 Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents: 145
diff changeset
47 int get_bool(bool *bp, WINDOW *win);
56e748983fa8 Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents: 145
diff changeset
48 void put_str(char *str, WINDOW *win);
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
49
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
50 OPTION optlist[] = {
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
51 {"terse", "Terse output: ",
229
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
52 (void *) &terse, put_bool, get_bool },
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
53 {"flush", "Flush typeahead during battle: ",
229
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
54 (void *) &fight_flush, put_bool, get_bool },
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
55 {"jump", "Show position only at end of run: ",
229
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
56 (void *) &jump, put_bool, get_bool },
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
57 {"step", "Do inventories one line at a time: ",
229
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
58 (void *) &slow_invent, put_bool, get_bool },
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
59 {"askme", "Ask me about unidentified things: ",
229
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
60 (void *) &askme, put_bool, get_bool },
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
61 {"pickup", "Pick things up automatically: ",
229
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
62 (void *) &auto_pickup, put_bool, get_bool },
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
63 {"name", "Name: ",
229
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
64 (void *) whoami, put_str, get_restr },
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
65 {"fruit", "Fruit: ",
229
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
66 (void *) fruit, put_str, get_str },
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
67 {"file", "Save file: ",
229
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
68 (void *) file_name, put_str, get_restr },
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
69 {"score", "Score file: ",
229
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
70 (void *) score_file, put_str, get_score },
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
71 {"class", "Character class: ",
229
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
72 (void *)&char_type, put_abil, get_abil },
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
73 {"quest", "Quest item: ",
229
50b89f165a34 Use uniform return types for functions related to options.
John "Elwin" Edwards
parents: 218
diff changeset
74 (void *) &quest_item, put_quest, get_quest }
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
75 };
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
76
66
c56f672244f4 arogue5: close security holes.
elwin
parents: 63
diff changeset
77 /* For fields that would be restricted if use_savedir is set. */
c56f672244f4 arogue5: close security holes.
elwin
parents: 63
diff changeset
78 int get_restr(char *optstr, WINDOW *win)
c56f672244f4 arogue5: close security holes.
elwin
parents: 63
diff changeset
79 {
c56f672244f4 arogue5: close security holes.
elwin
parents: 63
diff changeset
80 int oy, ox;
c56f672244f4 arogue5: close security holes.
elwin
parents: 63
diff changeset
81
c56f672244f4 arogue5: close security holes.
elwin
parents: 63
diff changeset
82 if (use_savedir)
c56f672244f4 arogue5: close security holes.
elwin
parents: 63
diff changeset
83 {
c56f672244f4 arogue5: close security holes.
elwin
parents: 63
diff changeset
84 getyx(win, oy, ox);
c56f672244f4 arogue5: close security holes.
elwin
parents: 63
diff changeset
85 put_str(optstr, win);
c56f672244f4 arogue5: close security holes.
elwin
parents: 63
diff changeset
86 return get_ro(win, oy, ox);
c56f672244f4 arogue5: close security holes.
elwin
parents: 63
diff changeset
87 }
c56f672244f4 arogue5: close security holes.
elwin
parents: 63
diff changeset
88 else
c56f672244f4 arogue5: close security holes.
elwin
parents: 63
diff changeset
89 return get_str(optstr, win);
c56f672244f4 arogue5: close security holes.
elwin
parents: 63
diff changeset
90 }
c56f672244f4 arogue5: close security holes.
elwin
parents: 63
diff changeset
91