Exemplo n.º 1
0
Arquivo: CGUI.cpp Projeto: 2asoft/0ad
/**
 * @callgraph
 */
void CGUI::LoadXmlFile(const VfsPath& Filename, boost::unordered_set<VfsPath>& Paths)
{
	Paths.insert(Filename);

	CXeromyces XeroFile;
	if (XeroFile.Load(g_VFS, Filename, "gui") != PSRETURN_OK)
		return;

	XMBElement node = XeroFile.GetRoot();

	CStr root_name(XeroFile.GetElementString(node.GetNodeName()));
	try
	{
		if (root_name == "objects")
		{
			Xeromyces_ReadRootObjects(node, &XeroFile, Paths);

			// Re-cache all values so these gets cached too.
			//UpdateResolution();
		}
		else if (root_name == "sprites")
			Xeromyces_ReadRootSprites(node, &XeroFile);
		else if (root_name == "styles")
			Xeromyces_ReadRootStyles(node, &XeroFile);
		else if (root_name == "setup")
			Xeromyces_ReadRootSetup(node, &XeroFile);
		else
			debug_warn(L"CGUI::LoadXmlFile error");
	}
	catch (PSERROR_GUI& e)
	{
		LOGERROR("Errors loading GUI file %s (%u)", Filename.string8(), e.getCode());
		return;
	}
}
Exemplo n.º 2
0
/**
 * @callgraph
 */
void CGUI::LoadXmlFile(const VfsPath& Filename, boost::unordered_set<VfsPath>& Paths)
{
	Paths.insert(Filename);

	CXeromyces XeroFile;
	if (XeroFile.Load(g_VFS, Filename) != PSRETURN_OK)
		// Fail silently
		return;

	XMBElement node = XeroFile.GetRoot();

	// Check root element's (node) name so we know what kind of
	//  data we'll be expecting
	CStr root_name (XeroFile.GetElementString(node.GetNodeName()));

	try
	{

		if (root_name == "objects")
		{
			Xeromyces_ReadRootObjects(node, &XeroFile, Paths);

			// Re-cache all values so these gets cached too.
			//UpdateResolution();
		}
		else
		if (root_name == "sprites")
		{
			Xeromyces_ReadRootSprites(node, &XeroFile);
		}
		else
		if (root_name == "styles")
		{
			Xeromyces_ReadRootStyles(node, &XeroFile);
		}
		else
		if (root_name == "setup")
		{
			Xeromyces_ReadRootSetup(node, &XeroFile);
		}
		else
		{
			debug_warn(L"CGUI::LoadXmlFile error");
			// TODO Gee: Output in log
		}
	}
	catch (PSERROR_GUI& e)
	{
		LOGERROR(L"Errors loading GUI file %ls (%u)", Filename.string().c_str(), e.getCode());
		return;
	}
}
Exemplo n.º 3
0
/*
 * Go to the /devices directory and recursively find all
 * the device special files (with the handy library function
 * nftw).  nftw() will call devices_entry() which will put
 * the entry in the hash table.  After we find all the
 * entries allocate a table and put pointers in it so
 * we can sort the entries.
 */
static void
get_devices(void)
{
	char *dir;
	int i;
	struct devices_ent *dep, **pht, **pdep;

	dir = root_name("/devices");
	if (chdir(dir) == -1) {
		xperror(dir);
		exit(1);
	}

	/*
	 * Errors related to access permissions are handled
	 * by devices_entry() and devices_entry doesn't return
	 * non-zero so the only thing left is some other type
	 * of error.
	 */
	if (nftw(".", devices_entry, depth, FTW_PHYS) == -1)
		xperror("nftw()");

	devices_list = xmalloc(sizeof (struct devices_ent *) *
	    num_devices_ents);

	pdep = devices_list;
	pht = de_hashtab;
	for (i = 0; i < HASHSIZE; i++) {
		dep = *pht;
		while (dep != NULL) {
			*pdep++ = dep;
			dep = dep->next;
		}
		pht++;
	}

	/*
	 * After all the /devices entries are put in the hash
	 * table we sort the entries.  We do this for two
	 * reasons: the rule functions may count on the order of
	 * devices it is called with (like the cdrom stuff in
	 * rule_sd) and if the rules create overlapping names the
	 * links will be made in an order based on sorted entries
	 * rather than be dependent on the order the entries
	 * happen to be in in a directory.
	 */
	qsort((void *) devices_list, num_devices_ents,
	    sizeof (struct devices_ent *), dcomp);
}
Exemplo n.º 4
0
	static Uri canonical(const Uri& uri, const Uri& base)
	{
		if (uri.absolute())
			return uri;

		auto temp = base;
		temp.fragment(uri.fragment());
		temp.query(uri.query());

		auto path = filesystem::canonical(uri.path(), base.path());
		if (path.has_root_name())
			path = path.string().substr(path.root_name().string().length());
		temp.path(path.string());

		return temp;
	}
Exemplo n.º 5
0
void
FE_populate (void)
{
  AST_Root *r = 0;

  // Check that the BE init created a generator object
  if (idl_global->gen () == 0)
    {
      ACE_ERROR ((
          LM_ERROR,
          ACE_TEXT ("IDL: idl_global->gen() not initialized, exiting\n")
        ));

      throw Bailout ();
    }

  // Create a global root for the AST. Note that the AST root has no name.
  Identifier root_id ("");
  UTL_ScopedName root_name (&root_id, 0);
  r = idl_global->gen ()->create_root (&root_name);
  idl_global->set_root (r);

  if (r == 0)
    {
      ACE_ERROR ((
          LM_ERROR,
          ACE_TEXT ("IDL: FE init failed to create AST root, exiting\n")
        ));

      throw Bailout ();
    }

  // Push it on the stack
  idl_global->scopes ().push (idl_global->root ());

  // Populate it with nodes for predefined types.
  fe_populate_global_scope ();

  // Set flag to indicate we are processing the main file now.
  idl_global->set_in_main_file (true);

  // Populate the IDL keyword container, for checking local identifiers.
  fe_populate_idl_keywords ();
}
Exemplo n.º 6
0
/*
 * Spin through our sorted list of /devices entries and call
 * the rule function for each.
 */
static void
call_device_rules(void)
{
	struct devices_ent **pdep;
	struct devices_ent *dep;
	int i;
	char *root_etc;

	root_etc = root_name("/etc");
	link_handle = di_devlink_open(root_etc, 0);

	pdep = devices_list;
	for (i = 0; i < num_devices_ents; i++) {
		dep = *pdep++;
		dep->drp->rule_func(dep);
	}

	di_devlink_close(&link_handle, 0);
}
Exemplo n.º 7
0
/*
 * Go to the /dev directory and recursively find all the
 * symlinks.  nftw() will call dev_entry() which will put
 * the entry in the hash table.
 */
static void
get_dev_links(void)
{
	char *devdir;

	devdir = root_name("/dev");
	if (chdir(devdir) == -1) {
		xperror(devdir);
		exit(1);
	}

	/*
	 * Errors related to access permissions are handled
	 * by dev_entry() and dev_entry doesn't return non-zero
	 * so the only thing left is some other type of error.
	 */
	if (nftw(".", dev_entry, depth, FTW_PHYS) == -1)
		xperror("nftw()");
}
Exemplo n.º 8
0
static void
rule_zs(struct devices_ent *dep)
{
	static int beenhere = 0;
	int len;
	DIR *dirp;
	struct dirent *direntp;
	char *termdir;
	char *entry;
	char *devicename = dep->devicename;

	len = strlen(devicename);
	if (strncmp(&devicename[len - 3], ",cu", 3) == 0)
		return;

	if (beenhere)
		return;
	else
		beenhere = 1;

	termdir = root_name("/dev/term");

	dirp = opendir(termdir);
	if (dirp == NULL) {
		xperror(termdir);
		return;
	}
	while ((direntp = readdir(dirp)) != NULL) {
		entry = direntp->d_name;
		if (entry[0] == '.')
			continue;
		(void) sprintf(namebuf, "tty%s", direntp->d_name);
		(void) sprintf(namebuf2, "term/%s", direntp->d_name);
		addlink_nolookup(namebuf, namebuf2, 0);
	}

	(void) closedir(dirp);
}
Exemplo n.º 9
0
void
lego_diagram_t::prepare()
{
    _log.debug("lego_diagram_t::prepare\n");

    root_ = new node_t();
    root_->name_ = root_name();
    root_->depth_ = 0;
    maxdepth_ = 0;

    /* First pass: construct a tree of nodes */
    for (list_iterator_t<cov_file_t> iter = cov_file_t::first() ; *iter ; ++iter)
    {
	cov_file_t *f = *iter;

	_log.debug("    adding file \"%s\"\n", f->minimal_name());

	cov_scope_t *sc = new cov_file_scope_t(f);
	const cov_stats_t *st = sc->get_stats();
	if (st->blocks_total() == 0)
	{
	    delete sc;
	    continue;
	}

	node_t *parent = root_;
	node_t *node = 0;
	tok_t tok(f->minimal_name(), "/");
	const char *comp;
	while ((comp = tok.next()) != 0)
	{
	    node = 0;

	    for (list_iterator_t<node_t> niter = parent->children_.first() ; *niter ; ++niter)
	    {
		if (!strcmp((*niter)->name_, comp))
		{
		    node = *niter;
		    break;
		}
	    }
	    if (node == 0)
	    {
		node = new node_t();
		node->name_ = comp;
		parent->children_.append(node);
		node->depth_ = parent->depth_ + 1;
		if (node->depth_ > maxdepth_)
		    maxdepth_ = node->depth_;
	    }
	    parent->stats_.accumulate(st);
	    parent = node;
	}

	assert(node != 0);
	assert(node->file_ == 0);
	node->file_ = f;
	node->stats_ = *st;

	delete sc;
    }

    /* Second pass: assign geometry to the nodes */
    assign_geometry(root_, 0.0, 0.0, (WIDTH / (double)(maxdepth_+1)), HEIGHT);

    /* Debug: dump tree */
    if (_log.is_enabled(logging::DEBUG2))
	dump_node(root_);
}
Exemplo n.º 10
0
 path  path::root_path() const
 { 
   path temp(root_name());
   if (!root_directory().empty()) temp.m_pathname += root_directory().c_str();
   return temp;
 } 
Exemplo n.º 11
0
 bool has_root_name() const       { return !root_name().empty(); }