/* lily_new_symtab: Symtab init, stage 1 This function is responsible for creating a symtab struct for the parser. Returns a valid symtab, or NULL on failure. */ lily_symtab *lily_new_symtab(lily_raiser *raiser) { lily_symtab *symtab = lily_malloc(sizeof(lily_symtab)); int v = 0; if (symtab == NULL) return NULL; symtab->next_register_spot = 0; symtab->class_pos = 0; symtab->class_size = INITIAL_CLASS_SIZE; symtab->var_start = NULL; symtab->var_top = NULL; symtab->old_function_chain = NULL; symtab->classes = NULL; symtab->lit_start = NULL; symtab->lit_top = NULL; symtab->function_depth = 1; /* lily_try_new_var expects lex_linenum to be the lexer's line number. 0 is used, because these are all builtins, and the lexer may have failed to initialize anyway. */ symtab->lex_linenum = &v; symtab->root_sig = NULL; if (!init_classes(symtab) || !init_literals(symtab) || !init_lily_main(symtab) || !read_global_seeds(symtab) || !call_class_setups(symtab)) { /* First the literals and vars created, if any... */ lily_free_symtab_lits_and_vars(symtab); /* then delete the symtab. */ lily_free_symtab(symtab); return NULL; } symtab->raiser = raiser; return symtab; }
JNIEXPORT jint JNICALL JVM_OnLoad(JavaVM *vm, char *options, void *reserved) { int res; char *log_file_path = "/tmp/heapprof.log"; jvm = vm; if (options) { fprintf(stderr, "options=\"%s\"\n", options); if ((strlen(options) > 4) && (strncmp(options, "log=", 4) == 0)) { log_file_path = options + 4; } } last_gc = now_us(); class_filter = (regex_t*) calloc(1, sizeof(regex_t)); res = regcomp(class_filter, "^(bamboo|ostore|org\\.apache|com\\.sleepycat)\\..*", REG_EXTENDED | REG_NOSUB); assert(!res); if (log_file_path) { log_fd = open(log_file_path, O_WRONLY | O_CREAT, 0664); if (!log_fd) { fprintf(stderr, "Could not open log file: %s\n", log_file_path); fflush(stderr); exit(1); } log_file = fdopen(log_fd, "w"); } else { log_file = stderr; log_fd = 0; } classes = g_hash_table_new(g_direct_hash, g_direct_equal); init_classes(); asites = g_hash_table_new(asite_key_hash, asite_key_equals); methods = g_hash_table_new(g_direct_hash, g_direct_equal); objects = g_hash_table_new(g_direct_hash, g_direct_equal); arenas = g_hash_table_new(g_direct_hash, g_direct_equal); res = (*jvm)->GetEnv(jvm, (void**)&jvmpi, JVMPI_VERSION_1); if (res < 0) return JNI_ERR; jvmpi->NotifyEvent = notify_event; lock = jvmpi->RawMonitorCreate("_lock"); jvmpi->RawMonitorEnter(lock); if (jvmpi->EnableEvent(JVMPI_EVENT_GC_START, NULL) != JVMPI_SUCCESS) return JNI_ERR; if (jvmpi->EnableEvent(JVMPI_EVENT_GC_FINISH, NULL) != JVMPI_SUCCESS) return JNI_ERR; if (jvmpi->EnableEvent(JVMPI_EVENT_OBJ_ALLOC, NULL) != JVMPI_SUCCESS) return JNI_ERR; if (jvmpi->EnableEvent(JVMPI_EVENT_OBJ_MOVE, NULL) != JVMPI_SUCCESS) return JNI_ERR; if (jvmpi->EnableEvent(JVMPI_EVENT_OBJ_FREE, NULL) != JVMPI_SUCCESS) return JNI_ERR; if (jvmpi->EnableEvent(JVMPI_EVENT_DELETE_ARENA, NULL) != JVMPI_SUCCESS) return JNI_ERR; if (jvmpi->EnableEvent(JVMPI_EVENT_CLASS_LOAD, NULL) != JVMPI_SUCCESS) return JNI_ERR; if (jvmpi->EnableEvent(JVMPI_EVENT_CLASS_UNLOAD, NULL) != JVMPI_SUCCESS) return JNI_ERR; if (jvmpi->EnableEvent(JVMPI_EVENT_METHOD_ENTRY, NULL) != JVMPI_SUCCESS) return JNI_ERR; if (jvmpi->EnableEvent(JVMPI_EVENT_METHOD_EXIT, NULL) != JVMPI_SUCCESS) return JNI_ERR; jvmpi->RawMonitorExit(lock); return JNI_OK; }
int main (int argc, char **argv) { gboolean arg_version = FALSE; gboolean arg_display_properties = FALSE; gboolean arg_display_about = FALSE; gboolean arg_consider_new_mail_as_read = FALSE; gboolean arg_update = FALSE; gboolean arg_print_summary = FALSE; gboolean arg_unset_obsolete_configuration = FALSE; gboolean arg_quit = FALSE; const GOptionEntry options[] = { { "version", 'v', 0, G_OPTION_ARG_NONE, &arg_version, N_("Show version information"), NULL }, { "enable-info", 'i', 0, G_OPTION_ARG_NONE, &arg_enable_info, N_("Enable informational output"), NULL }, { "display-properties", 'p', 0, G_OPTION_ARG_NONE, &arg_display_properties, N_("Display the properties dialog"), NULL }, { "display-about", 'a', 0, G_OPTION_ARG_NONE, &arg_display_about, N_("Display the about dialog"), NULL }, { "consider-new-mail-as-read", 'r', 0, G_OPTION_ARG_NONE, &arg_consider_new_mail_as_read, N_("Consider new mail as read"), NULL }, { "update", 'u', 0, G_OPTION_ARG_NONE, &arg_update, N_("Update the mail status"), NULL }, { "print-summary", 's', 0, G_OPTION_ARG_NONE, &arg_print_summary, N_("Print a XML mail summary"), NULL }, { "unset-obsolete-configuration", '\0', 0, G_OPTION_ARG_NONE, &arg_unset_obsolete_configuration, N_("Unset obsolete GConf configuration"), NULL }, { "quit", 'q', 0, G_OPTION_ARG_NONE, &arg_quit, N_("Quit Mail Notification"), NULL }, { NULL } }; GOptionContext *option_context; DBusGConnection *bus; DBusGProxy *bus_proxy; g_log_set_fatal_mask(NULL, G_LOG_LEVEL_CRITICAL); g_log_set_handler(NULL, G_LOG_LEVEL_INFO, info_log_cb, NULL); #ifdef ENABLE_NLS bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif g_set_application_name(_("Mail Notification")); g_thread_init(NULL); if (! g_thread_supported()) /* * We cannot use mn_fatal_error_dialog() because gtk_init() has * not been called yet. */ g_critical(_("multi-threading is not available")); gdk_threads_init(); GDK_THREADS_ENTER(); option_context = g_option_context_new(NULL); g_option_context_add_main_entries(option_context, options, GETTEXT_PACKAGE); gnome_program_init(PACKAGE, VERSION, LIBGNOME_MODULE, argc, argv, GNOME_PARAM_HUMAN_READABLE_NAME, _("Mail Notification"), GNOME_PROGRAM_STANDARD_PROPERTIES, GNOME_PARAM_GOPTION_CONTEXT, option_context, NULL); gtk_init(&argc, &argv); if (arg_version) { print_version(); goto end; } if (arg_unset_obsolete_configuration) { mn_conf_unset_obsolete(); goto end; } ensure_icon_path(); gtk_window_set_default_icon_name("mail-notification"); mn_stock_init(); bus = connect_to_session_bus(); bus_proxy = get_bus_proxy(bus); if (mn_server_start(bus, bus_proxy)) /* not already running */ { if (arg_quit) g_message(_("Mail Notification is not running")); else { mn_mailbox_init_types(); #if WITH_MBOX || WITH_MOZILLA || WITH_MH || WITH_MAILDIR || WITH_SYLPHEED mn_vfs_mailbox_init_types(); #endif /* mn-client-session uses sockets, we don't want to die on SIGPIPE */ signal(SIGPIPE, SIG_IGN); if (! gnome_vfs_init()) mn_show_fatal_error_dialog(NULL, _("Unable to initialize the GnomeVFS library.")); #if !GTK_CHECK_VERSION(3,0,0) gnome_authentication_manager_init(); #endif /* must be called before init_gmime() */ mn_conf_init(); #if WITH_GMIME init_gmime(); #endif if (! notify_init(_("Mail Notification"))) mn_show_error_dialog(NULL, _("An initialization error has occurred in Mail Notification"), _("Unable to initialize the notification library. Message popups will not be displayed.")); /* * Work around * http://bugzilla.gnome.org/show_bug.cgi?id=64764: * initialize the classes we will be using concurrently * before any thread is created. */ init_classes(); mn_shell_new(bus, bus_proxy); /* also display the properties dialog if there are no mailboxes */ if (! mn_shell->mailboxes->list) arg_display_properties = TRUE; if (arg_display_properties) mn_shell_show_properties_dialog(mn_shell, 0); if (arg_display_about) mn_shell_show_about_dialog(mn_shell, 0); if (arg_consider_new_mail_as_read) report_option_ignored("--consider-new-mail-as-read"); if (arg_update) report_option_ignored("--update"); if (arg_print_summary) report_option_ignored("--print-summary"); /* in case no window has been displayed */ gdk_notify_startup_complete(); gtk_main(); } } else /* already running */ { DBusGProxy *proxy; GError *err = NULL; proxy = dbus_g_proxy_new_for_name(bus, MN_SERVER_SERVICE, MN_SERVER_PATH, MN_SERVER_INTERFACE); if (arg_quit) { g_message(_("quitting Mail Notification")); CALL_SERVER(org_gnome_MailNotification_quit(proxy, &err)); } else { /* also display the properties dialog if there are no mailboxes */ if (! arg_display_properties) { gboolean has; CALL_SERVER(org_gnome_MailNotification_has_mailboxes(proxy, &has, &err)); arg_display_properties = ! has; } if (arg_display_properties) CALL_SERVER(org_gnome_MailNotification_display_properties(proxy, &err)); if (arg_display_about) CALL_SERVER(org_gnome_MailNotification_display_about(proxy, &err)); if (arg_consider_new_mail_as_read) { g_message(_("considering new mail as read")); CALL_SERVER(org_gnome_MailNotification_consider_new_mail_as_read(proxy, &err)); } if (arg_update) { g_message(_("updating the mail status")); CALL_SERVER(org_gnome_MailNotification_update(proxy, &err)); } if (arg_print_summary) { char *summary; CALL_SERVER(org_gnome_MailNotification_get_summary(proxy, &summary, &err)); g_print("%s", summary); g_free(summary); } if (! (arg_display_properties || arg_display_about || arg_consider_new_mail_as_read || arg_update || arg_print_summary)) g_message(_("Mail Notification is already running")); } /* * Do not unref the proxy, since it might break when the * DBusGProxy memory management issue is fixed * (https://bugs.freedesktop.org/show_bug.cgi?id=14030). */ /* no window has been displayed by this process */ gdk_notify_startup_complete(); } end: GDK_THREADS_LEAVE(); return 0; }