Ejemplo n.º 1
0
/* return a vnode number matching targethost */
int findtargethost(char *allnodes, char *targethost)
  {
  int i;
  char *ptr;
  int vnode = 0;

  if ((ptr = strchr(targethost, '/')) != NULL)
    {
    *ptr = '\0';
    ptr++;
    vnode = atoi(ptr);
    }

  for (i = 0; i < numnodes; i++)
    {
    if (!strcmp(allnodes + (i*PBS_MAXNODENAME), targethost))
      {
      if (vnode == 0)
        return(i);

      vnode--;
      }
    else
      {
      /* Sometimes the allnodes will return the FQDN of the host
       and the PBS_NODEFILE will have the short name of the host.
       See if the shortname mataches */
      std::string targetname(targethost);
      std::string the_host(allnodes + (i*PBS_MAXNODENAME));
      std::size_t dot = the_host.find_first_of(".");
      if(dot != std::string::npos)
        {
        the_host[dot] = '\0';
        std::string shortname(the_host.c_str());
        if (shortname.compare(targetname) == 0)
          {
          if (vnode == 0)
            return(i);
          vnode--;
          }
        }
      } 
    }

  if (i == numnodes)
    {
    fprintf(stderr, "%s: %s not found\n", id, targethost);
    tm_finalize();
    exit(1);
    }

  return(-1);
  }
Ejemplo n.º 2
0
	bool BeforeMode(User* user, User*, Channel* chan, std::string& param, bool adding, ModeType modetype)
	{
		if ((!adding) || (modetype != MODETYPE_CHANNEL))
			return true;

		if ((!IS_LOCAL(user)) || !IsExtBanRedirect(param))
			return true;

		std::string::size_type p = param.find(':', 2);
		if (p == std::string::npos)
		{
			user->WriteNumeric(690, "%s :Extban redirect \"%s\" is invalid. Format: %c:<chan>:<mask>", user->nick.c_str(), param.c_str(), extbanchar);
			return false;
		}

		std::string targetname(param, 2, p - 2);
		if (!ServerInstance->IsChannel(targetname.c_str(), ServerInstance->Config->Limits.ChanMax))
		{
			user->WriteNumeric(ERR_NOSUCHCHANNEL, "%s %s :Invalid channel name in redirection (%s)", user->nick.c_str(), chan->name.c_str(), targetname.c_str());
			return false;
		}

		Channel* const targetchan = ServerInstance->FindChan(targetname);
		if (!targetchan)
		{
			user->WriteNumeric(690, "%s :Target channel %s must exist to be set as a redirect.", user->nick.c_str(), targetname.c_str());
			return false;
		}

		if (targetchan == chan)
		{
			user->WriteNumeric(690, "%s %s :You cannot set a ban redirection to the channel the ban is on", user->nick.c_str(), targetname.c_str());
			return false;
		}

		if (adding && targetchan->GetPrefixValue(user) < OP_VALUE)
		{
			user->WriteNumeric(690, "%s :You must be opped on %s to set it as a redirect.", user->nick.c_str(), targetname.c_str());
			return false;
		}

		return true;
	}
Ejemplo n.º 3
0
Project *
Project::CreateProject(const char *projname, const char *target, int32 type, const char *path,
						bool create_folder)
{
	BString name(projname), targetname(target);
	if (name.CountChars() < 1)
		name = "Untitled";
	
	if (targetname.CountChars() < 1)
		name = "BeApp";
	
	Project *newproj = new Project(name.String(),targetname.String());
	
	newproj->SetTargetType(type);
	
	newproj->AddLocalInclude(".");
	newproj->AddSystemInclude("/boot/develop/headers/be");
	newproj->AddSystemInclude("/boot/develop/headers/cpp");
	newproj->AddSystemInclude("/boot/develop/headers/posix");
	newproj->AddSystemInclude("/boot/home/config/include");
	
	newproj->AddLibrary("/boot/develop/lib/x86/libroot.so");
	
	newproj->AddGroup("Source Files");
	
	switch (type)
	{
		case PROJECT_GUI:
		{
			newproj->AddLibrary("/boot/develop/lib/x86/libbe.so");
			
			// Having to manually add this one is terribly annoying. :/
			if (DetectPlatform() == PLATFORM_HAIKU_GCC4)
				newproj->AddLibrary("/boot/develop/lib/x86/libsupc++.so");
			break;
		}
		case PROJECT_DRIVER:
		{
			newproj->AddLibrary("/boot/develop/lib/x86/_KERNEL_");
			break;
		}
		case PROJECT_CONSOLE:
		case PROJECT_SHARED_LIB:
		case PROJECT_STATIC_LIB:
		default:
			break;
	}
	
	BPath projpath(path);
	if (create_folder)
	{
		projpath.Append(name.String());
		if (!BEntry(projpath.Path()).Exists());
			create_directory(projpath.Path(),0777);
	}
	
	BString filename(newproj->GetName());
	filename << ".pld";
	projpath.Append(filename.String());
	newproj->Save(projpath.Path());
	
	return newproj;
}