Exemple #1
0
void
drd_info_rep::heuristic_init (hashmap<string,tree> env2) {
  // time_t tt= texmacs_time ();
  set_environment (env2);
  bool flag= true;
  int round= 0;
  while (flag) {
    // cout << HRULE;
    flag= false;
    iterator<string> it= iterate (env);
    while (it->busy()) {
      string var= it->next();
      tree   val= env[var];
      if (is_func (val, MACRO))
	flag= heuristic_init_macro (var, val) | flag;
      if (is_func (val, XMACRO))
	flag= heuristic_init_xmacro (var, val) | flag;
    }
    if ((round++) == 10) {
      cout << "TeXmacs] Warning: bad heuristic drd convergence\n";
      flag= false;
    }
  }
  // cout << "--> " << (texmacs_time ()-tt) << "ms\n";
}
Exemple #2
0
void init_libretro_sym(void)
{
   // Guarantee that we can do "dirty" casting.
   // Every OS that this program supports should pass this ...
   rarch_assert(sizeof(void*) == sizeof(void (*)(void)));

#ifdef HAVE_DYNAMIC
   // Try to verify that -lretro was not linked in from other modules
   // since loading it dynamically and with -l will fail hard.
   function_t sym = dylib_proc(NULL, "retro_init");
   if (sym)
   {
      RARCH_ERR("Serious problem. RetroArch wants to load libretro dyamically, but it is already linked.\n"); 
      RARCH_ERR("This could happen if other modules RetroArch depends on link against libretro directly.\n");
      RARCH_ERR("Proceeding could cause a crash. Aborting ...\n");
      rarch_fail(1, "init_libretro_sym()");
   }

   if (!*g_settings.libretro)
   {
      RARCH_ERR("RetroArch is built for dynamic libretro, but libretro_path is not set. Cannot continue.\n");
      rarch_fail(1, "init_libretro_sym()");
   }
#endif

   load_symbols();

   set_environment_defaults();
   set_environment();
}
graphical_font_label::graphical_font_label(
       const std::string& text, const std::string& font, int size)
  : text_(text), font_(graphical_font::get(font)), size_(size)
{
	set_environment();
	ASSERT_LOG(font_.get(), "UNKNOWN FONT: " << font);
	reset_text_dimensions();
}
Exemple #4
0
button::button(widget_ptr label, boost::function<void ()> onclick, BUTTON_STYLE button_style, BUTTON_RESOLUTION button_resolution)
  : label_(label), onclick_(onclick), button_resolution_(button_resolution), button_style_(button_style),
	down_(false), hpadding_(10), vpadding_(4)
	
{
	set_environment();
	setup();
}
Exemple #5
0
button::button(const std::string& str, boost::function<void()> onclick)
  : label_(new label(str, graphics::color_white())),
    onclick_(onclick), button_resolution_(BUTTON_SIZE_NORMAL_RESOLUTION),
	button_style_(BUTTON_STYLE_NORMAL), hpadding_(10), vpadding_(4),
	down_(false)
{
	set_environment();
	setup();
}
Exemple #6
0
/**
 * Initialize the program environment
 */
void init_env() {
  
  /* Setup for safe(r) exec */
  set_sandbox();

  /* Setup program environment */
  set_environment();

}
Exemple #7
0
dialog::dialog(int x, int y, int w, int h)
  : opened_(false), cancelled_(false), clear_bg_(196), padding_(10),
    add_x_(0), add_y_(0), bg_alpha_(1.0), last_draw_(-1)
{
	set_environment();
	set_loc(x,y);
	set_dim(w,h);
	forced_dimensions_ = rect(x, y, w, h);
}
Exemple #8
0
grid::grid(int ncols)
  : ncols_(ncols), col_widths_(ncols, 0),
    col_aligns_(ncols, grid::ALIGN_LEFT), row_height_(0),
	selected_row_(-1), allow_selection_(false), must_select_(false),
    swallow_clicks_(false), hpad_(0), show_background_(false),
	max_height_(-1), allow_highlight_(true), set_h_(0), set_w_(0)
{
	set_environment();
	set_dim(0,0);
}
Exemple #9
0
void Process::copy_environment() {
//GetEnvironmentVariable

#ifdef WIN32

	LPTSTR lpszVariable;
	LPCH lpvEnv;

	lpvEnv = GetEnvironmentStrings();

	if (lpvEnv == NULL) return;

	// Variable strings are separated by NULL byte, and the block is terminated by a NULL byte.
	for (lpszVariable = (LPTSTR) lpvEnv; *lpszVariable; lpszVariable++) {

        LPCH ptr = strchr(lpszVariable, '=');

        if (!ptr) continue;

        set_environment(string(lpszVariable, ptr-lpszVariable), string(ptr+1));

		lpszVariable += strlen(lpszVariable) ;

	}

	FreeEnvironmentStrings(lpvEnv);

#else

    for(char **current = environ; *current; current++) {
    
        char* var = *current;
        char* ptr = strchr(var, '=');
        if (!ptr) continue;

        set_environment(string(var, ptr-var), string(ptr+1));

    }

#endif
}
Exemple #10
0
key_button::key_button(key_type key, BUTTON_RESOLUTION button_resolution)
  : label_(widget_ptr(new graphical_font_label(get_key_name(key), "door_label", 2))),
	key_(key), button_resolution_(button_resolution),
	normal_button_image_set_(framed_gui_element::get("regular_button")),
	depressed_button_image_set_(framed_gui_element::get("regular_button_pressed")),
	focus_button_image_set_(framed_gui_element::get("regular_button_focus")),
	current_button_image_set_(normal_button_image_set_), grab_keys_(false)
	
{
	set_environment();
	set_dim(label_->width()+hpadding*2,label_->height()+vpadding*2);
}
Exemple #11
0
// TODO This is internal, make it private as soon as possible.
void
retro_core_set_environment_interface (RetroCore *self)
{
  RetroModule *module;
  RetroCallbackSetter set_environment;

  module = self->module;
  set_environment = retro_module_get_set_environment (module);

  retro_core_push_cb_data (self);
  set_environment (on_environment_interface);
  retro_core_pop_cb_data ();
}
Exemple #12
0
void
init(const char *_cmd)
{
	x11_init();

	checkotherwm();

	cmd = _cmd;

	/* Setup the motion struct */
	motion = xcalloc(1, sizeof(struct motion));
	motion->type = NoMotion;

	sysinfo_init();

	clients_init();
	bars_init(settings()->barfont);
	launcher_init();

	/* Select wvents to handle */
	XSelectInput(dpy, root, WM_EVENT_MASK);

	/* Setup cursors */
	cursors_init();
	cursor_set(root, NormalCursor);

	/* Setup key bindings */
	keys = settings()->keys;
	key_init();
	key_grab_all(keys);

	/* Init atoms and EWMH */
	atoms_init();
	ewmh_init(wm_name);

	/* Init program lists */
	program_init(getenv("PATH"));

	/* Create monitors */
	create_monitors();

	/* Init ewmh desktop functionality */
	ewmh_root_set_number_of_desktops(
			monitor_count(mons) * N_WORKSPACES);
	ewmh_root_set_current_desktop(0);

	get_windows();

	set_environment();
}
Exemple #13
0
bool Camera::_set(const StringName& p_name, const Variant& p_value) {

	bool changed_all=false;
	if (p_name=="projection") {

		int proj = p_value;
		if (proj==PROJECTION_PERSPECTIVE)
			mode=PROJECTION_PERSPECTIVE;
		if (proj==PROJECTION_ORTHOGONAL)
			mode=PROJECTION_ORTHOGONAL;

		changed_all=true;
	} else if (p_name=="fov" || p_name=="fovy" || p_name=="fovx")
		fov=p_value;
	else if (p_name=="size" || p_name=="sizex" || p_name=="sizey")
		size=p_value;
	else if (p_name=="near")
		near=p_value;
	else if (p_name=="far")
		far=p_value;														
	else if (p_name=="keep_aspect")
		set_keep_aspect_mode(KeepAspect(int(p_value)));
	else if (p_name=="vaspect")
		set_keep_aspect_mode(p_value?KEEP_WIDTH:KEEP_HEIGHT);
	else if (p_name=="h_offset")
		h_offset=p_value;
	else if (p_name=="v_offset")
		v_offset=p_value;
	else if (p_name=="current") {
		if (p_value.operator bool()) {
			make_current();
		} else {
			clear_current();
		}
	} else if (p_name=="visible_layers") {
		set_visible_layers(p_value);
	} else if (p_name=="environment") {
		set_environment(p_value);
	} else
		return false;
		
	_update_camera_mode();
	if (changed_all)
		_change_notify();
	return true;

}
Exemple #14
0
void syscall_env( struct syscall_packet *scp )
{
	struct process *proc = NULL;
	scp->rc = SMK_UNKNOWN_SYSCALL;

	switch (scp->opcode)
	{
		case OP( ENV, ONE ):
				proc = checkout_process( getpid(), WRITER );
				assert( proc != NULL );
				scp->rc = set_environment( current_process(), scp->name, scp->ptr, scp->size );
				commit_process( proc );
				break;

		case OP( ENV, TWO ):
				proc = checkout_process( getpid(), READER );
				assert( proc != NULL );
				scp->rc = get_environment( current_process(), scp->name, scp->ptr, &(scp->size) );
				commit_process( proc );
				break;

		case OP( ENV, THREE ):
				proc = checkout_process( getpid(), READER );
				assert( proc != NULL );
				scp->rc = get_environment_size( current_process(), scp->name, &(scp->size) );
				commit_process( proc );
				break;

		case OP( ENV, FOUR ):
				proc = checkout_process( getpid(), READER );
				assert( proc != NULL );
				scp->rc = get_environment_information( current_process(), scp->id, scp->name, &(scp->size) );
				commit_process( proc );
				break;

		case OP( ENV, FIVE ):
				proc = checkout_process( getpid(), WRITER );
				assert( proc != NULL );
				scp->rc = remove_environment( current_process(), scp->name );
				commit_process( proc );
				break;

	}

}
Exemple #15
0
bool Camera::_set(const StringName& p_name, const Variant& p_value) {

	bool changed_all=false;
	if (p_name=="projection") {

		int proj = p_value;
		if (proj==PROJECTION_PERSPECTIVE)
			mode=PROJECTION_PERSPECTIVE;
		if (proj==PROJECTION_ORTHOGONAL)
			mode=PROJECTION_ORTHOGONAL;

		changed_all=true;
	} else if (p_name=="fov")
		fov=p_value;
	else if (p_name=="size")
		size=p_value;
	else if (p_name=="near")
		near=p_value;
	else if (p_name=="far")
		far=p_value;														
	else if (p_name=="vaspect")
		set_use_vertical_aspect(p_value);
	else if (p_name=="current") {
		if (p_value.operator bool()) {
			make_current();
		} else {
			clear_current();
		}
	} else if (p_name=="visible_layers") {
		set_visible_layers(p_value);
	} else if (p_name=="environment") {
		set_environment(p_value);
	} else
		return false;
		
	_update_camera_mode();
	if (changed_all)
		_change_notify();
	return true;

}
Exemple #16
0
static void process_click(int fd) {
	char buf[SMALL_BUF];
	char *args[MAX_CLICK_ARGS];
	int x,y;
	ssize_t n_bytes;
	pid_t childpid;

	n_bytes = read(fd, buf, SMALL_BUF);
	if (n_bytes < 0){
		perror("lemonbar click read");
	}
	if (buf[n_bytes-1] == '\n'){
		buf[n_bytes-1] = '\0'; //ends in newline, overwrite \n with termination
	} else {
		buf[n_bytes] = 0;
	}

	if ((childpid = fork()) == -1) {
		perror("fork");
		return;
	}

	if (childpid == 0) {
		DEBUG_(printf("got command string: %s\n",buf));
		process_args(buf, args);
		mouseloc(&x,&y);
		if (x != -1 && y != -1){
			set_env_coords(x,y);
		} else {
			fprintf(stderr, "mouse location determination failed\n");
		}
		set_environment();
		execvp(args[0],args);
	} else {
		return;
	}

	DEBUG_(printf("got lemonbar output: %s\n", buf));
}
Exemple #17
0
/** This function takes the environment variables set up in the
 * source process and duplicates (copies) everything across to the
 * destination process.
 *
 * \warning This function first calls release_environment on the
 * destination process. Also, if an error occurs during the clone
 * then the destination process is left without any environment
 * variables.
 *
 * \param src The R-LOCKED source process to get environment variables from.
 * \param dest The W-LOCKED dest process to copy environment variables into.
 * \return 0 on success.
 */
int clone_environment( struct process *dest, struct process *src )
{
    int i;
    struct environ_info *env = (struct environ_info *)src->environment;

    if ( release_environment( dest ) != 0 ) return -1;

    if ( env == NULL ) return 0; 	// Already done. :)


    for ( i = 0; i < src->environment_count; i++ )
    {
        if ( set_environment( dest, env[i].name,
                              env[i].data,
                              env[i].size ) != 0 )
        {
            release_environment( dest );
            return -1;
        }
    }


    return 0;
}
Exemple #18
0
static int
startClient(char *client[])
{
    clientpid = fork();
    if (clientpid == 0) {
        set_environment();
        setWindowPath();

        if (setuid(getuid()) == -1) {
            Error("cannot change uid");
            _exit(EXIT_FAILURE);
        }
        setpgid(0, getpid());
        Execute(client);
        Error("Unable to run program \"%s\"", client[0]);

        fprintf(stderr, "Specify a program on the command line or make sure that %s\n", bindir);
        fprintf(stderr, "is in your path.\n\n");

        _exit(EXIT_FAILURE);
    } else {
        return clientpid;
    }
}
Exemple #19
0
	selector_widget::selector_widget(const selector_list& list)
		: current_selection_(0), list_(list)
	{
		set_environment();
		init();
	}
Exemple #20
0
checkbox::checkbox(const std::string& label, bool checked, boost::function<void(bool)> onclick, BUTTON_RESOLUTION button_resolution)
  : button(create_checkbox_widget(label, checked), boost::bind(&checkbox::on_click, this), BUTTON_STYLE_NORMAL,button_resolution), label_(label), onclick_(onclick), checked_(checked)
{
	set_environment();
}
Exemple #21
0
scrollable_widget::scrollable_widget() : yscroll_(0), virtual_height_(0), step_(0), arrow_step_(0)
{
	set_environment();
}