- extern ChimaraGlkPrivate *glk_data;
-
- g_signal_emit_by_name(glk_data->self, "started");
- ((glk_main_t)glk_main)();
- g_signal_emit_by_name(glk_data->self, "stopped");
+ extern GPrivate *glk_data_key;
+ g_private_set(glk_data_key, startup->glk_data);
+
+ /* Run startup function */
+ if(startup->glkunix_startup_code) {
+ startup->glk_data->in_startup = TRUE;
+ int result = startup->glkunix_startup_code(&startup->args);
+ startup->glk_data->in_startup = FALSE;
+
+ int i = 0;
+ while(i < startup->args.argc)
+ g_free(startup->args.argv[i++]);
+ g_free(startup->args.argv);
+
+ if(!result)
+ return NULL;
+ }
+
+ /* Run main function */
+ g_signal_emit_by_name(startup->glk_data->self, "started");
+ (startup->glk_main)();
+ g_signal_emit_by_name(startup->glk_data->self, "stopped");
+ g_slice_free(struct StartupData, startup);