Ejemplo n.º 1
0
static bool
check_bool(GLboolean b, bool expected)
{
	/* Negate the bools before comparing so that distinct nonzero
	 * values compare equal.
	 */
	if ((!b) == (!expected)) {
		return true;
	} else {
		printf("Expected %s, got %s\n", bool_to_string(expected),
		       bool_to_string(b));
		return false;
	}
}
Ejemplo n.º 2
0
/**
 * sends a UPC message to send a message to the given room
 */
void
RoomManager::SendMessage(UPCMessageID messageName, std::vector<RoomID> rooms, StringArgs msg,
		bool includeSelf, IFilterRef filters) const {
	if (std::string(messageName) == "") {
		log.Warn(GetName()+"  sendMessage() failed. No messageName supplied.");
		return;
	}

	std::string roomStr;
	for (auto it=rooms.begin(); it!=rooms.end(); ++it) {
		if (it > rooms.begin()) {
			roomStr.append(Token::RS);
		}
		roomStr.append(*it);
	}

	StringArgs args = {
		messageName,
		roomStr,
		bool_to_string(includeSelf),
		filters ? filters->ToXMLString() : ""};

	for (auto it=msg.begin(); it!=msg.end(); it++) {
		args.push_back(*it);
	}
	unionBridge.SendUPC(UPC::ID::SEND_MESSAGE_TO_ROOMS, args);
}
Ejemplo n.º 3
0
std::string
Arguments::to_string(){
    std::stringstream out;
    out << "Input scene: \t" << in_scene << std::endl
        << "Input mesh: \t" << in_mesh << std::endl
        << "Output prefix: \t" << out_prefix << std::endl
        << "Datacost file: \t" << data_cost_file << std::endl
        << "Labeling file: \t" << labeling_file << std::endl
        << "Data term: \t" << choice_string<tex::DataTerm>(settings.data_term) << std::endl
        << "Smoothness term: \t" << choice_string<tex::SmoothnessTerm>(settings.smoothness_term) << std::endl
        << "Outlier removal method: \t" << choice_string<tex::OutlierRemoval>(settings.outlier_removal) << std::endl
        << "Apply global seam leveling: \t" << bool_to_string(settings.global_seam_leveling) << std::endl
        << "Apply local seam leveling: \t" << bool_to_string(settings.local_seam_leveling) << std::endl;

    return out.str();
}
Ejemplo n.º 4
0
void win32_windowed_app_setup_params::trace_dump() const {
    TRACE("hinstance : {:x}", (unsigned int)get_hinstance());
    TRACE("window_class_name : {}", utf16_to_utf8(get_window_class_name()));
    TRACE("window_caption : {}", utf16_to_utf8(get_window_caption()));
    TRACE("min_window_size : {}", get_min_window_size());
    TRACE("small_icon_id : {}", get_small_icon_id());
    TRACE("large_icon_id : {}", get_large_icon_id());
    TRACE("is_visible_by_default : {}", bool_to_string(get_is_visible_by_default()));
}
Ejemplo n.º 5
0
/**
 * request server to stop watching for rooms according to given qualifier
 */
void
RoomManager::StopWatchingForRooms(const RoomQualifier roomQualifier) const {
	bool recursive = false;
	// "" means watch the whole server
	if (roomQualifier == "") {
		recursive = true;
	}


	unionBridge.SendUPC(UPC::ID::STOP_WATCHING_FOR_ROOMS, {roomQualifier, bool_to_string(recursive)} );
};
Ejemplo n.º 6
0
void	print_out_facts_table()
{
  if (g_facts.empty())
    {
      std::cout << "no facts into table" << std::endl;
      return;
    }
  std::cout << "print out facts table:" << std::endl;
  for (FactsSet::iterator it = g_facts.begin(), end = g_facts.end();
       it != end; ++it)
    std::cout << it->first << " = " << bool_to_string(it->second) << std::endl;
}
Ejemplo n.º 7
0
// The application (just print out some config values in this case)
int lift(KeySet *conf)
{
	kdb_boolean_t stops = get_test_lift_emergency_action_stops(conf);
	enum algorithm a = get_test_lift_algorithm(conf);
	kdb_boolean_t write = get_test_lift_write(conf);

	printf("delay: "ELEKTRA_LONG_F"\n", get_test_lift_emergency_delay(conf));
	printf("stops: %s\n", bool_to_string(stops));
	printf("algorithm: %s\n", algorithm_to_string(a));
	printf("height #3: %f\n", get_test_lift_floor_3_height(conf));
	printf("write: %s\n", bool_to_string(write));
	printf("limit: "ELEKTRA_LONG_F"\n", get_test_lift_limit(conf));
	printf("number: %s\n", get_test_lift_emergency_action_calls_number(conf));

	// rewrite the same (does not change anything)
	set_test_lift_algorithm(conf, a);
	set_test_lift_emergency_action_stops(conf, stops);

	// set option to write out false
	set_test_lift_write(conf, 0);

	return write;
}
Ejemplo n.º 8
0
void RubyConfig::printConfiguration(ostream& out) {
  out << "Ruby Configuration" << endl;
  out << "------------------" << endl;

  out << "protocol: " << CURRENT_PROTOCOL << endl;
  SIMICS_print_version(out);
  out << "compiled_at: " << __TIME__ << ", " << __DATE__ << endl;
  out << "RUBY_DEBUG: " << bool_to_string(RUBY_DEBUG) << endl;

  char buffer[100];
  gethostname(buffer, 50);
  out << "hostname: " << buffer << endl;

  print_parameters(out);
}
Ejemplo n.º 9
0
bool
conf_print_items(struct conf *conf,
                 void (*printer)(const char *descr, const char *origin,
                                 void *context),
                 void *context)
{
	char *s = x_strdup("");
	char *s2;

	reformat(&s, "base_dir = %s", conf->base_dir);
	printer(s, conf->item_origins[find_conf("base_dir")->number], context);

	reformat(&s, "cache_repo_path = %s", conf->cache_repo_path);
	printer(s, conf->item_origins[find_conf("cache_repo_path")->number], context);

	reformat(&s, "cache_dir = %s", conf->cache_dir);
	printer(s, conf->item_origins[find_conf("cache_dir")->number], context);

	reformat(&s, "cache_dir_levels = %u", conf->cache_dir_levels);
	printer(s, conf->item_origins[find_conf("cache_dir_levels")->number],
	        context);

	reformat(&s, "compiler = %s", conf->compiler);
	printer(s, conf->item_origins[find_conf("compiler")->number], context);

	reformat(&s, "compiler_check = %s", conf->compiler_check);
	printer(s, conf->item_origins[find_conf("compiler_check")->number], context);

	reformat(&s, "compression = %s", bool_to_string(conf->compression));
	printer(s, conf->item_origins[find_conf("compression")->number], context);

	reformat(&s, "compression_level = %u", conf->compression_level);
	printer(s, conf->item_origins[find_conf("compression_level")->number],
	        context);

	reformat(&s, "cpp_extension = %s", conf->cpp_extension);
	printer(s, conf->item_origins[find_conf("cpp_extension")->number], context);

	reformat(&s, "direct_mode = %s", bool_to_string(conf->direct_mode));
	printer(s, conf->item_origins[find_conf("direct_mode")->number], context);

	reformat(&s, "disable = %s", bool_to_string(conf->disable));
	printer(s, conf->item_origins[find_conf("disable")->number], context);

	reformat(&s, "extra_files_to_hash = %s", conf->extra_files_to_hash);
	printer(s, conf->item_origins[find_conf("extra_files_to_hash")->number],
	        context);

	reformat(&s, "hard_link = %s", bool_to_string(conf->hard_link));
	printer(s, conf->item_origins[find_conf("hard_link")->number], context);

	reformat(&s, "hash_dir = %s", bool_to_string(conf->hash_dir));
	printer(s, conf->item_origins[find_conf("hash_dir")->number], context);

	reformat(&s, "log_file = %s", conf->log_file);
	printer(s, conf->item_origins[find_conf("log_file")->number], context);

	reformat(&s, "max_files = %u", conf->max_files);
	printer(s, conf->item_origins[find_conf("max_files")->number], context);

	s2 = format_parsable_size_with_suffix(conf->max_size);
	reformat(&s, "max_size = %s", s2);
	printer(s, conf->item_origins[find_conf("max_size")->number], context);
	free(s2);

	reformat(&s, "path = %s", conf->path);
	printer(s, conf->item_origins[find_conf("path")->number], context);

	reformat(&s, "prefix_command = %s", conf->prefix_command);
	printer(s, conf->item_origins[find_conf("prefix_command")->number], context);

	reformat(&s, "read_only = %s", bool_to_string(conf->read_only));
	printer(s, conf->item_origins[find_conf("read_only")->number], context);

	reformat(&s, "read_only_direct = %s", bool_to_string(conf->read_only_direct));
	printer(s, conf->item_origins[find_conf("read_only_direct")->number],
	        context);

	reformat(&s, "recache = %s", bool_to_string(conf->recache));
	printer(s, conf->item_origins[find_conf("recache")->number], context);

	reformat(&s, "run_second_cpp = %s", bool_to_string(conf->run_second_cpp));
	printer(s, conf->item_origins[find_conf("run_second_cpp")->number], context);

	reformat(&s, "sloppiness = ");
	if (conf->sloppiness & SLOPPY_FILE_MACRO) {
		reformat(&s, "%sfile_macro, ", s);
	}
	if (conf->sloppiness & SLOPPY_INCLUDE_FILE_MTIME) {
		reformat(&s, "%sinclude_file_mtime, ", s);
	}
	if (conf->sloppiness & SLOPPY_INCLUDE_FILE_CTIME) {
		reformat(&s, "%sinclude_file_ctime, ", s);
	}
	if (conf->sloppiness & SLOPPY_TIME_MACROS) {
		reformat(&s, "%stime_macros, ", s);
	}
	if (conf->sloppiness & SLOPPY_FILE_STAT_MATCHES) {
		reformat(&s, "%sfile_stat_matches, ", s);
	}
	if (conf->sloppiness) {
		/* Strip last ", ". */
		s[strlen(s) - 2] = '\0';
	}
	printer(s, conf->item_origins[find_conf("sloppiness")->number], context);

	reformat(&s, "stats = %s", bool_to_string(conf->stats));
	printer(s, conf->item_origins[find_conf("stats")->number], context);

	reformat(&s, "temporary_dir = %s", conf->temporary_dir);
	printer(s, conf->item_origins[find_conf("temporary_dir")->number], context);

	if (conf->umask == UINT_MAX) {
		reformat(&s, "umask = ");
	} else {
		reformat(&s, "umask = %03o", conf->umask);
	}
	printer(s, conf->item_origins[find_conf("umask")->number], context);

	reformat(&s, "unify = %s", bool_to_string(conf->unify));
	printer(s, conf->item_origins[find_conf("unify")->number], context);

	free(s);
	return true;
}
Ejemplo n.º 10
0
GSList* soy_net_xmpp_agent_get_remote_candidates (soynetXMPPAgent* self, LmMessageNode* transport, guint stream_id) {
	GSList* result = NULL;
	GSList* rcands = NULL;
	LmMessageNode* candidate = NULL;
	LmMessageNode* _tmp0_ = NULL;
	LmMessageNode* _tmp1_ = NULL;
	LmMessageNode* _tmp2_ = NULL;
	LmMessageNode* _tmp3_ = NULL;
	GSList* _tmp45_ = NULL;
	GSList* _tmp46_ = NULL;
#line 119 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	g_return_val_if_fail (self != NULL, NULL);
#line 119 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	g_return_val_if_fail (transport != NULL, NULL);
#line 120 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	rcands = NULL;
#line 121 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_tmp0_ = transport;
#line 121 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_tmp1_ = lm_message_node_get_child (_tmp0_, "candidate");
#line 121 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_tmp2_ = _lm_message_node_ref0 (_tmp1_);
#line 121 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	candidate = _tmp2_;
#line 124 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_tmp3_ = candidate;
#line 124 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	if (_tmp3_ == NULL) {
#line 125 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		result = rcands;
#line 125 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_lm_message_node_unref0 (candidate);
#line 125 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		return result;
#line 584 "XMPPAgent.c"
	}
#line 127 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	while (TRUE) {
#line 588 "XMPPAgent.c"
		LmMessageNode* _tmp4_ = NULL;
		NiceCandidate* rcand = NULL;
		GeeHashMap* _tmp5_ = NULL;
		LmMessageNode* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		gpointer _tmp8_ = NULL;
		NiceCandidate* _tmp9_ = NULL;
		LmMessageNode* _tmp10_ = NULL;
		const gchar* _tmp11_ = NULL;
		LmMessageNode* _tmp12_ = NULL;
		const gchar* _tmp13_ = NULL;
		LmMessageNode* _tmp14_ = NULL;
		const gchar* _tmp15_ = NULL;
		LmMessageNode* _tmp16_ = NULL;
		const gchar* _tmp17_ = NULL;
		NiceCandidate* _tmp18_ = NULL;
		LmMessageNode* _tmp19_ = NULL;
		const gchar* _tmp20_ = NULL;
		NiceCandidate* _tmp21_ = NULL;
		LmMessageNode* _tmp22_ = NULL;
		const gchar* _tmp23_ = NULL;
		gint _tmp24_ = 0;
		NiceCandidate* _tmp25_ = NULL;
		NiceCandidate* _tmp26_ = NULL;
		LmMessageNode* _tmp27_ = NULL;
		const gchar* _tmp28_ = NULL;
		gint _tmp29_ = 0;
		NiceCandidate* _tmp30_ = NULL;
		LmMessageNode* _tmp31_ = NULL;
		const gchar* _tmp32_ = NULL;
		gint _tmp33_ = 0;
		NiceCandidate* _tmp34_ = NULL;
		guint _tmp35_ = 0U;
		NiceCandidate* _tmp36_ = NULL;
		gboolean _tmp37_ = FALSE;
		gchar* _tmp38_ = NULL;
		gchar* _tmp39_ = NULL;
		NiceCandidate* _tmp40_ = NULL;
		NiceCandidate* _tmp41_ = NULL;
		LmMessageNode* _tmp42_ = NULL;
		LmMessageNode* _tmp43_ = NULL;
		LmMessageNode* _tmp44_ = NULL;
#line 127 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp4_ = candidate;
#line 127 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		if (!(_tmp4_ != NULL)) {
#line 127 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
			break;
#line 637 "XMPPAgent.c"
		}
#line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp5_ = soy_net_xmpp_agent_candidate_type_dict;
#line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp6_ = candidate;
#line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp7_ = lm_message_node_get_attribute (_tmp6_, "type");
#line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp8_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp5_, _tmp7_);
#line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp9_ = nice_candidate_new ((guint) ((gint) ((gintptr) _tmp8_)));
#line 129 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		rcand = _tmp9_;
#line 131 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		g_print ("Remote Candidate\n");
#line 132 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp10_ = candidate;
#line 132 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp11_ = lm_message_node_get_attribute (_tmp10_, "ip");
#line 132 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		g_print ("%s\n", _tmp11_);
#line 133 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp12_ = candidate;
#line 133 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp13_ = lm_message_node_get_attribute (_tmp12_, "port");
#line 133 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		g_print ("port: %s\n", _tmp13_);
#line 134 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp14_ = candidate;
#line 134 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp15_ = lm_message_node_get_attribute (_tmp14_, "priority");
#line 134 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		g_print ("priority:  %s\n", _tmp15_);
#line 135 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp16_ = candidate;
#line 135 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp17_ = lm_message_node_get_attribute (_tmp16_, "component");
#line 135 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		g_print ("component %s\n", _tmp17_);
#line 138 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp18_ = rcand;
#line 138 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp19_ = candidate;
#line 138 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp20_ = lm_message_node_get_attribute (_tmp19_, "ip");
#line 138 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		nice_address_set_from_string (&_tmp18_->addr, _tmp20_);
#line 139 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp21_ = rcand;
#line 139 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp22_ = candidate;
#line 139 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp23_ = lm_message_node_get_attribute (_tmp22_, "port");
#line 139 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp24_ = atoi (_tmp23_);
#line 139 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		nice_address_set_port (&_tmp21_->addr, (guint) _tmp24_);
#line 140 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp25_ = rcand;
#line 140 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp25_->transport = NICE_CANDIDATE_TRANSPORT_UDP;
#line 141 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp26_ = rcand;
#line 141 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp27_ = candidate;
#line 141 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp28_ = lm_message_node_get_attribute (_tmp27_, "priority");
#line 141 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp29_ = atoi (_tmp28_);
#line 141 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp26_->priority = (guint32) _tmp29_;
#line 142 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp30_ = rcand;
#line 142 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp31_ = candidate;
#line 142 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp32_ = lm_message_node_get_attribute (_tmp31_, "component");
#line 142 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp33_ = atoi (_tmp32_);
#line 142 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp30_->component_id = (guint) _tmp33_;
#line 143 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp34_ = rcand;
#line 143 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp35_ = stream_id;
#line 143 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp34_->stream_id = _tmp35_;
#line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp36_ = rcand;
#line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp37_ = nice_address_is_valid (&_tmp36_->addr);
#line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp38_ = bool_to_string (_tmp37_);
#line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp39_ = _tmp38_;
#line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		g_print ("%s\n", _tmp39_);
#line 145 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_g_free0 (_tmp39_);
#line 146 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp40_ = rcand;
#line 146 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp41_ = nice_candidate_copy (_tmp40_);
#line 146 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		rcands = g_slist_append (rcands, _tmp41_);
#line 147 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp42_ = candidate;
#line 147 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp43_ = _tmp42_->next;
#line 147 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_tmp44_ = _lm_message_node_ref0 (_tmp43_);
#line 147 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_lm_message_node_unref0 (candidate);
#line 147 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		candidate = _tmp44_;
#line 127 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
		_nice_candidate_free0 (rcand);
#line 755 "XMPPAgent.c"
	}
#line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_tmp45_ = rcands;
#line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_tmp46_ = g_slist_copy (_tmp45_);
#line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	result = _tmp46_;
#line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_lm_message_node_unref0 (candidate);
#line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	_g_slist_free0 (rcands);
#line 148 "/home/jeff/Documents/libraries/libsoy/src/net/XMPPAgent.gs"
	return result;
#line 769 "XMPPAgent.c"
}
Ejemplo n.º 11
0
	void resource_system::setup(const resource_system_params& params) {
		TRACE("resource_system setup {{ provider_count:{} , is_watching_enabled:{} }}", params._providers.size(), bool_to_string(params._is_watching_enabled));
		for (const auto& provider : params._providers) {
			TRACE("resource_system provider : {}", provider.get_description());
		}

		_providers = params._providers;
	}
Ejemplo n.º 12
0
QString MainWindow::config_compile()
{
    QString config = "";

    config = "[General]\n";

    config  += "CONFIGURE_FSTAB=";

    config += bool_to_string(ui->cb_fstab->isChecked()) + "\n";

    if (ui->cb_crontab->isChecked())
    {
        QLineEdit* crontabs[] = {ui->txt_crontab_0, ui->txt_crontab_1, ui->txt_crontab_2, ui->txt_crontab_3, ui->txt_crontab_4, ui->txt_crontab_5, ui->txt_crontab_6, ui->txt_crontab_7, ui->txt_crontab_8, ui->txt_crontab_9};

        for(int i = 0; i < 10; i++)
        {
            if(crontabs[i]->text() != "")
            {
                if(i < 9)
                {
                    config += "CRONTAB_0" + QString::number(i+1);
                    config += "=" + crontabs[i]->text() + "\n";
                }
                else if(i == 9)
                {
                    config += "CRONTAB_" + QString::number(i+1);
                    config += "=" + crontabs[i]->text() + "\n";
                }
            }
        }
    }

    if(ui->txt_dnsserver->text() != "")
        config += "DNS_SERVER=" + ui->txt_dnsserver->text() + "\n";

    if(ui->txt_searchdomain->text() != "" && ui->txt_dnsserver->text() != "")
        config += "SEARCH_DOMAIN=" + ui->txt_searchdomain->text() + "\n";

    config += "LOCAL_APPS=" + bool_to_string(ui->cb_localapp->isChecked()) + "\n";

    if(ui->cb_localapp->isChecked() && ui->txt_localappextra->text() != "")
        config += "LOCAL_APPS_EXTRAMOUNTS=" + ui->txt_localappextra->text() + "\n";

    config += "LOCALDEV=" + bool_to_string(ui->cb_ldev->isChecked()) + "\n";

    config += "LOCALDEV_DENY_CD=" + bool_to_string(ui->cb_ldevdenycd->isChecked()) + "\n";

    config += "LOCALDEV_DENY_FLOPPY=" + bool_to_string(ui->cb_ldevdenyfloppy->isChecked()) + "\n";

    config += "LOCALDEV_DENY_INTERNAL_DISKS=" + bool_to_string(ui->cb_ldevdenyinternal->isChecked()) + "\n";

    config += "LOCALDEV_DENY_USB=" + bool_to_string(ui->cb_ldevdenyusb->isChecked()) + "\n";

    if(ui->txt_ldevdeny->text() != "")
        config += "LOCALDEV_DENY=" + ui->txt_ldevdeny->text() + "\n";

    config += "NBD_SWAP=" + bool_to_string(ui->cb_nbdswap->isChecked()) + "\n";

    if(ui->cb_nbdswap->isChecked())
    {
        config += "NBD_SWAP_PORT=";
        if(ui->txt_nbdswapport->text() != "")
        {
            config += ui->txt_nbdswapport->text() + "\n";
        }
        else if (ver_persistent < 1404)
        {
            config += "9572\n";
        }
        else
        {
            config += "10809\n";
        }
        config += "NBD_SWAP_SERVER=";
        if(ui->txt_nbdswapserver->text() != "")
        {
            config += ui->txt_nbdswapserver->text() + "\n";
        }
        else
        {
            config += "SERVER\n";
        }
    }

    if(ui->txt_server->text() != "")
    config += "SERVER=" + ui->txt_server->text() + "\n";

    if(ui->txt_sysloghost->text() != "")
    config += "SYSLOG_HOST=" + ui->txt_sysloghost->text() + "\n";

    config += "USE_LOCAL_SWAP=" + bool_to_string(ui->cb_localswap->isChecked()) + "\n";

    if (ui->cb_scripts->isChecked())
    {
        config += "\n[Scripts and Modules]\n";

        QLineEdit* scripts[] = {ui->txt_RC0, ui->txt_RC1, ui->txt_RC2, ui->txt_RC3, ui->txt_RC4, ui->txt_RC5, ui->txt_RC6, ui->txt_RC7, ui->txt_RC8, ui->txt_RC9};
        QLineEdit* modules[] = {ui->txt_mod0, ui->txt_mod1, ui->txt_mod2, ui->txt_mod3, ui->txt_mod4, ui->txt_mod5, ui->txt_mod6, ui->txt_mod7, ui->txt_mod8, ui->txt_mod9};

        for(int g = 0; g < 10; g++)
        {
            if(modules[g]->text() != "")
            {
                if(g < 9)
                {
                    config += "MODULE_0" + QString::number(g+1);
                    config += "=" + modules[g]->text() + "\n";
                }
                else if(g == 9)
                {
                    config += "MODULE_" + QString::number(g+1);
                    config += "=" + modules[g]->text() + "\n";
                }
            }
        }

        for(int h = 0; h < 10; h++)
        {
            if(scripts[h]->text() != "")
            {
                if(h < 9)
                {
                    config += "RCFILE_0" + QString::number(h+1);
                    config += "=" + scripts[h]->text() + "\n";
                }
                else if(h == 9)
                {
                    config += "RCFILE_" + QString::number(h+1);
                    config += "=" + scripts[h]->text() + "\n";
                }
            }
        }
    }

    config += "\n[Printer]\n";

    if(ui->txt_printerdevice->text() != "")
    {
        config += "PRINTER_0_DEVICE=" + ui->txt_printerdevice->text() + "\n";

        config += "PRINTER_0_PORT=";
        if (ui->txt_printerport->text() != "")
            config += ui->txt_printerport->text() + "\n";
        else
            config += "9100\n";

        if(ui->com_printertype->currentIndex() > 0)
        {
            config += "PRINTER_0_TYPE=";
            switch(ui->com_printertype->currentIndex())
            {
            case 1:
                config += "P\n";
                break;
            case 2:
                config += "U\n";
                break;
            case 3:
                config += "S\n";
                break;
            }
        }

        config += "PRINTER_0_WRITE_ONLY=" + bool_to_string(ui->cb_printer_write->isChecked()) + "\n";

        if(ui->com_printertype->currentIndex() == 3)
        {
        config += "PRINTER_0_SPEED=";
        if(ui->txt_printerspeed->text() != "")
            config += ui->txt_printerspeed->text() + "\n";
        else
            config += "9600\n";
        config += "PRINTER_0_PARITY=" + bool_to_string(ui->cb_printparity->isChecked()) + "\n";

        config += "PRINTER_0_DATABITS=";
        if(ui->txt_printerdatabits->text() != "")
            config += ui->txt_printerdatabits->text() + "\n";
        else
            config += "8\n";

        if(ui->txt_printeroptions->text() != "")
            config += "PRINTER_0_OPTIONS=" + ui->txt_printeroptions->text() + "\n";
        }

     }

        if(ui->txt_printerlist->text() != "")
            config += "LDM_PRINTER_LIST=" + ui->txt_printerlist->text() + "\n";

        if(ui->txt_printerdefault->text() != "")
            config += "LDM_PRINTER_DEFAULT=" + ui->txt_printerdefault->text() + "\n";

        config += "SCANNER=" + bool_to_string(ui->cb_scanner->isChecked()) + "\n";

        if(ui->cb_keyboard->isChecked())
        {
            config += "\n[Keyboard]\n";

            config += "CONSOLE_KEYMAP=";
            if(ui->txt_keymap->text() != "")
                config += ui->txt_keymap->text() + "\n";
            else
                config += "en\n";

            if(ui->txt_xkblayout->text() != "")
                config += "XKBLAYOUT=" + ui->txt_xkblayout->text() + "\n";

            if(ui->txt_xkbmodel->text() != "")
                config += "XKBMODEL=" + ui->txt_xkbmodel->text() + "\n";

            if(ui->txt_xkboptions->text() != "")
                config+= "XKBOPTIONS=" + ui->txt_xkboptions->text() + "\n";

            if(ui->txt_xkbrules->text() != "")
                config += "XKBRULES=" + ui->txt_xkbrules->text() + "\n";

            if(ui->txt_xkbvariant->text() != "")
                config += "XKBVARIANT=" + ui->txt_xkbvariant->text() + "\n";
        }

        config += "\n[Sound]\n";

        config += "SOUND=" + bool_to_string(ui->cb_sound->isChecked()) + "\n";

        config += "SOUND_DAEMON=";
        switch(ui->com_sounddaemon->currentIndex())
        {
        case 0:
            config += "pulse\n";
            break;
        case 1:
            config += "esd\n";
            break;
        case 2:
            config += "nasd\n";
            break;
        }

        config += "VOLUME=";
        if(ui->txt_volume->text() != "")
            config += ui->txt_volume->text() + "\n";
        else
            config += "90\n";

        if(ui->txt_headphonevolume->text() != "")
            config += "HEADPHONE_VOLUME=" + ui->txt_headphonevolume->text() + "\n";

        if(ui->txt_pcmvolume->text() != "")
            config += "PCM_VOLUME=" + ui->txt_pcmvolume->text() + "\n";

        if(ui->txt_cdvolume->text() != "")
            config += "CD_VOLUME=" + ui->txt_cdvolume->text() + "\n";

        if(ui->txt_frontvolume->text() != "")
            config += "FRONT_VOLUME=" + ui->txt_frontvolume->text() + "\n";

        if(ui->txt_micvolume->text() != "")
            config += "MIC_VOLUME=" + ui->txt_micvolume->text() + "\n";

        config += "\n[Xorg Parameters]\n";

        config += "USE_XFS=" + bool_to_string(ui->cb_xfs->isChecked()) + "\n";

        if(ui->txt_xfsserver->text() != "")
            config += "XFS_SERVER=" + ui->txt_xfsserver->text() + "\n";

        if(ui->cb_configx->isChecked())
            config += "CONFIGURE_X=True";

        if(ui->txt_xconfig->text() != "")
            config += "X_CONF=" + ui->txt_xconfig->text() + "\n";

        if(ui->sb_xramperc->value() > 100)
            config += "X_RAMPERC=100\n";
        else
            config += "X_RAMPERC=" + QString::number(ui->sb_xramperc->value()) + "\n";

        if(ui->txt_xvirtual->text() != "")
            config += "X_VIRTUAL=" + ui->txt_xvirtual->text() + "\n";

        if(ui->txt_xdmserver->text() != "")
            config += "XDM_SERVER=" + ui->txt_xdmserver->text() + "\n";

        if(ui->cb_xserver->isChecked())
            config += "XSERVER=" + ui->txt_xserver->text() + "\n";

        if(ui->cb_xmouse->isChecked())
        {
            config += "X_MOUSE_DEVICE=" + ui->txt_xmousedev->text() + "\n";
            config += "X_MOUSE_PROTOCOL=" + ui->txt_xmousepro->text() + "\n";
        }

        if(ui->cb_mouseemu->isChecked())
            config += "X_MOUSE_EMULATE3BTN=Y\n";

        config += "X_NUMLOCK=" + bool_to_string(ui->cb_numlock->isChecked()) + "\n";

        config += "X_COLOR_LEVEL=" + ui->com_colordepth->currentText() + "\n";

        if(ui->cb_customxorg->isChecked())
        {
            config += "\n[Custom Xorg Options]\n";

            QLineEdit* xoptions[] = {ui->txt_xoption0, ui->txt_xoption1, ui->txt_xoption2, ui->txt_xoption3, ui->txt_xoption4, ui->txt_xoption5, ui->txt_xoption6, ui->txt_xoption7, ui->txt_xoption8, ui->txt_xoption9, ui->txt_xoption10, ui->txt_xoption11};

            for(int j = 0; j < 12; j++)
            {
                if(xoptions[j]->text() != "")
                {
                    if(j < 9)
                    {
                        config += "X_OPTION_0" + QString::number(j+1);
                        config += "=" + xoptions[j]->text() + "\n";
                    }
                    else if(j >= 9)
                    {
                        config += "X_OPTION_" + QString::number(j+1);
                        config += "=" + xoptions[j]->text() + "\n";
                    }
                }
            }

            if(ui->txt_xmode0->text() != "")
                config += "X_MODE_0=" + ui->txt_xmode0->text() + "\n";

            if(ui->txt_xmode1->text() != "")
                config += "X_MODE_1=" + ui->txt_xmode1->text() + "\n";

            if(ui->txt_xmode2->text() != "")
                config += "X_MODE_2=" + ui->txt_xmode2->text() + "\n";
        }

       config += "X_BLANKING=" + QString::number(ui->sb_xblanking->value()) + "\n";

       config += "\n[Screen Scripts]\n";

       QComboBox* screens[] = {ui->com_screen0, ui->com_screen1, ui->com_screen2, ui->com_screen3, ui->com_screen4, ui->com_screen5, ui->com_screen6, ui->com_screen7, ui->com_screen8, ui->com_screen9, ui->com_screen10, ui->com_screen11};

       for(int k = 0; k < 12; k++)
       {
               if(k < 9)
               {
                   config += "SCREEN_0" + QString::number(k+1);
                   config += "=" + screens[k]->currentText() + "\n";
               }
               else if(k >= 9)
               {
                   config += "SCREEN_" + QString::number(k+1);
                   config += "=" + screens[k]->currentText() + "\n";
               }
       }

       if(ui->txt_telnethost->text() != "")
           config += "TELNET_HOST=" + ui->txt_telnethost->text() + "\n";

       config += "\n[LDM Options]\n";

       if(ui->com_autologin->currentIndex() == 1)
       {
           config += "LDM_AUTOLOGIN=True\n";

           if(ui->txt_autouser->text() != "")
               config += "LDM_USERNAME="******"\n";

           if(ui->txt_autopass->text() != "")
               config += "LDM_PASSWORD="******"\n";
       }
       else
           config += "LDM_AUTOLOGIN=False\n";

        switch(ui->com_debug->currentIndex())
        {
            case 0:
                break;
            case 1:
                config += "LDM_DEBUG=True\n";
                break;
            case 2:
                config += "LDM_DEBUG=False\n";
                break;
        }

        config += "LDM_DIRECTX=" + bool_to_string(ui->cb_directx->isChecked()) + "\n";

        config += "LDM_GUESTLOGIN="******"\n";

        if(ui->sb_logtimeout->value() > 0)
        {
            config += "LDM_LOGIN_TIMEOUT=" + QString::number(ui->sb_logtimeout->value()) + "\n";

            if(ui->txt_autouser->text() != "")
                config += "LDM_USERNAME="******"\n";

            if(ui->txt_autopass->text() != "")
                config += "LDM_PASSWORD="******"\n";
        }

        config += "LDM_SYSLOG=" + bool_to_string(ui->cb_syslog->isChecked()) + "\n";

        if(ui->txt_language->text() != "")
            config += "LDM_LANGUAGE=" + ui->txt_language->text() + "\n";

        config += "NETWORK_COMPRESSION=" + bool_to_string(ui->cb_netcompress->isChecked()) + "\n";

        if(ui->txt_sshoverride->text() != "")
            config += "SSH_OVERRIDE_PORT=" + ui->txt_sshoverride->text() + "\n";

        config += "SSH_FOLLOW_SYMLINKS=" + bool_to_string(ui->cb_symlinks->isChecked()) + "\n";

        if(ui->txt_session->text() != "")
            config += "LDM_SESSION=" + ui->txt_session->text() + "\n";

        if(ui->txt_xsession->text() != "")
            config += "LDM_XSESSION=" + ui->txt_xsession->text() + "\n";
        else
            config += "LDM_XSESSION=Xsession\n";

        config += "\n[Local Applications]\n";

        config += "LOCAL_APPS=" + bool_to_string(ui->cb_localapps->isChecked()) + "\n";

        config += "LOCAL_APPS_MENU=" + bool_to_string(ui->cb_localappsmenu->isChecked()) + "\n";

        if(ui->cb_localappsmenu->isChecked() && ui->txt_localappmenu->text() != "")
            config += "LOCAL_APPS_MENU_ITEMS=" + ui->txt_localappmenu->text() + "\n";

        if(ui->txt_appwhitelist->text() != "")
            config += "LOCAL_APPS_WHITELIST=" + ui->txt_appwhitelist->text() + "\n";

        config += "\n[End Config]\n";

    return config;
}
Ejemplo n.º 13
0
/*
 * Write a configuration to the config file.
 */
static void write_config(struct config_s *config)
{
#ifdef WINDOWS
    remove(CONFIG_BAK_FILENAME);    // For windows rename() bug.
#endif
    if (rename(CONFIG_FILENAME, CONFIG_BAK_FILENAME) != 0 && errno != ENOENT)
    {
        warning("unable to back-up old configuation file \"%s\" to \"%s\"",
            CONFIG_FILENAME, CONFIG_BAK_FILENAME);
    }
    errno = 0;

    FILE *file = fopen(CONFIG_TMP_FILENAME, "w");
    if (file == NULL)
    {
        warning("unable to open configuration file \"%s\" for writing",
            CONFIG_TMP_FILENAME);
        return;
    }
    fprintf(file, "# %s configuration file\n", PROGRAM_NAME_LONG);
    fputs("# AUTOMATICALLY GENERATED, DO NOT EDIT\n", file);
    fputc('\n', file);
    fprintf(file, "%s = \"%s\"\n", VAR_ENABLED,
        bool_to_string(config->enabled));
    fprintf(file, "%s = \"%s\"\n", VAR_HIDE_TCP,
        bool_to_string(config->hide_tcp));
    fprintf(file, "%s = \"%s\"\n", VAR_HIDE_TCP_DATA,
        bool_to_string(config->hide_tcp_data));
    fprintf(file, "%s = \"%s\"\n", VAR_HIDE_TCP_SYN,
        enum_to_string(config->hide_tcp_syn, flag_def, DEF_SIZE(flag_def)));
    fprintf(file, "%s = \"%s\"\n", VAR_HIDE_TCP_ACK,
        enum_to_string(config->hide_tcp_ack, flag_def, DEF_SIZE(flag_def)));
    fprintf(file, "%s = \"%s\"\n", VAR_HIDE_TCP_PSH,
        enum_to_string(config->hide_tcp_psh, flag_def, DEF_SIZE(flag_def)));
    fprintf(file, "%s = \"%s\"\n", VAR_HIDE_TCP_FIN,
        enum_to_string(config->hide_tcp_fin, flag_def, DEF_SIZE(flag_def)));
    fprintf(file, "%s = \"%s\"\n", VAR_HIDE_TCP_RST,
        enum_to_string(config->hide_tcp_rst, flag_def, DEF_SIZE(flag_def)));
    fprintf(file, "%s = \"%s\"\n", VAR_HIDE_UDP,
        bool_to_string(config->hide_udp));
    fprintf(file, "%s = \"%s\"\n", VAR_SPLIT_MODE,
        enum_to_string(config->split, split_def, DEF_SIZE(split_def)));
    fprintf(file, "%s = \"%s\"\n", VAR_LOG_LEVEL,
        enum_to_string((config_enum_t)log_get_level(), log_level_def,
        DEF_SIZE(log_level_def)));
    fprintf(file, "%s = \"%s\"\n", VAR_GHOST_MODE,
        enum_to_string(config->ghost, ghost_def, DEF_SIZE(ghost_def)));
    fprintf(file, "%s = \"%s\"\n", VAR_GHOST_CHECK,
        bool_to_string(config->ghost_check));
    fprintf(file, "%s = \"%s\"\n", VAR_GHOST_SET_TTL,
        bool_to_string(config->ghost_set_ttl));
    fprintf(file, "%s = \"%u\"\n", VAR_GHOST_TTL, config->ghost_ttl);
    fprintf(file, "%s = \"%s\"\n", VAR_FRAG_MODE,
        enum_to_string(config->fragment, frag_def, DEF_SIZE(frag_def)));
    fprintf(file, "%s = \"%u\"\n", VAR_TCP_PORT, config->tcp_port);
    fprintf(file, "%s = \"%s\"\n", VAR_TCP_PROTO,
        protocol_get_name(config->tcp_proto));
    fprintf(file, "%s = \"%u\"\n", VAR_UDP_PORT, config->udp_port);
    fprintf(file, "%s = \"%s\"\n", VAR_UDP_PROTO,
        protocol_get_name(config->udp_proto));
    fprintf(file, "%s = \"%u\"\n", VAR_MTU, config->mtu);
    fprintf(file, "%s = \"%s\"\n", VAR_LAUNCH_UI,
        bool_to_string(config->launch_ui));
    fclose(file);

#ifdef WINDOWS
    remove(CONFIG_FILENAME);
#endif
    if (rename(CONFIG_TMP_FILENAME, CONFIG_FILENAME) != 0)
    {
        warning("unable to move temporary configuration file \"%s\" to \"%s\"",
            CONFIG_TMP_FILENAME, CONFIG_FILENAME);
    }
}
Ejemplo n.º 14
0
/*
 * Call-back from the configuration server; save the configuration state.
 */
void config_callback(struct http_user_vars_s *vars)
{
    bool should_save;
    if (http_user_var_lookup(vars, VAR_POST) == NULL)
    {
        // This is a GET request -- initialise variables:
        char buff[32];
        http_user_var_insert(vars, VAR_ENABLED,
            bool_to_string(config.enabled));
        http_user_var_insert(vars, VAR_HIDE_TCP,
            bool_to_string(config.hide_tcp));
        http_user_var_insert(vars, VAR_HIDE_TCP_DATA,
            bool_to_string(config.hide_tcp_data));
        http_user_var_insert(vars, VAR_HIDE_TCP_SYN,
            enum_to_string(config.hide_tcp_syn, flag_def, DEF_SIZE(flag_def)));
        http_user_var_insert(vars, VAR_HIDE_TCP_ACK,
            enum_to_string(config.hide_tcp_ack, flag_def, DEF_SIZE(flag_def)));
        http_user_var_insert(vars, VAR_HIDE_TCP_PSH,
            enum_to_string(config.hide_tcp_psh, flag_def, DEF_SIZE(flag_def)));
        http_user_var_insert(vars, VAR_HIDE_TCP_FIN,
            enum_to_string(config.hide_tcp_fin, flag_def, DEF_SIZE(flag_def)));
        http_user_var_insert(vars, VAR_HIDE_TCP_RST,
            enum_to_string(config.hide_tcp_rst, flag_def, DEF_SIZE(flag_def)));
        http_user_var_insert(vars, VAR_SPLIT_MODE,
            enum_to_string(config.split, split_def, DEF_SIZE(split_def)));
        http_user_var_insert(vars, VAR_LOG_LEVEL,
            enum_to_string((config_enum_t)log_get_level(), log_level_def,
            DEF_SIZE(log_level_def)));
        http_user_var_insert(vars, VAR_HIDE_UDP,
            bool_to_string(config.hide_udp));
        http_user_var_insert(vars, VAR_GHOST_MODE,
            enum_to_string(config.ghost, ghost_def, DEF_SIZE(ghost_def)));
        http_user_var_insert(vars, VAR_GHOST_CHECK,
            bool_to_string(config.ghost_check));
        http_user_var_insert(vars, VAR_GHOST_SET_TTL,
            bool_to_string(config.ghost_set_ttl));
        snprintf(buff, sizeof(buff)-1, "%u", config.ghost_ttl);
        http_user_var_insert(vars, VAR_GHOST_TTL, buff);
        http_user_var_insert(vars, VAR_FRAG_MODE,
            enum_to_string(config.fragment, frag_def, DEF_SIZE(frag_def)));
        snprintf(buff, sizeof(buff)-1, "%u", config.tcp_port);
        http_user_var_insert(vars, VAR_TCP_PORT, buff);
        http_user_var_insert(vars, VAR_TCP_PROTO,
            protocol_get_name(config.tcp_proto));
        snprintf(buff, sizeof(buff)-1, "%u", config.udp_port);
        http_user_var_insert(vars, VAR_UDP_PORT, buff);
        http_user_var_insert(vars, VAR_UDP_PROTO,
            protocol_get_name(config.udp_proto));
        snprintf(buff, sizeof(buff)-1, "%u", config.mtu);
        http_user_var_insert(vars, VAR_MTU, buff);
        http_user_var_insert(vars, VAR_LAUNCH_UI,
            bool_to_string(config.launch_ui));

    }
    else if (http_get_bool_var(vars, VAR_SAVE, &should_save) && should_save)
    {
        // This is a POST request that wishes to save a new configuration:
        struct config_s config_temp;
        memmove(&config_temp, &config, sizeof(struct config_s));
        load_config(vars, &config_temp);

        // Copy to the global configuration state.
        thread_lock(&config_lock);
        memmove(&config, &config_temp, sizeof(struct config_s));
        thread_unlock(&config_lock);

        // Save the new configuration to disk.
        write_config(&config_temp);

        // Handle add/del of tunnel URLs
        const char *url;
        if (http_get_string_var(vars, VAR_ADD_URL, &url) && url[0] != '\0')
        {
            tunnel_add(url);
        }
        else if (http_get_string_var(vars, VAR_DEL_URL, &url) &&
                    url[0] != '\0')
        {
            tunnel_delete(url);
        }
    }
}
Ejemplo n.º 15
0
int main(int argc, char* argv[]) {
    element_interface_t interface;
    interface.to_string = int_to_string;
    LINKED_LISTp list = LINKED_LIST_construct(&interface);
    char buffer[1000];
    LINKED_LIST_add(list, (void*)0);
    LINKED_LIST_add(list, (void*)1);
    LINKED_LIST_add(list, (void*)2);
    LINKED_LIST_add(list, (void*)3);
    printf("size: %ld\n", LINKED_LIST_size(list));
    printf("%s\n", LINKED_LIST_to_string(list, buffer));
    LINKED_LIST_set(list, 2, (void*) 5);
    printf("%s\n", LINKED_LIST_to_string(list, buffer));
    LINKED_LIST_insert(list, 2, (void*) 8);
    printf("%s\n", LINKED_LIST_to_string(list, buffer));
    printf("list[%d]: %p\n", 0, LINKED_LIST_get(list, 0));
    printf("list[%d]: %p\n", 1, LINKED_LIST_get(list, 1));
    printf("list[%d]: %p\n", 2, LINKED_LIST_get(list, 2));
    printf("list[%d]: %p\n", 3, LINKED_LIST_get(list, 3));
    LINKED_LIST_itrerator_p itr = LINKED_LIST_get_itr(list);
    printf("itr has next %s\n",
           bool_to_string(LINKED_LIST_iterator_has_next(itr)));
    LINKED_LIST_iterator_next(itr);


    printf("list[%d]: %p\n", 0, LINKED_LIST_get(list, 0));

    LINKED_LIST_iterator_remove(itr);

    printf("size: %ld\n", LINKED_LIST_size(list));

    printf("list[%d]: %p\n", 1, LINKED_LIST_iterator_next(itr));
    printf("list[%d]: %p\n", 1, LINKED_LIST_iterator_peek(itr));

    LINKED_LIST_remove(list, 0);
    printf("\n\nlist[%d]: %p\n", 0, LINKED_LIST_get(list, 0));
    printf("list[%d]: %p\n", 1, LINKED_LIST_get(list, 1));


    printf("itr has next %s\n",
           bool_to_string(LINKED_LIST_iterator_has_next(itr)));
    LINKED_LIST_iterator_destruct(itr);
    LINKED_LIST_destruct(list);

    FIFOQp queue = FIFOQ_construct(NULL);
    printf("empty size: %ld\n", FIFOQ_size(queue));
    FIFOQ_enqueue(queue, (void*) 0);
    printf("enqueued 1 size: %ld\n", FIFOQ_size(queue));
    FIFOQ_enqueue(queue, (void*) 1);
    printf("enqueued 2 size: %ld\n", FIFOQ_size(queue));
    FIFOQ_enqueue(queue, (void*) 2);

    printf("peeked   0: %p, size: %ld\n", FIFOQ_peek(queue),
           FIFOQ_size(queue));
    printf("dequeued 0: %p, size: %ld\n", FIFOQ_dequeue(queue),
           FIFOQ_size(queue));

    printf("peeked   1: %p, size: %ld\n", FIFOQ_peek(queue),
           FIFOQ_size(queue));
    printf("dequeued 1: %p, size: %ld\n", FIFOQ_dequeue(queue),
           FIFOQ_size(queue));

    printf("peeked   2: %p, size: %ld\n", FIFOQ_peek(queue),
           FIFOQ_size(queue));
    printf("dequeued 2: %p, size: %ld\n", FIFOQ_dequeue(queue),
           FIFOQ_size(queue));
    printf("size: %ld\n", FIFOQ_size(queue));
    FIFOQ_destruct(queue);

    printf("PRIORITY QUEUE\n");
    PRIORITYQp pqueue = PRIORITYQ_construct(NULL);
    printf("empty size: %ld\n", PRIORITYQ_size(pqueue));
    PRIORITYQ_enqueue(pqueue, (void*) 5, 3);
    printf("enqueued (5, 3) size: %ld\n", PRIORITYQ_size(pqueue));
    PRIORITYQ_enqueue(pqueue, (void*) 6, 1);
    printf("enqueued (6, 1) size: %ld\n", PRIORITYQ_size(pqueue));
    PRIORITYQ_enqueue(pqueue, (void*) 7, 2);
    printf("enqueued (7, 2) size: %ld\n", PRIORITYQ_size(pqueue));
    int i;
    for (i = 0; i < 3; i++) {
        printf("               peeked %d: %p,     size: %ld\n",
               i, PRIORITYQ_peek(pqueue), PRIORITYQ_size(pqueue));
        printf("new size %2ld, dequeued %d: %p, old size: %ld\n",
               PRIORITYQ_size(pqueue), i, PRIORITYQ_dequeue(pqueue),
               PRIORITYQ_size(pqueue));
    }
    printf("size: %ld\n", PRIORITYQ_size(pqueue));

    PRIORITYQ_destruct(pqueue);


    return EXIT_SUCCESS;
}
Ejemplo n.º 16
0
void bingsprec_sync(struct msauth_token* token,
			struct bingsprec_params* params,
			char* file_name,
			struct bingsprec_results* results) {
	null_bingsprec_results(results);

	uuid_t uuid;
	char uuid_str[36 + 1];
	uuid_generate(uuid);
	uuid_unparse_upper(uuid, uuid_str);
	uuid_str[36] = '\0';

	char* request = (char*) 
		malloc(BINGSPREC_REQUEST_MAX_LEN * sizeof(char));		
	if (request == NULL) {
		exit(-1);
	}

	char instance_id[36 + 1];	
	FILE* fp_read = fopen(".saved_instance_id", "r");
	if (fp_read != NULL) {
		if (fread(instance_id, sizeof(char), 36, fp_read)) {
			instance_id[36] = '\0';
			fclose(fp_read);
		} else {
			fprintf(stderr, "Error reading from file.\n");
			fclose(fp_read);
			exit(-1);
		}
	} else {
		/* This is either the first time making a call, the previous
		 * instance id file was deleted, or we had an error opening the
		 * file. We'll try creating a new instance id to handle the
		 * first two cases.
		 */
			
		uuid_t instance_uuid;
		uuid_generate(instance_uuid);
		uuid_unparse_upper(instance_uuid, instance_id);	
		
		FILE* fp_write = fopen(".saved_instance_id", "w");
		if (fp_write != NULL) {
			fputs(instance_id, fp_write);	
		}
		fclose(fp_write);
	}

	snprintf(request,
		BINGSPREC_REQUEST_MAX_LEN * sizeof(char),
		"%s/recognize"
		"?version=3.0&format=json"
		"&scenarios=%s"
		"&appid=%s"
		"&locale=%s"
		"&device.os=%s"
		"&maxnbest=%d"
		"&result.profanity=%d"
		"&instanceid=%s"
		"&requestid=%s",
		BINGSPREC_BASE_URL,
		scenario_to_string(params->scenario),
	        BINGSPREC_APP_ID,
		locale_to_string(params->locale),
		params->deviceos,
		params->maxnbest,
		params->profanity_markup,
		instance_id,	
		uuid_str);	

	CURL* curl = curl_easy_init();
	if (!curl) {
		exit(-1);
	}

	curl_easy_setopt(curl, CURLOPT_VERBOSE, BINGSPREC_VERBOSE);
	curl_easy_setopt(curl, CURLOPT_URL, request);
	curl_easy_setopt(curl, CURLOPT_POST, 1);
	curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);

	FILE* file = fopen(file_name, "r");
	if (file == NULL) {
		fprintf(stderr, "Error opening wav file.\n");
		exit(-1);
	}

	fseek(file, 0, SEEK_END);
	unsigned long fileSize = (unsigned long)ftell(file);
	rewind(file);
	
	char* audio_data = (char*) malloc(sizeof(char) * fileSize);
	if (audio_data == NULL) {
		fprintf(stderr, "No membory to allocate audio buffer.\n");
		exit(-2);
	}
	
	struct bingsprec_wavfile wavFile;
	size_t freadres = fread(audio_data, 1, fileSize, file);
	if (ferror(file) || freadres != fileSize) {
		fprintf(stderr, "Eror reading wav file!\n");
		fclose(file);
		exit(-1);
	}
	
	fclose(file);

	wavFile.readPtr = audio_data;
	wavFile.sizeLeft = fileSize;

	curl_easy_setopt(curl, CURLOPT_READFUNCTION, bingsprec_read_wavfile);
	curl_easy_setopt(curl, CURLOPT_READDATA, &wavFile);


	char* content_type = (char*) 
		malloc(BINGSPREC_REQUEST_MAX_LEN * sizeof(char));
	snprintf(content_type,
		BINGSPREC_REQUEST_MAX_LEN * sizeof(char),
		"Content-Type: audio/wav; codec=\"audio/pcm\"; "
		"samplerate=%d; "
		"sourcerate=%d; "
		"trustsourcerate=%s",
		params->samplerate,
		params->sourcerate,
		bool_to_string(params->trustsourcerate)); 

	struct curl_slist* headers = NULL;
	headers = curl_slist_append(headers, content_type);
	headers = curl_slist_append(headers, 
		"Accept: application/json;text/xml");
	headers = curl_slist_append(headers, 
		"Host: speech.platform.bing.com");	
	headers = curl_slist_append(headers, 
		"Connection: Keep-Alive");
	headers = curl_slist_append(headers, 
		"Transfer-Encoding: chunked");

	free(content_type);
	
	size_t token_length = strlen(token->access_token);
	// strlen("Authorization: Bearer ") = 22
	char auth_header[22 + token_length + 1];
	auth_header[0] = '\0';
	strcat(auth_header, "Authorization: Bearer ");
	strcat(auth_header, token->access_token);
	headers = curl_slist_append(headers, auth_header);

	curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
	
	struct bingsprec_response* resp = bingsprec_new_response();	
	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, 
		bingsprec_write_response);
	curl_easy_setopt(curl, CURLOPT_WRITEDATA, resp);
 
	CURLcode res = curl_easy_perform(curl);
	long http_code = 0;
	curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
	if (res == CURLE_OK && http_code == 200) {
		parse_json_to_results(resp->str, results);
	} else {
		fprintf(stderr, "CURL Error:\n%s\n", curl_easy_strerror(res));
	}	

	bingsprec_free_response(resp);
	free(request); 
	free(audio_data);
	curl_slist_free_all(headers);
	curl_easy_cleanup(curl);
}