Exemple #1
0
JsonValue::JsonValuePtr Effect::get_info() const {
  auto info = JsonValue::create_object();
  info->add_key_value("name", name());
  info->add_key_value("start_time", (int32)_start_time);
  info->add_key_value("end_time", (int32)_end_time);

  auto params = JsonValue::create_array();
  for (auto it = begin(_params); it != end(_params); ++it) {
    params->add_value((*it)->to_json());
  }
  info->add_key_value("params", params);
  return info;
}
Exemple #2
0
void put_symbol(Symbol symbol, hash_table_t table)
{
    char *name;

    name = symbol_name(symbol);
    add_key_value(name, symbol, table);
}
Exemple #3
0
void
wpa_parser_init (const char *wpa_supplicant_conf)
{
	GIOChannel *channel = NULL;
	gchar *line;
	gboolean complete = FALSE;

	wpa_parser_data_changed = FALSE;
	wsec_table = g_hash_table_new (g_str_hash, g_str_equal);
	wsec_global_table = g_hash_table_new (g_str_hash, g_str_equal);

	if (g_file_test (wpa_supplicant_conf, G_FILE_TEST_IS_REGULAR))
		channel =
		    g_io_channel_new_file (wpa_supplicant_conf, "r", NULL);
	if (channel == NULL) {
		nm_log_warn (LOGD_SETTINGS, "Can't open %s for wireless security",
		             wpa_supplicant_conf);
		return;
	}

	while (g_io_channel_read_line (channel, &line, NULL, NULL, NULL)
	       != G_IO_STATUS_EOF) {
		g_strstrip (line);
		if (line[0] != '#' && line[0] != '\0') {
			if (strstr (line, "network={") == NULL) {
				add_global_data (line);
				g_free (line);
				continue;
			} else {
				GHashTable *network =
				    g_hash_table_new (g_str_hash, g_str_equal);

				do {
					gchar *quote_start, *quote_end = NULL, *comment;

					if (line[0] == '#' || line[0] == '\0') {
						g_free (line);
						continue;
					}
					/* ignore inline comments unless inside
					   a double-quoted string */
					if ((quote_start = strchr (line, '"')) != NULL)
						quote_end = strrchr (quote_start + 1, '"');
					if ((comment = strchr ((quote_end != NULL) ?
					                       quote_end : line, '#')) != NULL)
						*comment = '\0';
					if (strstr (line, "}") != NULL)
						complete = TRUE;
					add_key_value (network, line);
					g_free (line);
				} while (complete == FALSE
					 &&
					 g_io_channel_read_line
					 (channel, &line, NULL,
					  NULL, NULL) != G_IO_STATUS_EOF);
				add_security (network);
				//EOF in inner loop
				if (complete == FALSE) {
					g_free (line);
					break;
				}
				complete = FALSE;
			}
		} else
			g_free (line);
	}

	g_io_channel_shutdown (channel, FALSE, NULL);
	g_io_channel_unref (channel);

	add_keys_from_net ();
}