예제 #1
0
파일: lua.c 프로젝트: Cynede/hexchat
static void check_deferred(script_info *info)
{
	info->status &= ~STATUS_ACTIVE;
	if(info->status & STATUS_DEFERRED_UNLOAD)
	{
		run_unload_hooks(info, NULL);
		g_ptr_array_remove_fast(scripts, info);
	}
	else if(info->status & STATUS_DEFERRED_RELOAD)
	{
		if(info == interp)
		{
			run_unload_hooks(interp, NULL);
			destroy_interpreter();
			create_interpreter();
		}
		else
		{
			char *filename = g_strdup(info->filename);
			run_unload_hooks(info, NULL);
			g_ptr_array_remove_fast(scripts, info);
			load_script(filename);
			g_free(filename);
		}
	}
}
예제 #2
0
파일: lua.c 프로젝트: Cynede/hexchat
G_MODULE_EXPORT int hexchat_plugin_init(hexchat_plugin *plugin_handle, char **name, char **description, char **version, char *arg)
{
    if (g_str_has_prefix(LUA_VERSION, "Lua "))
    {
        strcat(plugin_version, "/");
        g_strlcat(plugin_version, LUA_VERSION + 4, sizeof(plugin_version));
    }

    *name = plugin_name;
    *description = plugin_description;
    *version = plugin_version;

    ph = plugin_handle;

    hexchat_hook_command(ph, "", HEXCHAT_PRI_NORM, command_console_exec, NULL, NULL);
    hexchat_hook_command(ph, "LOAD", HEXCHAT_PRI_NORM, command_load, NULL, NULL);
    hexchat_hook_command(ph, "UNLOAD", HEXCHAT_PRI_NORM, command_unload, NULL, NULL);
    hexchat_hook_command(ph, "RELOAD", HEXCHAT_PRI_NORM, command_reload, NULL, NULL);
    hexchat_hook_command(ph, "lua", HEXCHAT_PRI_NORM, command_lua, command_help, NULL);

    hexchat_printf(ph, "%s version %s loaded.\n", plugin_name, plugin_version);

    scripts = g_ptr_array_new_with_free_func((GDestroyNotify)destroy_script);
    create_interpreter();

    if(!arg)
        autoload_scripts();
    return 1;
}
예제 #3
0
파일: channel-usb.c 프로젝트: kadych/iscan
channel *
channel_interpreter_ctor (channel *self, const char *dev_name,
                          SANE_Status *status)
{
  char *name = NULL;
  size_t name_len = 0;

  require (self && dev_name);
  require (0 == strncmp_c (dev_name, "interpreter:", strlen ("interpreter:")));

  dev_name += strlen ("interpreter:");
  name_len  = strlen ("usb:") + strlen (dev_name) + 1;

  name = t_malloc (name_len, char);
  if (!name)
    {
      if (status) *status = SANE_STATUS_NO_MEM;
      return self->dtor (self);
    }
  strcpy (name, "usb:");
  strcat (name, dev_name);

  self = channel_usb_ctor (self, name, status);
  delete (name);

  if (self)
    {
      SANE_Status s = SANE_STATUS_GOOD;
      SANE_Word vendor;
      SANE_Word product;

      self->open (self, &s);
      if (SANE_STATUS_GOOD == s)
        {
          s = sanei_usb_get_vendor_product (self->fd,
                                            &vendor, &product);
        }
      self->close (self, NULL);
      if (SANE_STATUS_GOOD == s)
        {
          s = create_interpreter (self, product);
        }

      if (!self->interpreter)
        {
          if (status) *status = s;
          return self->dtor (self);
        }
      else
        {
          self->dtor = channel_interpreter_dtor;
        }
    }

  self->max_size = 32 * 1024;

  return self;
}
예제 #4
0
/**
 * ./itrace -p [PID]
 *
 * opens an interactive session where you can trace a process single-step
 * the instructions will be disassembled via udis86
 * provided by sample code snyfer.c
 */
int main(int argc,
	 char* argv[])
{
  if(3==argc)
  {
    init_attach(argv[2]);
    create_interpreter();
    do_sniff();
  }else{
    do_usage();
    return -1;
  }

  return 0;
}
예제 #5
0
파일: lua.c 프로젝트: Cynede/hexchat
static int command_lua(char *word[], char *word_eol[], void *userdata)
{
	if(!strcmp(word[2], "load"))
	{
		load_script(word[3]);
	}
	else if(!strcmp(word[2], "unload"))
	{
		if(!unload_script(word[3]))
			hexchat_printf(ph, "Could not find a script by the name '%s'", word[3]);
	}
	else if(!strcmp(word[2], "reload"))
	{
		if(!reload_script(word[3]))
			hexchat_printf(ph, "Could not find a script by the name '%s'", word[3]);
	}
	else if(!strcmp(word[2], "exec"))
	{
		if(interp)
			inject_string(interp, word_eol[3]);
	}
	else if(!strcmp(word[2], "inject"))
	{
		script_info *script = get_script_by_file(word[3]);
		if (script)
		{
			inject_string(script, word_eol[4]);
		}
		else
		{
			hexchat_printf(ph, "Could not find a script by the name '%s'", word[3]);
		}
	}
	else if(!strcmp(word[2], "reset"))
	{
		if(interp)
		{
			if(interp->status & STATUS_ACTIVE)
			{
				interp->status |= STATUS_DEFERRED_RELOAD;
			}
			else
			{
				run_unload_hooks(interp, NULL);
				destroy_interpreter();
				create_interpreter();
			}
		}
	}
	else if(!strcmp(word[2], "list"))
	{
		guint i;
		hexchat_print(ph,
		   "Name             Version  Filename             Description\n"
		   "----             -------  --------             -----------\n");
		for(i = 0; i < scripts->len; i++)
		{
			script_info *info = scripts->pdata[i];
			char *basename = g_path_get_basename(info->filename);
			hexchat_printf(ph, "%-16s %-8s %-20s %-10s\n", info->name, info->version,
						   basename, info->description);
			g_free(basename);
		}
		if(interp)
			hexchat_printf(ph, "%-16s %-8s", interp->name, plugin_version);
	}
	else if(!strcmp(word[2], "console"))
	{
		hexchat_commandf(ph, "query %s", console_tab);
	}
	else
	{
		hexchat_command(ph, "help lua");
	}
	return HEXCHAT_EAT_ALL;
}