Exemple #1
0
  /**
   * Runs rbx from the filesystem. Searches for the Rubinius runtime files
   * according to the algorithm in find_runtime().
   */
  void Environment::run_from_filesystem() {
    int i = 0;
    state->vm()->set_root_stack(reinterpret_cast<uintptr_t>(&i),
                                VM::cStackDepthMax);

    std::string runtime = system_prefix() + RBX_RUNTIME_PATH;

    load_platform_conf(runtime);
    boot_vm();
    start_finalizer();

    load_argv(argc_, argv_);

    start_signals();
    state->vm()->initialize_config();

    load_tool();

    G(rubinius)->set_const(state, "Signature", Integer::from(state, signature_));

    if(LANGUAGE_20_ENABLED(state)) {
      runtime += "/20";
    } else if(LANGUAGE_19_ENABLED(state)) {
      runtime += "/19";
    } else {
      runtime += "/18";
    }
    G(rubinius)->set_const(state, "RUNTIME_PATH", String::create(state,
                           runtime.c_str(), runtime.size()));

    load_kernel(runtime);
    shared->finalizer_handler()->start_thread(state);

    run_file(runtime + "/loader.rbc");

    state->vm()->thread_state()->clear();

    Object* loader = G(rubinius)->get_const(state, state->symbol("Loader"));
    if(loader->nil_p()) {
      rubinius::bug("Unable to find loader");
    }

    OnStack<1> os(state, loader);

    Object* inst = loader->send(state, 0, state->symbol("new"));
    if(inst) {
      OnStack<1> os2(state, inst);

      inst->send(state, 0, state->symbol("main"));
    } else {
      rubinius::bug("Unable to instantiate loader");
    }
  }
Exemple #2
0
/**
 * Inits the main structure.
 * @note With sqlite version > 3.7.7 we should use URI filename.
 * @param opt : a filled options_t * structure that contains all options
 *        by default, read into the file or selected in the command line.
 * @returns a main_struct_t * pointer to the main structure
 */
static main_struct_t *init_main_structure(options_t *opt)
{
    main_struct_t *main_struct = NULL;
    gchar *db_uri = NULL;
    gchar *conn = NULL;

    if (opt != NULL)
    {

        print_debug(_("Please wait while initializing main structure...\n"));

        main_struct = (main_struct_t *) g_malloc0(sizeof(main_struct_t));

        create_directory(opt->dircache);
        db_uri = g_build_filename(opt->dircache, opt->dbname , NULL);
        main_struct->database = open_database(db_uri);
        db_uri = free_variable(db_uri);

        main_struct->opt = opt;
        main_struct->hostname = g_get_host_name();

        if (opt != NULL && opt->ip != NULL)
        {
            conn = make_connexion_string(opt->ip, opt->port);
            main_struct->comm = init_comm_struct(conn);
            main_struct->reconnected = init_comm_struct(conn);
            free_variable(conn);
        }
        else
        {
            /* This should never happen because we have default values */
            main_struct->comm = NULL;
        }

        main_struct->signal_fd = start_signals();
        main_struct->fanotify_fd = start_fanotify(opt);

        /* inits the queue that will wait for events on files */
        main_struct->save_queue = g_async_queue_new();
        main_struct->dir_queue = g_async_queue_new();
        main_struct->regex_exclude_list = make_regex_exclude_list(opt->exclude_list);

        /* Thread initialization */
        main_struct->save_one_file = g_thread_new("save_one_file", save_one_file_threaded, main_struct);
        main_struct->carve_all_directories = g_thread_new("carve_all_directories", carve_all_directories, main_struct);
        main_struct->reconn_thread = g_thread_new("reconnected", reconnected, main_struct);

        print_debug(_("Main structure initialized !\n"));

    }

    return main_struct;
}