概述
- int main(int argc, char *argv[])
- {
- GError *error = NULL;
- GOptionContext *context;
- spice_connection *conn;
- gchar *conf_file, *conf;
- char *host = NULL, *port = NULL, *tls_port = NULL;
-
-
- #if !GLIB_CHECK_VERSION(2,31,18)
- g_thread_init(NULL);
- #endif
- /*国际化*/
- bindtextdomain(GETTEXT_PACKAGE, SPICE_GTK_LOCALEDIR);
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
- textdomain(GETTEXT_PACKAGE);
-
-
- /*信号处理函数*/
- signal(SIGINT, signal_handler);
- signal(SIGTERM, signal_handler);
- segv_handler = signal(SIGSEGV, signal_handler);
- abrt_handler = signal(SIGABRT, signal_handler);
- fpe_handler = signal(SIGFPE, signal_handler);
- ill_handler = signal(SIGILL, signal_handler);
-
- #ifndef WIN32
- signal(SIGHUP, signal_handler);
- bus_handler = signal(SIGBUS, signal_handler);
- #endif
-
-
- /*读取配置文件*/
- keyfile = g_key_file_new();
-
-
- int mode = S_IRWXU;
- conf_file = g_build_filename(g_get_user_config_dir(), "spicy", NULL);
- if (g_mkdir_with_parents(conf_file, mode) == -1)
- SPICE_DEBUG("failed to create config directory");
- g_free(conf_file);
-
-
- conf_file = g_build_filename(g_get_user_config_dir(), "spicy", "settings", NULL);
- if (!g_key_file_load_from_file(keyfile, conf_file,
- G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS, &error)) {
- SPICE_DEBUG("Couldn't load configuration: %s", error->message);
- g_clear_error(&error);
- }
-
- /*解析命令行传入的参数*/
- /* parse opts */
- gtk_init(&argc, &argv);
- context = g_option_context_new(_("- spice client test application"));
- g_option_context_set_summary(context, _("Gtk+ test client to connect to Spice servers."));
- g_option_context_set_description(context, _("Report bugs to " PACKAGE_BUGREPORT "."));
- g_option_context_add_group(context, spice_get_option_group());
- g_option_context_set_main_group(context, spice_cmdline_get_option_group());
- g_option_context_add_main_entries(context, cmd_entries, NULL);
- g_option_context_add_group(context, gtk_get_option_group(TRUE));
- if (!g_option_context_parse (context, &argc, &argv, &error)) {
- g_print(_("option parsing failed: %sn"), error->message);
- exit(1);
- }
- g_option_context_free(context);
-
-
- if (version) {
- g_print("spicy " PACKAGE_VERSION "n");
- exit(0);
- }
-
-
-
-
- g_type_init();
- mainloop = g_main_loop_new(NULL, false);
-
-
- /*设置conn的通道默认回调函数,设置内部默认参数,读取命令行参数*/
- conn = connection_new();
- spice_set_session_option(conn->session);
- spice_cmdline_session_setup(conn->session);
-
-
- g_object_get(conn->session,
- "host", &host,
- "port", &port,
- "tls-port", &tls_port,
- NULL);
- /* If user doesn't provide hostname and port, show the dialog window
- instead of connecting to server automatically */
- if (host == NULL || (port == NULL && tls_port == NULL)) {
- int ret = connect_dialog(conn->session);
- if (ret != 0) {
- exit(0);
- }
- }
- g_free(host);
- g_free(port);
- g_free(tls_port);
-
-
- watch_stdin();
-
-
- /*创建主通道,激活channel_new()*/
- connection_connect(conn);
- if (connections > 0)
- g_main_loop_run(mainloop);
- g_main_loop_unref(mainloop);
-
-
- if ((conf = g_key_file_to_data(keyfile, NULL, &error)) == NULL ||
- !g_file_set_contents(conf_file, conf, -1, &error)) {
- SPICE_DEBUG("Couldn't save configuration: %s", error->message);
- g_error_free(error);
- error = NULL;
- }
-
-
- g_free(conf_file);
- g_free(conf);
- g_key_file_free(keyfile);
-
-
- g_free(spicy_title);
-
-
- setup_terminal(true);
- return 0;
- }
0
上一篇:gobject 中 g_object_new 流程简介
下一篇:Linux Used内存到底哪里去了?
相关热门文章
- linux设备驱动之USB数据传输分...
- QEMU源码分析系列(四)...
- 研究说:失眠的人刷微博、朋友...
- 物联网MQTT协议分析和开源Mosq...
- APP开发报价单,如何计算APP报...
- [官版翻译ing]OpenStack云计算...
- [官版翻译ing]OpenStack云计算...
- hive的安装和配置
- OpenStack安装记
- Hadoop运行class类出现Excepti...
- linux dhcp peizhi roc
- 关于Unix文件的软链接
- 求教这个命令什么意思,我是新...
- sed -e "/grep/d" 是什么意思...
- 谁能够帮我解决LINUX 2.6 10...
给主人留下些什么吧!~~
评论热议
最后
以上就是迷人小蝴蝶为你收集整理的SPICE之spicy主函数源码分析的全部内容,希望文章能够帮你解决SPICE之spicy主函数源码分析所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复