Пример #1
0
BOOL	set_env(char *s, char *s2)
{
  char	**tab;
  size_t	i;

  i = 0;
  if (environ)
    while (environ[i])
      if (move_env(s, i++))
	return (fill_env(s, s2, i - 1));
  if ((tab = xmalloc(sizeof(*tab) * (i + 3))) == NULL)
    return (FALSE);
  i = 0;
  if (environ)
    while (environ[i++])
      tab[i - 1] = environ[i - 1];
  tab[i - 1] = my_stricat(s, s2, '=');
  tab[i] = NULL;
  return (switch_env(tab, FALSE));
}
Пример #2
0
void
meta_draw_op_list_draw_with_style (const MetaDrawOpList *op_list,
                                   GtkStyleContext      *context,
                                   cairo_t              *cr,
                                   const MetaDrawInfo   *info,
                                   MetaRectangleDouble   rect)
{
  int i;
  MetaPositionExprEnv env;

  fill_env (&env, info, rect);

  cairo_save (cr);

  for (i = 0; i < op_list->n_ops; i++)
    {
      MetaDrawOp *op = op_list->ops[i];

      if (op->type == META_DRAW_CLIP)
        {
          cairo_restore (cr);

          cairo_rectangle (cr,
                           meta_draw_spec_parse_x_position (op->data.clip.x, &env),
                           meta_draw_spec_parse_y_position (op->data.clip.y, &env),
                           meta_draw_spec_parse_size (op->data.clip.width, &env),
                           meta_draw_spec_parse_size (op->data.clip.height, &env));
          cairo_clip (cr);

          cairo_save (cr);
        }
      else if (gdk_cairo_get_clip_rectangle (cr, NULL))
        {
          draw_op_draw_with_env (op, context, cr, info, &env);
        }
    }

  cairo_restore (cr);
}
Пример #3
0
void		b_env(char **buffer)
{
	int		i_opt;
	char	**tmp_env;
	int		i;

	i_opt = get_i_opt(buffer);
	if (i_opt < 0)
		return ;
	if (!i_opt)
		tmp_env = strdup_2d(g_env);
	else
	{
		tmp_env = (char **)malloc(sizeof(char *) * 2);
		ft_bzero(tmp_env, sizeof(char *) * 2);
	}
	i = i_opt + 1;
	i = fill_env(buffer, &tmp_env, i);
	if (!buffer[i])
		ft_print_env(tmp_env);
	else
		b_env_find_exec(&(buffer[i]), tmp_env);
	strfree_2d(tmp_env);
}
Пример #4
0
int		main(int ac, char **av, char **env)
{
	struct termios		reset;
	t_le				le;
	t_env				*data_env;

	if (ac && av)
		;
	if (tcgetattr(0, &reset) == -1)
		message_handling();
	g_name_prog = NULL;
	signal(SIGWINCH, update_size);
	data_env = create_env(env);
	data_env->reset = reset;
	fill_env(&data_env, env);
	if (init_term(data_env) == 0)
		message_handling();
	init_env(&le, data_env);
	data_env->le = le;
	loop_prompt(data_env);
	free_env(&data_env);
	reset_term(reset);
	return (0);
}
static int _create_process (lua_State *lua_state)
{
   char* commandline;
   WORD show_mode = SW_SHOWNORMAL;
   WORD flags = NORMAL_PRIORITY_CLASS;
   char* dir = NULL;
   char* env = NULL;
   static char buffer[1024];

   luaL_arg_check(lua_state,
                  lua_istable(lua_state, 1) || lua_isstring(lua_state, 1),1,
                  "must be a table or string");

   if (lua_isstring(lua_state, 1))
      commandline = _strdup(lua_tostring(lua_state, 1));
   else
   {
      lua_pushstring(lua_state, "cmd");
      lua_gettable(lua_state, 1);
      if (lua_isstring(lua_state, -1))
      {
        commandline = _strdup(lua_tostring(lua_state, -1));
      }
      else
         make_lua_error(lua_state, "The cmd field must be provided");

      lua_pushstring(lua_state, "console");
      lua_gettable(lua_state, 1);
      if (!lua_isnil(lua_state, -1))
         flags |= CREATE_NEW_CONSOLE;

      lua_pushstring(lua_state, "show_mode");
      lua_gettable(lua_state, 1);
      if (lua_isstring(lua_state, -1))
         show_mode = getShowMode(lua_tostring(lua_state, -1));

      lua_pushstring(lua_state, "dir");
      lua_gettable(lua_state, 1);
      if (lua_isstring(lua_state, -1))
         dir = _strdup(lua_tostring(lua_state, -1));

      lua_pushstring(lua_state, "env");
      lua_gettable(lua_state, 1);
      if (lua_istable(lua_state, -1))
      {
         fill_env(lua_state, buffer);
         env = buffer;
      }
   }

   STARTUPINFO si;
   PROCESS_INFORMATION pi;
   ZeroMemory(&si, sizeof(STARTUPINFO));
   si.cb = sizeof(STARTUPINFO);
   si.dwFlags = STARTF_USESHOWWINDOW;
   si.wShowWindow = show_mode;
   BOOL pr = CreateProcess(NULL,commandline,NULL,NULL,FALSE,
                           flags,env,dir,&si,&pi);

   free(commandline);
   free(dir);

   CloseHandle(pi.hThread);
   CloseHandle(pi.hProcess);
   if (!pr)
      lua_pushnil(lua_state);
   else
      lua_pushnumber(lua_state, pi.dwProcessId);

   /* number of results */
   return 1;
}