summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/initfile.h
diff options
context:
space:
mode:
authornlanza <nlanza@c06c8d41-db1a-0410-9941-cceddc491573>2006-08-13 02:19:00 +0000
committernlanza <nlanza@c06c8d41-db1a-0410-9941-cceddc491573>2006-08-13 02:19:00 +0000
commitaa88fdd8c6ad2da5eb5bd933e2d53d56cd8c176f (patch)
treed0551b96eaebb5b55694579fb8dae4abc7a38407 /crawl-ref/source/initfile.h
parent2b32f164e6ca1c4b3d587789f6cf46f46fe02fe8 (diff)
downloadcrawl-ref-aa88fdd8c6ad2da5eb5bd933e2d53d56cd8c176f.tar.gz
crawl-ref-aa88fdd8c6ad2da5eb5bd933e2d53d56cd8c176f.zip
Clean up a mistake in the SVN import.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/initfile.h')
-rw-r--r--crawl-ref/source/initfile.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/crawl-ref/source/initfile.h b/crawl-ref/source/initfile.h
new file mode 100644
index 0000000000..d5860fdd77
--- /dev/null
+++ b/crawl-ref/source/initfile.h
@@ -0,0 +1,101 @@
+/*
+ * File: initfile.h
+ * Summary: Simple reading of init file.
+ * Written by: David Loewenstern
+ *
+ * Change History (most recent first):
+ *
+ * <1> 6/9/99 DML Created
+ */
+
+
+#ifndef INITFILE_H
+#define INITFILE_H
+
+#include <string>
+#include <cstdio>
+
+std::string & trim_string( std::string &str );
+
+// last updated 12may2000 {dlb}
+/* ***********************************************************************
+ * called from: acr
+ * *********************************************************************** */
+void read_init_file(bool runscript = false);
+
+void read_options(FILE *f, bool runscript = false);
+
+void read_options(const std::string &s, bool runscript = false);
+
+void parse_option_line(const std::string &line, bool runscript = false);
+
+// last updated 12may2000 {dlb}
+/* ***********************************************************************
+ * called from: acr
+ * *********************************************************************** */
+void get_system_environment(void);
+
+
+// last updated 16feb2001 {gdl}
+/* ***********************************************************************
+ * called from: acr
+ * *********************************************************************** */
+bool parse_args(int argc, char **argv, bool rc_only);
+
+void write_newgame_options_file(void);
+
+void save_player_name(void);
+
+std::string channel_to_str(int ch);
+
+int str_to_channel(const std::string &);
+
+class InitLineInput {
+public:
+ virtual ~InitLineInput() { }
+ virtual bool eof() = 0;
+ virtual std::string getline() = 0;
+};
+
+class FileLineInput : public InitLineInput {
+public:
+ FileLineInput(FILE *f) : file(f) { }
+
+ bool eof() {
+ return !file || feof(file);
+ }
+
+ std::string getline() {
+ char s[256] = "";
+ if (!eof())
+ fgets(s, sizeof s, file);
+ return (s);
+ }
+private:
+ FILE *file;
+};
+
+class StringLineInput : public InitLineInput {
+public:
+ StringLineInput(const std::string &s) : str(s), pos(0) { }
+
+ bool eof() {
+ return pos >= str.length();
+ }
+
+ std::string getline() {
+ if (eof())
+ return "";
+ std::string::size_type newl = str.find("\n", pos);
+ if (newl == std::string::npos)
+ newl = str.length();
+ std::string line = str.substr(pos, newl - pos);
+ pos = newl + 1;
+ return line;
+ }
+private:
+ const std::string &str;
+ std::string::size_type pos;
+};
+
+#endif