Ejemplo n.º 1
0
static void linphone_lpconfig_from_buffer(){
	const char* buffer = "[buffer]\ntest=ok";
	const char* buffer_linebreaks = "[buffer_linebreaks]\n\n\n\r\n\n\r\ntest=ok";
	LpConfig* conf;

	conf = lp_config_new_from_buffer(buffer);
	BC_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"buffer","test",""),"ok");
	lp_config_destroy(conf);

	conf = lp_config_new_from_buffer(buffer_linebreaks);
	BC_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"buffer_linebreaks","test",""),"ok");
	lp_config_destroy(conf);
}
Ejemplo n.º 2
0
static void linphone_lpconfig_from_buffer_zerolen_value(){
	/* parameters that have no value should return NULL, not "". */
	const char* zerolen = "[test]\nzero_len=\nnon_zero_len=test";
	LpConfig* conf;

	conf = lp_config_new_from_buffer(zerolen);

	BC_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"test","zero_len","LOL"),"LOL");
	BC_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"test","non_zero_len",""),"test");

	lp_config_set_string(conf, "test", "non_zero_len", ""); /* should remove "non_zero_len" */
	BC_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"test","non_zero_len","LOL"), "LOL");

	lp_config_destroy(conf);
}
Ejemplo n.º 3
0
int main(int argc, char *argv[]) {
	if(argc != 4) {
		show_usage(argc, argv);
		return -1;
	}
	
	lpc2xml_context *ctx = lpc2xml_context_new(cb_function, NULL);
	LpConfig *lpc = lp_config_new(argv[2]);
	lpc2xml_set_lpc(ctx, lpc);
	if(strcmp("convert", argv[1]) == 0) {
		lpc2xml_convert_file(ctx, argv[3]);
	} else {
		show_usage(argc, argv);
	}
	lp_config_destroy(lpc);
	lpc2xml_context_destroy(ctx);
	return 0;
}
Ejemplo n.º 4
0
static void linphone_lpconfig_from_file_zerolen_value(){
	/* parameters that have no value should return NULL, not "". */
	const char* zero_rc_file = "zero_length_params_rc";
	char* rc_path = ms_strdup_printf("%s/rcfiles/%s", bc_tester_read_dir_prefix, zero_rc_file);
	LpConfig* conf;

	/* not using lp_config_new() because it expects a readable file, and iOS (for instance)
	   stores the app bundle in read-only */
	conf = lp_config_new_with_factory(NULL, rc_path);

	BC_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"test","zero_len","LOL"),"LOL");

	// non_zero_len=test -> should return test
	BC_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"test","non_zero_len",""),"test");

	lp_config_set_string(conf, "test", "non_zero_len", ""); /* should remove "non_zero_len" */
	BC_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"test","non_zero_len","LOL"), "LOL");

	ms_free(rc_path);
	lp_config_destroy(conf);
}
Ejemplo n.º 5
0
int main(int argc, char *argv[]) {
	lpc2xml_context *ctx;
	LpConfig *lpc;
	if(argc > 4 || argc < 3) {
		show_usage(argc, argv);
		return -1;
	}

	lpc = lp_config_new(argv[2]);
	if(strcmp("convert", argv[1]) == 0 && argc == 4) {
		ctx = lpc2xml_context_new(cb_function, NULL);
		lpc2xml_convert_file(ctx, argv[3]);
		lpc2xml_set_lpc(ctx, lpc);
		lpc2xml_context_destroy(ctx);
	} else if (strcmp("dump", argv[1]) == 0 && argc == 3) {
		char *dump = lp_config_dump_as_xml(lpc);
		fprintf(stdout, "%s", dump);
	} else {
		show_usage(argc, argv);
	}
	lp_config_destroy(lpc);
	return 0;
}