+
+static void print_version()
+{
+ g_print("Openbox %s\n\n", PACKAGE_VERSION);
+ g_print("This program comes with ABSOLUTELY NO WARRANTY.\n");
+ g_print("This is free software, and you are welcome to redistribute it\n");
+ g_print("under certain conditions. See the file COPYING for details.\n\n");
+}
+
+static void print_help()
+{
+ print_version();
+ g_print("Syntax: openbox [options]\n\n");
+ g_print("Options:\n\n");
+#ifdef USE_SM
+ g_print(" --sm-disable Disable connection to session manager\n");
+ g_print(" --sm-client-id ID Specify session management ID\n");
+ g_print(" --sm-save-file FILE Specify file to load a saved session\n"
+ " from\n");
+#endif
+ g_print(" --replace Replace the currently running window "
+ "manager\n");
+ g_print(" --help Display this help and exit\n");
+ g_print(" --version Display the version and exit\n");
+ g_print(" --sync Run in synchronous mode (this is slow and\n"
+ " meant for debugging X routines)\n");
+ g_print(" --debug Display debugging output\n");
+ g_print("\nPlease report bugs at %s\n", PACKAGE_BUGREPORT);
+}
+
+static void parse_args(int argc, char **argv)
+{
+ int i;
+
+ for (i = 1; i < argc; ++i) {
+ if (!strcmp(argv[i], "--version")) {
+ print_version();
+ exit(0);
+ } else if (!strcmp(argv[i], "--help")) {
+ print_help();
+ exit(0);
+ } else if (!strcmp(argv[i], "--g-fatal-warnings")) {
+ g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
+ } else if (!strcmp(argv[i], "--replace")) {
+ ob_replace_wm = TRUE;
+ } else if (!strcmp(argv[i], "--sync")) {
+ xsync = TRUE;
+ } else if (!strcmp(argv[i], "--debug")) {
+ ob_debug_show_output(TRUE);
+ } else {
+ g_printerr("Invalid option: '%s'\n\n", argv[i]);
+ print_help();
+ exit(1);
+ }
+ }
+}
+
+void ob_exit_with_error(gchar *msg)
+{
+ g_critical(msg);
+ session_shutdown();
+ exit(EXIT_FAILURE);
+}
+
+void ob_restart_other(const gchar *path)
+{
+ restart_path = g_strdup(path);
+ ob_restart();
+}
+
+void ob_restart()
+{
+ restart = TRUE;
+ ob_exit();
+}
+
+void ob_exit()
+{
+ ob_main_loop_exit(ob_main_loop);
+}
+
+Cursor ob_cursor(ObCursor cursor)
+{
+ g_assert(cursor < OB_NUM_CURSORS);
+ return cursors[cursor];
+}
+
+KeyCode ob_keycode(ObKey key)
+{
+ g_assert(key < OB_NUM_KEYS);
+ return keys[key];
+}
+
+ObState ob_state()
+{
+ return state;
+}
+
+gchar *ob_expand_tilde(const gchar *f)
+{
+ gchar **spl;
+ gchar *ret, *mid;
+
+ if (!f)
+ return NULL;
+ spl = g_strsplit(f, "~", 0);
+ mid = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S, NULL);
+ ret = g_strjoinv(mid, spl);
+ g_free(mid);
+ g_strfreev(spl);
+ return ret;
+}
+
+void ob_reconfigure()
+{
+ reconfigure = TRUE;
+ ob_exit();
+}