コード例 #1
0
ファイル: my_script.c プロジェクト: ivanignatiev/script
int		main(int argc, char **argv)
{
    int		master_fd;
    int		opt[2];

    if (prepare_options(argc, argv, opt))
      {
	if (prepare_tcattr())
	  {
	    if (open_master(&master_fd))
	      {
		if (fork_pty(master_fd,
			     (opt[0] == -1 ? DEFAULT_SCRIPT_ : argv[opt[0]]),
			     opt[1]))
		  {
		    close(master_fd);
		    return (reset_settings());
		  }
		close(master_fd);
	      }
	    reset_settings();
	  }
      }
    return (EXIT_FAILURE);
}
コード例 #2
0
 action_t config_audio::execute()
 {
   reply r;
   r("207 OK RECEIVING AUDIO SETTINGS");
   reset_settings();
   read_settings();
   if(initialize_audio())
     {
       r("203-Opened a playback stream");
       r("203 OK AUDIO INITIALIZED");
     }
   else
     {
       r("400-Cannot open a playback stream");
       r("400 ERROR AUDIO NOT INITIALIZED");
     }
   return action_continue;
 }
コード例 #3
0
ファイル: xsys.c プロジェクト: fuzzmz/hexchat
static int
sysinfo_cb (char *word[], char *word_eol[], void *userdata)
{
	error_printed = 0;
	int announce = 0;
	int buffer;
	char format[bsize];

	if (!hexchat_pluginpref_get_str (ph, "format", format))
	{
		hexchat_printf (ph, "%s\tError reading config file!", name);
		return HEXCHAT_EAT_ALL;
	}

	if (hexchat_list_int (ph, NULL, "type") >= 2)
	{
		announce = 1;
	}

	if (!g_ascii_strcasecmp ("HELP", word[2]))
	{
		hexchat_printf (ph, sysinfo_help);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("LIST", word[2]))
	{
		list_settings ();
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("SET", word[2]))
	{
		if (!g_ascii_strcasecmp ("", word_eol[4]))
		{
			hexchat_printf (ph, "%s\tEnter a value!\n", name);
			return HEXCHAT_EAT_ALL;
		}
		if (!g_ascii_strcasecmp ("format", word[3]))
		{
			hexchat_pluginpref_set_str (ph, "format", word_eol[4]);
			hexchat_printf (ph, "%s\tformat is set to: %s\n", name, word_eol[4]);
		}
		else if (!g_ascii_strcasecmp ("percent", word[3]))
		{
			buffer = atoi (word[4]);	/* don't use word_eol, numbers must not contain spaces */

			if (buffer > 0 && buffer < INT_MAX)
			{
				hexchat_pluginpref_set_int (ph, "percent", buffer);
				hexchat_printf (ph, "%s\tpercent is set to: %d\n", name, buffer);
			}
			else
			{
				hexchat_printf (ph, "%s\tInvalid input!\n", name);
			}
		}
		else if (!g_ascii_strcasecmp ("pciids", word[3]))
		{
			hexchat_pluginpref_set_str (ph, "pciids", word_eol[4]);
			hexchat_printf (ph, "%s\tpciids is set to: %s\n", name, word_eol[4]);
		}
		else
		{
			hexchat_printf (ph, "%s\tInvalid variable name! Use 'pciids', 'format' or 'percent'!\n", name);
			return HEXCHAT_EAT_ALL;
		}

		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("RESET", word[2]))
	{
		reset_settings ();
		hexchat_printf (ph, "%s\tSettings have been restored to defaults.\n", name);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("OS", word[2]))
	{
		print_os (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("DISTRO", word[2]))
	{
		print_distro (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("CPU", word[2]))
	{
		print_cpu (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("RAM", word[2]))
	{
		print_ram (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("DISK", word[2]))
	{
		print_disk (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("VGA", word[2]))
	{
		print_vga (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("SOUND", word[2]))
	{
		print_sound (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("ETHERNET", word[2]))
	{
		print_ethernet (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("UPTIME", word[2]))
	{
		print_uptime (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("", word[2]))
	{
		print_summary (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else
	{
		hexchat_printf (ph, sysinfo_help);
		return HEXCHAT_EAT_ALL;
	}
}