Esempio n. 1
0
void
MidiView::_RetrieveSoftSynthList()
{
	char **paths = NULL;
	size_t pathCount = 0;
	status_t status = find_paths(B_FIND_PATH_DATA_DIRECTORY, "synth",
			&paths, &pathCount);
	if (status != B_OK)
		return;

	fListView->MakeEmpty();

	for (size_t i = 0; i < pathCount; i++) {
		BDirectory directory(paths[i]);
		BEntry entry;
		if (directory.InitCheck() != B_OK)
			continue;
		while (directory.GetNextEntry(&entry) == B_OK) {
			fListView->AddItem(new BStringItem(entry.Name()));
		}
	}
}
Esempio n. 2
0
File: svg2.c Progetto: anj1/cdac
/* Has two modes. If passed NULL, doesn't copy anything and just returns
 * the number of paths. Otherwise, parses and copies path data */
int find_paths(xmlNode *a, char **id, point2d32f **p, int **n, int nmax, int c)
{
	xmlNode *cur_node = NULL;
	xmlAttr *cur_attr = NULL;
	xmlAttr *attr;
	int got_data,got_id;
	size_t len;
	int err;
	
	for(cur_node = a; cur_node; cur_node = cur_node->next){

		/* depth-first search */
		/* paths that recursion finds are accumulated (hence c) */
		c = find_paths(cur_node->children, id, p, n, nmax, c);
		if(c < 0) return c;
		
		/* Make sure is XML element */
		if(cur_node->type != XML_ELEMENT_NODE) continue;

		/* make sure we're on a 'path' */
		if(!xmlStrEqual((xmlChar *)"path",cur_node->name)) continue;
		
		/* we got the path, now process it */
		attr = cur_node->properties;
		got_data=0; got_id=0;
		for(cur_attr=attr;cur_attr;cur_attr=cur_attr->next){
			/* Make sure is XML attribute */
			if(cur_attr->type != XML_ATTRIBUTE_NODE) continue;
			
			if(xmlStrEqual((xmlChar *)"d",cur_attr->name)){
				got_data=1;
				/* have we been given memory? */
				if(p && n){
					err = parse_outline2(cur_attr, p[c], n[c], nmax);
					if(err) return -err;
				}
			}
			
			/* store 'id' field */
			if(xmlStrEqual((xmlChar *)"id",cur_attr->name)){
				got_id=1;
				if(id){
					/* we can't use xmlStrlen because we want the number
					 * of bytes, not characters */
					len = strlen((const char *)cur_attr->children->content);
					id[c] = (char *)malloc(len+1);
					if(!id[c]) return c;	/* can't return error because that would cause memory leaks */
					memcpy(id[c], cur_attr->children->content, len);
					id[c][len]=0;
				}
			}
		}

		if(!(got_data && got_id)){
#ifdef DEBUG_PRINT
			fprintf(stderr,"Error: find_paths: missing path id or data)\n");
#endif
			return -1;
		} else c++;
	}
	return c;
}
Esempio n. 3
0
void find_paths(btree_node<int> *p_node, const int expected_path_len)
{
	vector<btree_node<int> *> path;
	int path_len = 0;
	find_paths(p_node, expected_path_len, path, path_len);
}