Exemplo n.º 1
0
struct info_tuple *new_info_tuple(char *key, char *value)
{
	struct info_tuple *info;
	info = calloc(1, sizeof(struct info_tuple));

	if (key == NULL)
		key = "NULL";

	if (value == NULL)
		value = "NULL";

	info->key = get_clone(key);
	info->value = get_clone(value);

	info->next = NULL;

	return info;
}
Exemplo n.º 2
0
TEST(make_structuring_element_test,testSet1)
{
	IplImage *se1 = get_bwimg(11,11);
	int searr1[121] = { 
					0,0,0,0,0,0,0,0,0,0,0,
					0,0,0,0,0,0,0,0,0,0,0,
					0,0,0,0,0,0,0,0,0,0,0,
					0,0,0,0,0,1,0,0,0,0,0,
					0,0,0,0,0,1,0,0,0,0,0,
					0,0,0,0,0,1,0,0,0,0,0,
					0,0,0,0,0,1,0,0,0,0,0,
					0,0,0,0,0,1,0,0,0,0,0,
					0,0,0,0,0,1,0,0,0,0,0,
					0,0,0,0,0,1,0,0,0,0,0,
					0,0,0,0,0,1,0,0,0,0,0};
	fill_img(se1,searr1);
	IplImage *act_se1 = get_clone(se1);
	make_structuring_element_b1(act_se1,1,3,0);
	ASSERT_EQ_IMAGE(se1,act_se1);

	IplImage *se2 = get_bwimg(11,11);
	int searr2[121] = { 
					1,1,1,1,1,1,1,1,1,1,1,
					1,0,0,0,0,0,0,0,0,0,1,
					1,0,0,0,0,0,0,0,0,0,1,
					1,0,0,0,0,0,0,0,0,0,1,
					1,0,0,0,0,0,0,0,0,0,1,
					1,0,0,0,0,0,0,0,0,0,1,
					1,0,0,0,0,0,0,0,0,0,1,
					1,0,0,0,0,0,0,0,0,0,1,
					1,0,0,0,0,0,0,0,0,0,1,
					0,0,0,0,0,0,0,0,0,0,0,
					0,0,0,0,0,0,0,0,0,0,0};
	fill_img(se2,searr2);
	IplImage *act_se2 = get_clone(se2);
	make_structuring_element_b2(act_se2,1,1,2);
	//print_img(act_se1);
    //print_img(act_se2);
	ASSERT_EQ_IMAGE(se2,act_se2);
	cvReleaseImage(&se1);
	cvReleaseImage(&se2);
	cvReleaseImage(&act_se1);
	cvReleaseImage(&act_se2);
}
Exemplo n.º 3
0
int device2xml (struct device *device, hash_table *config)
{
	if (device == NULL)
		return ERROR;

	char *xml_filename = get_hash_info (config, "xml_output");
	
	if (is_blank(xml_filename)) {
		char *xml_tmp = "/tmp/ldc.xml";
		delete(&xml_filename);
		xml_filename = get_clone(xml_tmp);
	}
	
	char *dev_name = device->name;
	
	if ( !is_blank(dev_name) && !equals(dev_name, "computer") ) {
		char *clean_str = get_clean_string(xml_filename,".xml");
		int len = strlen(clean_str) + strlen(dev_name) + 6;
		char *xml_tmp = calloc(len, sizeof(char));
		//sprintf(xml_tmp, "%s_%s.xml", clean_str, dev_name);
		append_string(&xml_tmp, clean_str);
		append_string(&xml_tmp, "_");
		append_string(&xml_tmp, dev_name);
		append_string(&xml_tmp, ".xml");
		delete(&xml_filename);
		xml_filename = get_clone(xml_tmp);
		delete(&xml_tmp);
		delete(&clean_str);
	}

	char *XML = append_xml_meta (device);
	
	write_output (XML, xml_filename, "w");

	delete (&XML);
	delete (&xml_filename);

	return SUCCESS;
}
Exemplo n.º 4
0
char *get_info_value(struct device *dev, char *key)
{
	if (dev == NULL || key == NULL)
		return NULL;

	struct info_tuple *iter = dev->info;

	while (iter != NULL) {
		if (iter->key != NULL && strcmp(key, iter->key) == 0) {
			char *tmp = get_clone(iter->value);
			return tmp;
		}

		iter = iter->next;
	}

	return NULL;
}
Exemplo n.º 5
0
struct device *new_device(char *name)
{
	struct device *dev;
	dev = calloc(1, sizeof(struct device));

	if (dev == NULL)
		return NULL;

	if (name == NULL)
		name = "UNDEFINED";

	dev->name = get_clone(name);

	dev->info = NULL;
	dev->next = NULL;
	dev->child = NULL;

	return dev;
}