Example #1
0
	bool yl_messenger::recv_ln_start_with(const String start, String &data)
	{
		String start_temp(start);
		start_temp.toLowerCase();
		for (;;)
		{
			String temp;
			if (!recv_ln(temp))
			{
#ifdef YL_SERIAL_DEBUG
				Serial.println("read error : 245");
#endif
				return false;
			}
			temp.toLowerCase();
			if (temp == start_temp)
			{
				return recv_ln(data);
			}
			if (temp.substring(0, start_temp.length()) == start_temp)
			{
				data = temp.substring(start_temp.length());
				return true;
			}
		}
		return false;
	}
Example #2
0
	bool String::toBoolean(){
		String low = *this;
		low.toLowerCase();
		if(low == "true")
			return true;
		else return false;
	}
int StructurePermissionList::togglePermission(const String& listName, const String& playerName, bool caseSensitive) {
	Locker locker(&lock);

	if(playerName == ownerName)
		return CANTCHANGEOWNER;

	if (!permissionLists.contains(listName))
		return LISTNOTFOUND;

	SortedVector<String>* list = &permissionLists.get(listName);

	String name = "";

	if (caseSensitive)
		name = playerName;
	else
		name = playerName.toLowerCase();

	//If they exist, remove them.
	if (list->contains(name)) {
		list->drop(name);
		return REVOKED;
	}

	list->put(name);
	return GRANTED;
}
Example #4
0
int main() {

	String foo = newString("This is FOO!");
	foo = foo.insertCharAt(&foo,'a',foo.length(&foo) - 1);
	foo.printString(&foo);


	foo = foo.substring(&foo,8,10);
	foo.printString(&foo);

	String bar = newString(" BAR");
	foo = foo.concat(&foo,&bar);
	foo.printString(&foo);

	StringArr foobar = split(&foo, " ");
	printf("%s\n",foobar[0]);
	printf("%s\n",foobar[1]);

	foo = foo.toLowerCase(&foo);
	bar = bar.toLowerCase(&bar);
	bar = bar.removeSpaces(&bar);
	foo.printString(&foo);
	bar.printString(&bar);

	if(foo.equals(&foo,&bar))
		printf("Same!\n");
	else
		printf("Not the same!\n");

	bar = newString("foo");

	if(foo.equals(&foo,&bar))
		printf("Same!\n");
	else
		printf("Not the same!\n");

	foo = foo.reverse(&foo);
	foo.printString(&foo);

	printf("%c\n",foo.charAt(&foo,1));

	bar = newString("bar");
	bar = bar.toUpperCase(&bar);
	printString(&bar);

}
Example #5
0
 String runString(CppiaCtx *ctx)
 {
    String val = strVal->runString(ctx);
    BCR_CHECK;
    if (UPPER)
       return val.toUpperCase();
    else
       return val.toLowerCase();
 }
Example #6
0
void AdminWebServer::check(void)
{
  Admin = KingOfPopAdmin.available();
  this->timeOut();
  if (Admin)
  {
    this->upTime();
    String prompt = this->getPrompt();
    this->authenticate(prompt);
    if (!authenticated)
    {
      return;
    }
    data = prompt;
    String command = prompt.toLowerCase();
    if (command == "quit")
    {
      this->disconnect();
    }
    else if (command == "cancel")
    {
      comstep = 0;
      pos = 0;
      Accounts.cancelSession();
    }
    switch (pos)
    {
    case 0 : 
      this->mainMenu(command); 
      break;
    case 1 : 
      this->addAccount(command); 
      break;
    case 2 : 
      this->listAllAccounts(command);
      break;
    case 3 : 
      this->editAccount(command);
      break;
    case 4 : 
      this->checkBalance(command);
      break;
    case 5 : 
      this->creditAccount(command);
      break;
    case 6 :
      this->chargeAccount(command);
      break;
    case 7 :
      this->adminTools(command);
      break;
    }
  }
}
Example #7
0
//==============================================================================
void WildcardFileFilter::parse (const String& pattern, StringArray& result)
{
    result.addTokens (pattern.toLowerCase(), ";,", "\"'");

    result.trim();
    result.removeEmptyStrings();

    // special case for *.*, because people use it to mean "any file", but it
    // would actually ignore files with no extension.
    for (int i = result.size(); --i >= 0;)
        if (result[i] == "*.*")
            result.set (i, "*");
}
Example #8
0
bool DateTime::parseHttpDate(String httpDate)
{
	char* ptr = (char*)httpDate.c_str();
	int first = httpDate.indexOf(',');
	if (first == -1 || httpDate.length() - first < 20) return false;
	first++; // Skip ','
	if (httpDate[first] == ' ') first ++;

	ptr += first;
	Day = (int8_t)os_strtol(ptr, &ptr, 10);
	if (*ptr == 0) return false;
	ptr++;
	char month[4] = {0};
	memcpy(month, ptr, 3);
	ptr += 4;
	if (*ptr == 0) return false;
	String mon = month;
	mon.toLowerCase();

	if (mon == "jan") Month = 0;
	else if (mon == "feb") Month = 1;
	else if (mon == "mar") Month = 2;
	else if (mon == "apr") Month = 3;
	else if (mon == "may") Month = 4;
	else if (mon == "jun") Month = 5;
	else if (mon == "jul") Month = 6;
	else if (mon == "aug") Month = 7;
	else if (mon == "sep") Month = 8;
	else if (mon == "oct") Month = 9;
	else if (mon == "nov") Month = 10;
	else if (mon == "dec") Month = 11;
	else return false;

	Year = (int16_t)os_strtol(ptr, &ptr, 10);
	if (*ptr == 0) return false;
	if (Year < 69)
		Year += 2000;
	else if (Year < 100)
		Year += 1900;

	Hour = (int8_t)os_strtol(ptr, &ptr, 10);
	if (*ptr != ':') return false;
	ptr++;
	Minute = (int8_t)os_strtol(ptr, &ptr, 10);
	if (*ptr != ':') return false;
	ptr++;
	Second = (int8_t)os_strtol(ptr, &ptr, 10);
	Milliseconds = 0;

	return true;
}
    String makeValidIdentifier (String s, bool capitalise, bool removeColons, bool allowTemplates)
    {
        if (s.isEmpty())
            return "unknown";

        if (removeColons)
            s = s.replaceCharacters (".,;:/@", "______");
        else
            s = s.replaceCharacters (".,;/@", "_____");

        for (int i = s.length(); --i > 0;)
            if (CharacterFunctions::isLetter (s[i])
                 && CharacterFunctions::isLetter (s[i - 1])
                 && CharacterFunctions::isUpperCase (s[i])
                 && ! CharacterFunctions::isUpperCase (s[i - 1]))
                s = s.substring (0, i) + " " + s.substring (i);

        String allowedChars ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_ 0123456789");
        if (allowTemplates)
            allowedChars += "<>";

        if (! removeColons)
            allowedChars += ":";

        StringArray words;
        words.addTokens (s.retainCharacters (allowedChars), false);
        words.trim();

        String n (words[0]);

        if (capitalise)
            n = n.toLowerCase();

        for (int i = 1; i < words.size(); ++i)
        {
            if (capitalise && words[i].length() > 1)
                n << words[i].substring (0, 1).toUpperCase()
                  << words[i].substring (1).toLowerCase();
            else
                n << words[i];
        }

        if (CharacterFunctions::isDigit (n[0]))
            n = "_" + n;

        if (CPlusPlusCodeTokeniser::isReservedKeyword (n))
            n << '_';

        return n;
    }
float PowerupObjectImplementation::getPowerupStat(const String& attribName) {

	for(int i = 0; i < modifiers.size(); ++i) {
		PowerupStat* stat = &modifiers.get(i);

		if(attribName.toLowerCase() ==
				stat->getAttributeToModify().toLowerCase()) {

			return stat->getValue() / 100.f;
		}
	}

	return 0;
}
Example #11
0
std::string WengoAccountParser::createEncyptionKey( const std::string& userId, const std::string& did )
{
	VoxMd5 md5;

	String input = userId;
	input = input.toLowerCase();
	input += did;

	String tempMd5 = md5.toString( input.c_str(), input.size() );

	std::string key = tempMd5.substr( 0, 16 );

	return key;
}
int StructurePermissionList::revokeAllPermissions(const String& playerName, bool caseSensitive) {
	Locker locker(&lock);

	if(playerName == ownerName)
		return CANTCHANGEOWNER;

	for (int i = 0; i < permissionLists.size(); ++i) {
		SortedVector<String>* list = &permissionLists.get(i);

		if (caseSensitive)
			list->drop(playerName);
		else
			list->drop(playerName.toLowerCase());
	}

	return REVOKED;
}
int StructurePermissionList::revokePermission(const String& listName, const String& playerName, bool caseSensitive) {
	Locker locker(&lock);

	if(playerName == ownerName)
		return CANTCHANGEOWNER;

	if (!permissionLists.contains(listName))
		return LISTNOTFOUND;

	SortedVector<String>* list = &permissionLists.get(listName);

	if (caseSensitive)
		list->drop(playerName);
	else
		list->drop(playerName.toLowerCase());

	return REVOKED;
}
uint8 CreatureAttribute::getAttribute(String attribute) {
	attribute = attribute.toLowerCase();

	if (attribute == "action")
		return ACTION;
	else if (attribute == "mind")
		return MIND;
	else if (attribute == "strength")
		return STRENGTH;
	else if (attribute == "constitution")
		return CONSTITUTION;
	else if (attribute == "quickness")
		return QUICKNESS;
	else if (attribute == "stamina")
		return STAMINA;
	else if (attribute == "focus")
		return FOCUS;
	else if (attribute == "willpower")
		return WILLPOWER;
	else
		return HEALTH;

}
void DNSServer::downcaseAndRemoveWwwPrefix(String &domainName)
{
  domainName.toLowerCase();
  domainName.replace("www.", "");
}