summaryrefslogtreecommitdiff
path: root/src/mongo/db/dbmain.cpp
diff options
context:
space:
mode:
authorJason Carey <jcarey@argv.me>2017-06-09 11:00:16 -0400
committerJason Carey <jcarey@argv.me>2017-06-21 14:59:27 -0400
commit18f480f4c846a65ee02b6f2f79db82c6b7a5e8ed (patch)
tree4b8f9502a0c557de84bb0557f9a72f547bbfcd1e /src/mongo/db/dbmain.cpp
parent74794ae5c03d75527b9aa0759d6f11de2217c172 (diff)
downloadmongo-18f480f4c846a65ee02b6f2f79db82c6b7a5e8ed.tar.gz
SERVER-29533 make mongodbmain a library
In service of making it easier to stand up mongodb in a library let's separate out mongodbmain into its own library and structure db.cpp to link to it, rather than including all of the setup in the final .cpp.
Diffstat (limited to 'src/mongo/db/dbmain.cpp')
-rw-r--r--src/mongo/db/dbmain.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/mongo/db/dbmain.cpp b/src/mongo/db/dbmain.cpp
new file mode 100644
index 00000000000..a16b7fee6b8
--- /dev/null
+++ b/src/mongo/db/dbmain.cpp
@@ -0,0 +1,52 @@
+/**
+ * Copyright (C) 2017 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects
+ * for all of the code used other than as permitted herein. If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. If you do not
+ * wish to do so, delete this exception statement from your version. If you
+ * delete this exception statement from all source files in the program,
+ * then also delete it in the license file.
+ */
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/db/dbmain.h"
+
+#include "mongo/util/quick_exit.h"
+#include "mongo/util/text.h"
+
+#if defined(_WIN32)
+// In Windows, wmain() is an alternate entry point for main(), and receives the same parameters
+// as main() but encoded in Windows Unicode (UTF-16); "wide" 16-bit wchar_t characters. The
+// WindowsCommandLine object converts these wide character strings to a UTF-8 coded equivalent
+// and makes them available through the argv() and envp() members. This enables mongoDbMain()
+// to process UTF-8 encoded arguments and environment variables without regard to platform.
+int wmain(int argc, wchar_t* argvW[], wchar_t* envpW[]) {
+ mongo::WindowsCommandLine wcl(argc, argvW, envpW);
+ int exitCode = mongo::mongoDbMain(argc, wcl.argv(), wcl.envp());
+ mongo::quickExit(exitCode);
+}
+#else
+int main(int argc, char* argv[], char** envp) {
+ int exitCode = mongo::mongoDbMain(argc, argv, envp);
+ mongo::quickExit(exitCode);
+}
+#endif