3 * Summary: Simple reading of init file.
4 * Written by: David Loewenstern
22 int str_to_summon_type(const std::string
&str
);
23 std::string
gametype_to_str(game_type type
);
25 std::string
read_init_file(bool runscript
= false);
28 newgame_def
read_startup_prefs();
30 void read_options(FILE *f
, bool runscript
= false);
31 void read_options(const std::string
&s
, bool runscript
= false,
32 bool clear_aliases
= false);
34 void parse_option_line(const std::string
&line
, bool runscript
= false);
36 void apply_ascii_display(bool ascii
);
38 void get_system_environment(void);
40 struct system_environment
43 std::string crawl_name
;
45 std::string crawl_dir
;
47 std::vector
<std::string
> rcdirs
; // Directories to search for includes.
49 std::string morgue_dir
;
50 std::string macro_dir
;
51 std::string crawl_base
; // Directory from argv[0], may be used to
53 std::string crawl_exe
; // File from argv[0].
56 #ifdef DGL_SIMPLE_MESSAGING
57 std::string messagefile
; // File containing messages from other users.
58 bool have_messages
; // There are messages waiting to be read.
59 unsigned message_check_tick
;
62 std::string scorefile
;
63 std::vector
<std::string
> cmd_args
;
67 std::vector
<std::string
> extra_opts_first
;
68 std::vector
<std::string
> extra_opts_last
;
71 void add_rcdir(const std::string
&dir
);
74 extern system_environment SysEnv
;
76 bool parse_args(int argc
, char **argv
, bool rc_only
);
79 void write_newgame_options_file(const newgame_def
& prefs
);
81 void save_player_name(void);
83 std::string
channel_to_str(int ch
);
85 int str_to_channel(const std::string
&);
90 virtual ~InitLineInput() { }
91 virtual bool eof() = 0;
92 virtual std::string
getline() = 0;
95 class FileLineInput
: public InitLineInput
98 FileLineInput(FILE *f
) : file(f
) { }
102 return !file
|| feof(file
);
105 std::string
getline()
109 fgets(s
, sizeof s
, file
);
116 class StringLineInput
: public InitLineInput
119 StringLineInput(const std::string
&s
) : str(s
), pos(0) { }
123 return pos
>= str
.length();
126 std::string
getline()
130 std::string::size_type newl
= str
.find("\n", pos
);
131 if (newl
== std::string::npos
)
133 std::string line
= str
.substr(pos
, newl
- pos
);
138 const std::string
&str
;
139 std::string::size_type pos
;