Exemplo n.º 1
0
Arquivo: thread.cpp Projeto: aox/aox
void Thread::parse()
{
    // thread = ["UID" SP] "THREAD" SP thread-alg SP search-criteria
    // thread-alg = "ORDEREDSUBJECT" / "REFERENCES" / thread-alg-ext
    // thread-alg-ext = atom
    // search-criteria = charset 1*(SP search-key)
    // charset = atom / quoted

    space();
    EString threadAlg = atom().lower();
    if ( threadAlg == "orderedsubject" )
        d->threadAlg = ThreadData::OrderedSubject;
    else if ( threadAlg == "refs" )
        d->threadAlg = ThreadData::Refs;
    else if ( threadAlg == "references" )
        d->threadAlg = ThreadData::References;
    else
        error( Bad, "Unsupported thread algorithm" );
    space();
    parser()->mark();
    if ( Codec::byName( astring() ) )
        space();
    else
        parser()->restore();
    d->s = new Selector;
    d->s->add( parseKey() );
    while ( ok() && !parser()->atEnd() ) {
        space();
        d->s->add( parseKey() );
    }
    d->s->simplify();
    end();
}
Exemplo n.º 2
0
ProductKey::ProductKey(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ProductKey)
{
    ui->setupUi(this);
    parseKey();
}
Exemplo n.º 3
0
int
main (int ac, char *ag[])
{
  int len, addr;
  EIBConnection *con;
  uchar buf[255];
  eibaddr_t dest;
  char *prog = ag[0];

  parseKey (&ac, &ag);
  if (ac != 5)
    die ("usage: %s url [-k key] eibaddr addr count", prog);
  con = EIBSocketURL (ag[1]);
  if (!con)
    die ("Open failed");
  dest = readaddr (ag[2]);
  addr = readHex (ag[3]);
  len = atoi (ag[4]);

  if (EIB_MC_Connect (con, dest) == -1)
    die ("Connect failed");
  auth (con);

  len = EIB_MC_Read (con, addr, len, buf);
  if (len == -1)
    die ("Read failed");
  printHex (len, buf);

  EIBClose (con);
  return 0;
}
Exemplo n.º 4
0
int
main (int ac, char *ag[])
{
  int len;
  EIBConnection *con;
  eibaddr_t dest;
  char *prog = ag[0];

  parseKey (&ac, &ag);
  if (ac != 3)
    die ("usage: %s [-k key] url eibaddr", prog);
  con = EIBSocketURL (ag[1]);
  if (!con)
    die ("Open failed");
  dest = readaddr (ag[2]);

  if (EIB_MC_Connect (con, dest) == -1)
    die ("Connect failed");
  auth (con);

  len = EIB_MC_Progmode_Toggle (con);
  if (len == -1)
    die ("Set failed");

  EIBClose (con);
  return 0;
}
Exemplo n.º 5
0
const wchar_t* TcJSONObject::fromObject(const QString&, const wchar_t* ptr)
{
    ptr = skip(ptr);
    if (*ptr == L'{')
    {
        setType(vtfObject);
        do
        {
            ptr = skip(++ptr);
            QString Key;
            ptr = skip(parseKey(Key, ptr));
            if (*ptr == L':')
            {
                ptr = skip(++ptr);

                ptr = parseValue(Key, ptr);
            }
            ptr = skip(ptr);
        } while (ptr && *ptr && *ptr == ',');
        if (ptr && *ptr == L'}')
        {
            ptr = skip(++ptr);
        }
        else
        {
            ptr = 0;
        }
    }
    return ptr;
}
Exemplo n.º 6
0
void GameStateConfigBase::readConfig() {
	//Load the menu configuration from file

	FileParser infile;
	if (infile.open("menus/config.txt")) {
		while (infile.next()) {
			if (parseKeyButtons(infile))
				continue;

			int x1 = popFirstInt(infile.val);
			int y1 = popFirstInt(infile.val);
			int x2 = popFirstInt(infile.val);
			int y2 = popFirstInt(infile.val);

			if (parseKey(infile, x1, y1, x2, y2))
				continue;
			else if (parseStub(infile))
				continue;
			else {
				infile.error("GameStateConfigBase: '%s' is not a valid key.", infile.key.c_str());
			}
		}
		infile.close();
	}
}
Exemplo n.º 7
0
KeyData * PasswdFile::parseLine( char * pPos, char * pLineEnd )
{
    char * pKey;
    int keyLen;
    pKey = parseKey( pPos, pLineEnd, keyLen );
    if ( pKey )
        return parseLine( pKey, keyLen, pPos, pLineEnd );
    return NULL;
}
Exemplo n.º 8
0
int
main (int ac, char *ag[])
{
  uchar buf[10000];
  int len;
  int i;
  EIBConnection *con;
  eibaddr_t dest;
  fd_set read;
  char *prog = ag[0];

  parseKey (&ac, &ag);
  if (ac != 3)
    die ("usage: %s [-k key] url eibaddr", prog);
  con = EIBSocketURL (ag[1]);
  if (!con)
    die ("Open failed");
  dest = readaddr (ag[2]);

  if (EIB_MC_Connect (con, dest) == -1)
    die ("Connect failed");
  auth (con);

  len = EIB_MC_PropertyScan_async (con, sizeof (buf), buf);
  if (len == -1)
    die ("Read failed");

lp:
  FD_ZERO (&read);
  FD_SET (EIB_Poll_FD (con), &read);
  printf ("Waiting\n");
  if (select (EIB_Poll_FD (con) + 1, &read, 0, 0, 0) == -1)
    die ("select failed");
  printf ("Data available\n");
  len = EIB_Poll_Complete (con);
  if (len == -1)
    die ("Read failed");
  if (len == 0)
    goto lp;
  printf ("Completed\n");

  len = EIBComplete (con);

  for (i = 0; i < len; i += 6)
    if (buf[i + 1] == 1 && buf[i + 2] == 4)
      printf ("Obj: %d Property: %d Type: %d Objtype:%d Access:%02X\n",
	      buf[i + 0], buf[i + 1], buf[i + 2],
	      (buf[i + 3] << 8) | buf[i + 4], buf[i + 5]);
    else
      printf ("Obj: %d Property: %d Type: %d Count:%d Access:%02X\n",
	      buf[i + 0], buf[i + 1], buf[i + 2],
	      (buf[i + 3] << 8) | buf[i + 4], buf[i + 5]);

  EIBClose (con);
  return 0;
}
Exemplo n.º 9
0
void MythUIVirtualKeyboard::loadKeyDefinitions(const QString &lang)
{
    QString language = lang.toLower();

    QString defFile = QString("keyboard/%1.xml").arg(language);

    if (!GetMythUI()->FindThemeFile(defFile))
    {
        LOG(VB_GENERAL, LOG_ERR,
            "No keyboard definition file found for: " + language);

        // default to US keyboard layout
        defFile = "keyboard/en_us.xml";
        if (!GetMythUI()->FindThemeFile(defFile))
        {
            LOG(VB_GENERAL, LOG_ERR,
                "Cannot find definitions file: " + defFile);
            return;
        }
    }

    LOG(VB_GENERAL, LOG_NOTICE, "Loading definitions from: " + defFile);

    QDomDocument doc("keydefinitions");
    QFile file(defFile);
    if (!file.open(QIODevice::ReadOnly))
    {
        LOG(VB_GENERAL, LOG_ERR, "Failed to open definitions file: " + defFile);
        return;
    }
    if (!doc.setContent(&file))
    {
        LOG(VB_GENERAL, LOG_ERR,
            "Failed to parse definitions file: " + defFile);
        file.close();
        return;
    }
    file.close();

    QDomElement docElem = doc.documentElement();
    QDomNode n = docElem.firstChild();
    while(!n.isNull())
    {
        QDomElement e = n.toElement();
        if(!e.isNull())
        {
            if (e.tagName() == "key")
                parseKey(e);
        }
        n = n.nextSibling();
    }
}
Exemplo n.º 10
0
const wchar_t* TcJSONObject::parseValue(QString Key, const wchar_t* ptr)
{
    ptr = skip(ptr);
    if ( *ptr )
    {
        if ( *ptr==L'\"' )
        {
            QString Value;
            ptr = skip(parseKey(Value, ptr));
            add(newKey(Key), Value);
        }else
        if ( *ptr==L'{' )
        {
            TcJSONObject* child = addObject(Key);
            ptr = skip(child->fromObject(Key, ptr));
        }else
        if ( *ptr==L'[' )
        {
            TcJSONObject* child = addArray(Key);
            ptr = skip(child->fromArray(ptr));
        }else
        if ( ptr && *ptr
            && (*ptr==L'+'||*ptr==L'-'||*ptr==L'.'||(*ptr>=L'0'&&*ptr<=L'9')||*ptr==L'E'||*ptr==L'e') )
        {
            QString Value;
            ptr = skip(parseNumber(Value, ptr));
            if ( Value.indexOf(".") >-1 )
            {
                add(newKey(Key), Value.toDouble() );
            }else
            {
                add(newKey(Key), Value.toInt() );
            }
        }else
        if ( std::wstring(ptr, 4).compare(L"true")==0 )
        {
            add(newKey(Key), true);
            ptr+=4;
        }else
        if ( std::wstring(ptr, 5).compare(L"false")==0 )
        {
            add(newKey(Key), false);
            ptr+=5;
        }else
        if ( std::wstring(ptr, 4).compare(L"null")==0 )
        {
            add(newKey(Key));
            ptr+=4;
        }
    }
    return ptr;
}
Exemplo n.º 11
0
void XSDSchemaParser::parseXSD(const pt::ptree &keys)
{
    for (auto it = keys.begin(); it != keys.end(); ++it)
    {
        //
        // Element parent (a type in realilty) and the element name help figure out how to process the XSD schema element
        std::string elemType = it->first;
        if (elemType == "xs:include")
        {
            std::string schemaFile = getXSDAttributeValue(it->second, "<xmlattr>.schemaLocation");
            if (m_pSchemaItem->addUniqueName(schemaFile))
            {
                parseXSD(schemaFile);
            }
        }
        else if (elemType == "xs:simpleType")
        {
            parseSimpleType(it->second);
        }
        else if (elemType == "xs:complexType")
        {
            parseComplexType(it->second);
        }
        else if (elemType == "xs:attributeGroup")
        {
            parseAttributeGroup(it->second);
        }
        else if (elemType == "xs:attribute")
        {
            parseAttribute(it->second);
        }
        else if (elemType == "xs:sequence")
        {
            parseXSD(it->second.get_child("", pt::ptree()));
        }
        else if (elemType == "xs:element")
        {
            parseElement(it->second);
        }
        else if (elemType == "xs:key")
        {
            parseKey(it->second);
        }
        else if (elemType == "xs:keyref")
        {
            parseKeyRef(it->second);
        }
    }
}
Exemplo n.º 12
0
Arquivo: Rjson.cpp Projeto: XoDeR/RE
		void parseObject(const char* json, JsonObject& object)
		{
			RIO_ASSERT_NOT_NULL(json);

			if (*json == '{')
			{
				json = getNext(json, '{');

				json = skipSpaces(json);

				if (*json == '}')
				{
					getNext(json, '}');
					return;
				}

				while (*json)
				{
					const char* keyBegin = *json == '"' ? (json + 1) : json;

					TempAllocator256 ta;
					DynamicString key(ta);
					json = parseKey(json, key);

					FixedString fixedSizeKey(keyBegin, key.getLength());

					json = skipSpaces(json);
					json = getNext(json, '=');
					json = skipSpaces(json);

					MapFn::set(object, fixedSizeKey, json);

					json = skipValue(json);
					json = skipSpaces(json);

					if (*json == '}')
					{
						getNext(json, '}');
						return;
					}

					json = skipSpaces(json);
				}
			}

			RIO_FATAL("Bad object");
		}
Exemplo n.º 13
0
Arquivo: xor.c Projeto: rprinz08/UP42
int xor(const char *inputFileName, const char *outputFileName, char *key) {
	FILE *inputFile, *outputFile;
	int keyLen;
	char *parsedKey = NULL;

	setbuf(stdout, NULL);

	if(!strcmp(inputFileName, "-"))
		inputFile = stdin;
	else
		inputFile = fopen(inputFileName, "rb");

	if(!inputFile) {
		printError(stderr, "opening input file (%s)", inputFileName);
		return(EXIT_INPUT_FILE_ERROR);
	}

	if(!strcmp(outputFileName, "-"))
		outputFile = stdout;
	else
		outputFile = fopen(outputFileName, "wb");

	if(!outputFile) {
		printError(stderr, "opening output file (%s)", outputFileName);
		return(EXIT_OUTPUT_FILE_ERROR);
	}

	try {
		parseKey(key, &keyLen);
		xorFile(inputFile, outputFile, parsedKey, keyLen);
	}
	catch(RuntimeException) {
		const e4c_exception *exception = e4c_get_exception();
		e4c_print_exception(exception);
		return(EXIT_UNKNOWN_ERROR);
	}
	finally {
		if(inputFile != stdin)
			fclose(inputFile);

		if(outputFile != stdout)
			fclose(outputFile);
	}

	return(EXIT_OK);
}
Exemplo n.º 14
0
int main(int argc, const char** argv) {
    int isotope;
    char modifiers = 0;
    char keys[6] = {0};
    int keysCount = 0;
    char release = 1;
    
    cmd_init(argc, argv);
    
    if(cmd_hasFlag('?', "help")) {
        printf("Isotope Keyboard Emulator\n");
        printf("Usage: %s -C -shift -A -win A SPACE BACKSPACE DEL F11 NUM7\n", cmd_application());
        return -1;
    }
    
    if(cmd_hasFlag('H', "hold")) release = 0;
    
    if(cmd_hasFlag('C', "ctrl")) modifiers |= MODIFIERKEY_CTRL;
    if(cmd_hasFlag(0, "lctrl")) modifiers |= MODIFIERKEY_LEFT_CTRL;
    if(cmd_hasFlag(0, "rctrl")) modifiers |= MODIFIERKEY_RIGHT_CTRL;
    
    if(cmd_hasFlag('A', "alt")) modifiers |= MODIFIERKEY_ALT;
    if(cmd_hasFlag(0, "lalt")) modifiers |= MODIFIERKEY_LEFT_ALT;
    if(cmd_hasFlag(0, "ralt")) modifiers |= MODIFIERKEY_RIGHT_ALT;
    
    if(cmd_hasFlag('S', "shift")) modifiers |= MODIFIERKEY_SHIFT;
    if(cmd_hasFlag(0, "lshift")) modifiers |= MODIFIERKEY_LEFT_SHIFT;
    if(cmd_hasFlag(0, "rshift")) modifiers |= MODIFIERKEY_RIGHT_SHIFT;
    
    if(cmd_hasFlag('W', "win")) modifiers |= MODIFIERKEY_GUI;
    if(cmd_hasFlag(0, "lwin")) modifiers |= MODIFIERKEY_LEFT_GUI;
    if(cmd_hasFlag(0, "rwin")) modifiers |= MODIFIERKEY_RIGHT_GUI;
    
    while(parseKey(keys, &keysCount));
    
    if(isotope = isotope_open("/dev/ttyAMA0")) {
        isotope_keyboard(isotope, modifiers, keys, keysCount);
        if(release) isotope_keyboard(isotope, 0, 0, 0);
        isotope_close(isotope);
        return 0;
    } else {
        printf("Error: Unable to connect to Isotope device, please ensure the UART is available.\n");
        return -2;
    }
}
Exemplo n.º 15
0
bool GraphMLHandler::startElement(const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts)
{
  if(done)
    return true;
  
  if(!localName.compare("key"))
    return parseKey(atts);
  else if(!localName.compare("graph"))
    return parseGraphElm(atts);
  else if(!localName.compare("node"))
    return parseNode(atts);
  else if(!localName.compare("edge"))
    return parseEdge(atts);
  else if(!localName.compare("data"))
    return parseData(atts);
  
  return true;
}
Exemplo n.º 16
0
Arquivo: Rjson.cpp Projeto: XoDeR/RE
		void parseObject(const char* json, Map<DynamicString, const char*>& object)
		{
			RIO_ASSERT_NOT_NULL(json);

			if (*json == '{')
			{
				json = getNext(json, '{');

				json = skipSpaces(json);

				if (*json == '}')
				{
					getNext(json, '}');
					return;
				}

				while (*json)
				{
					TempAllocator256 ta;
					DynamicString key(ta);
					json = parseKey(json, key);

					json = skipSpaces(json);
					json = getNext(json, '=');
					json = skipSpaces(json);

					MapFn::set(object, key, json);

					json = skipValue(json);
					json = skipSpaces(json);

					if (*json == '}')
					{
						getNext(json, '}');
						return;
					}

					json = skipSpaces(json);
				}
			}

			RIO_FATAL("Bad object");
		}
Exemplo n.º 17
0
status_t KeyLayoutMap::Parser::parse() {
    while (!mTokenizer->isEof()) {
#if DEBUG_PARSER
        ALOGD("Parsing %s: '%s'.", mTokenizer->getLocation().string(),
                mTokenizer->peekRemainderOfLine().string());
#endif

        mTokenizer->skipDelimiters(WHITESPACE);

        if (!mTokenizer->isEol() && mTokenizer->peekChar() != '#') {
            String8 keywordToken = mTokenizer->nextToken(WHITESPACE);
            if (keywordToken == "key") {
                mTokenizer->skipDelimiters(WHITESPACE);
                status_t status = parseKey();
                if (status) return status;
            } else if (keywordToken == "axis") {
                mTokenizer->skipDelimiters(WHITESPACE);
                status_t status = parseAxis();
                if (status) return status;
            } else if (keywordToken == "led") {
                mTokenizer->skipDelimiters(WHITESPACE);
                status_t status = parseLed();
                if (status) return status;
            } else {
                ALOGE("%s: Expected keyword, got '%s'.", mTokenizer->getLocation().string(),
                        keywordToken.string());
                return BAD_VALUE;
            }

            mTokenizer->skipDelimiters(WHITESPACE);
            if (!mTokenizer->isEol() && mTokenizer->peekChar() != '#') {
                ALOGE("%s: Expected end of line or trailing comment, got '%s'.",
                        mTokenizer->getLocation().string(),
                        mTokenizer->peekRemainderOfLine().string());
                return BAD_VALUE;
            }
        }

        mTokenizer->nextLine();
    }
    return NO_ERROR;
}
Exemplo n.º 18
0
void GameStateConfigDesktop::readConfig() {
	FileParser infile;
	if (infile.open("menus/config.txt")) {
		while (infile.next()) {
			int x1 = popFirstInt(infile.val);
			int y1 = popFirstInt(infile.val);
			int x2 = popFirstInt(infile.val);
			int y2 = popFirstInt(infile.val);

			if (parseKeyDesktop(infile, x1, y1, x2, y2))
				continue;
			else if (parseKey(infile, x1, y1, x2, y2))
				continue;
			else {
				infile.error("GameStateConfigDesktop: '%s' is not a valid key.", infile.key.c_str());
			}
		}
		infile.close();
	}
}
Exemplo n.º 19
0
Arquivo: Rjson.cpp Projeto: XoDeR/RE
		void parseRootObject(const char* json, Map<DynamicString, const char*>& object)
		{
			RIO_ASSERT_NOT_NULL(json);

			while (*json)
			{
				TempAllocator256 ta;
				DynamicString key(ta);
				json = parseKey(json, key);

				json = skipSpaces(json);
				json = getNext(json, '=');
				json = skipSpaces(json);

				MapFn::set(object, key, json);

				json = skipValue(json);
				json = skipSpaces(json);
			}
		}
Exemplo n.º 20
0
void LayoutParser::parseRow(const TagRowContainerPtr &row_container)
{
    static const QStringList heightValues(QString::fromLatin1("small,medium,large,x-large,xx-large").split(','));

    const TagRow::Height height(enumValue("height", heightValues, TagRow::Medium));
    TagRowPtr new_row(new TagRow(height));

    row_container->appendRow (new_row);

    while (m_xml.readNextStartElement()) {
        const QStringRef name(m_xml.name());

        if (name == QLatin1String("key")) {
            parseKey(new_row);
        } else if (name == QLatin1String("spacer")) {
            parseSpacer(new_row);
        } else {
            error(QString::fromLatin1("Expected '<key>' or '<spacer>', but got '<%1>'.").arg(name.toString()));
        }
    }
}
int main()
{
	qcin.setCodec(QTextCodec::codecForName("UTF-8"));
	qcout.setCodec(QTextCodec::codecForName("UTF-8"));

	QString curGroup;

	QRegExp groupRegExp( "^\\[(.*)\\]" );
	QRegExp keyRegExp( "^([a-zA-Z0-9:, _-]*)\\s*=\\s*(.*)\\s*" );
	QRegExp commentRegExp( "^(#.*)?$" );

	while ( !qcin.atEnd() )
	{
		QString line = qcin.readLine();

		if ( commentRegExp.exactMatch( line ) )
		{
			// We found a comment, leave unchanged
			qcout << line << endl;
		}
		else if ( groupRegExp.exactMatch( line ) )
		{
			// We found the start of a group, leave unchanged
			qcout << line << endl;

			curGroup = groupRegExp.capturedTexts()[ 1 ];
		}
		else if ( keyRegExp.exactMatch( line ) )
		{
			// We found the a key line
			parseKey( curGroup, keyRegExp.capturedTexts()[ 1 ], keyRegExp.capturedTexts()[ 2 ], line );
		}
		else
		{
			qcerr << "** Unknown input line: " << line << endl;
		}
	}

	return 0;
}
::std::string MongoDBConfiguration::getMongoDBPassword() const {
    return ezConfiguration.getString(
        parseKey(g_EzBakeProperty_constants.MONGODB_PASSWORD),
        "");
}
Exemplo n.º 23
0
void Knight::parseActions(pugi::xml_node *tmp_node)
{
	Animation *tmp_animation = nullptr;

	// NOTE(juha): Goes through all the actions
	for(pugi::xml_node_iterator action_it = tmp_node->begin();
			action_it != tmp_node->end();
			++action_it)
	{
		SpecialCombo tmp_combo;
		tmp_combo.name = action_it->attribute("name").value();

		if (tmp_combo.name.compare("jump") == 0) {
			jump = (float)atof(action_it->attribute("height").value());
		}

		std::string tmp_type_string = action_it->attribute("format").value();
		if (tmp_type_string.compare("strike") == 0) {
			tmp_combo.format = tmp_combo.TYPE_STRIKE;
		} else if (tmp_type_string.compare("ranged") == 0) {
			tmp_combo.format = tmp_combo.TYPE_RANGED;
		} else {
			tmp_combo.format = tmp_combo.TYPE_MISC;
		}
		
		// NOTE(juha): Goes through all the properties for an action
		for(pugi::xml_node_iterator property_it = action_it->begin();
			property_it != action_it->end();
			++property_it)
		{
			std::string tmp_string = property_it->name();
			
			if (tmp_string.compare("damage") == 0) {
				tmp_combo.damage = atoi(action_it->child("damage").attribute("value").value());
			}
			
			if (tmp_string.compare("animation") == 0) {
				tmp_animation = new Animation(window, 
						 action_it->child("animation").attribute("filename").value(),
					atoi(action_it->child("animation").attribute("width").value()),
					atoi(action_it->child("animation").attribute("height").value()),
					atoi(action_it->child("animation").attribute("startframe").value()),
					atoi(action_it->child("animation").attribute("framecount").value()),
					atoi(action_it->child("animation").attribute("framerate").value()));
				tmp_animation->running = false;
			}
			tmp_combo.defineAnimation(tmp_animation);
			tmp_combo.repeats = atoi(action_it->child("animation").attribute("loops").value());
			tmp_combo.frames = atoi(action_it->child("animation").attribute("framecount").value());
			tmp_combo.setHitboxes();

			if (tmp_string.compare("hitbox") == 0) {
				int frame =          atoi(action_it->child("hitbox").attribute("frame").value());
				Rectangle tmp_hitbox(atoi(action_it->child("hitbox").attribute("x").value()),
									 atoi(action_it->child("hitbox").attribute("y").value()),
									 atoi(action_it->child("hitbox").attribute("width").value()),
									 atoi(action_it->child("hitbox").attribute("height").value()));

				tmp_combo.hitboxes[frame] = tmp_hitbox;
			}
			
			if (tmp_string.compare("hitboxes") == 0) {

				for(pugi::xml_node_iterator hb_iterator =  action_it->child("hitboxes").begin();
											hb_iterator != action_it->child("hitboxes").end();
										  ++hb_iterator)
				{
					int frame =          atoi(hb_iterator->attribute("frame").value());
					Rectangle tmp_hitbox(atoi(hb_iterator->attribute("x").value()),
										 atoi(hb_iterator->attribute("y").value()),
										 atoi(hb_iterator->attribute("width").value()),
										 atoi(hb_iterator->attribute("height").value()));

					tmp_combo.hitboxes[frame] = tmp_hitbox;
				}
			}
			
			if (tmp_string.compare("control") == 0) {
				Key tmp_key_object;

				for(pugi::xml_node_iterator key_iterator = action_it->child("control").begin();
						key_iterator != action_it->child("control").end();
						++key_iterator)
				{
					std::string tmp_key_value = std::string(key_iterator->child_value());
					tmp_key_object.keycode = parseKey(tmp_key_value);

					tmp_key_value = std::string(key_iterator->attribute("pressed").value());
					
					if (tmp_key_value.compare("true") == 0) {
						tmp_key_object.pressed = true;
					}
					
					tmp_key_value = std::string(key_iterator->attribute("inair").value());
					
					if (tmp_key_value.compare("true") == 0) {
						tmp_key_object.in_air = true;
					}

					tmp_combo.keys.push_back(tmp_key_object);
				}
			}
			
			if (tmp_string.compare("name") == 0) {
				tmp_combo.combo_name = action_it->child("name").child_value();
			}
			
			if (tmp_string.compare("effect") == 0) {
				parseEffect(action_it->child("effect"), &tmp_combo);
			}

			if (tmp_string.compare("effects") == 0) {
				for(pugi::xml_node_iterator effect_iterator =  action_it->child("effects").begin();
											effect_iterator != action_it->child("effects").end();
										  ++effect_iterator)
				{
					parseEffect(effect_iterator, &tmp_combo);
				}

			}
			// TODO(juha): buffeffect, projectile, projectilespawner, trapspawner,
			//			   control parameters, hitbox frames, areaeffect.
			
			if (tmp_string.compare("areaeffect") == 0) {
				AreaEffect tmp_area_effect;
				tmp_area_effect.name = action_it->attribute("name").value();
			
				tmp_area_effect.hitbox.x = atoi(action_it->child("hitbox").attribute("x").value());
				tmp_area_effect.hitbox.y = atoi(action_it->child("hitbox").attribute("y").value());
				tmp_area_effect.hitbox.w = atoi(action_it->child("hitbox").attribute("width").value());
				tmp_area_effect.hitbox.h = atoi(action_it->child("hitbox").attribute("height").value());
			
				tmp_area_effect.damage = atoi(action_it->child("damage").attribute("value").value());
			
				tmp_combo.area_effects.push_back(tmp_area_effect);
			}
			
			if (tmp_string.compare("buffeffect") == 0) {
				BuffEffect tmp_buff_effect;
				Animation *tmp_animation = nullptr;
				tmp_buff_effect.name = action_it->attribute("name").value();
			
				std::string tmp_type_string = action_it->child("collision").attribute("collision").value();
				if (tmp_type_string.compare("all") == 0) {
					tmp_buff_effect.collision_type = tmp_buff_effect.COLLISION_ALL;
				} else if (tmp_type_string.compare("player") == 0) {
					tmp_buff_effect.collision_type = tmp_buff_effect.COLLISION_PLAYER;
				} else if (tmp_type_string.compare("wall") == 0) {
					tmp_buff_effect.collision_type = tmp_buff_effect.COLLISION_WALL;
				} else {
					tmp_buff_effect.collision_type = tmp_buff_effect.COLLISION_WALL;
				}
			
				tmp_type_string = action_it->child("collision").attribute("collisiondestruct").value();
				if (tmp_type_string.compare("true") == 0) {
					tmp_buff_effect.collision_destruct = true;
				} else {
					tmp_buff_effect.collision_destruct = false;
				}
			
				tmp_buff_effect.hitbox.x = atoi(action_it->child("hitbox").attribute("x").value());
				tmp_buff_effect.hitbox.y = atoi(action_it->child("hitbox").attribute("y").value());
				tmp_buff_effect.hitbox.w = atoi(action_it->child("hitbox").attribute("width").value());
				tmp_buff_effect.hitbox.h = atoi(action_it->child("hitbox").attribute("height").value());
			
				tmp_buff_effect.damage = atoi(action_it->child("damage").attribute("value").value());
			
				tmp_combo.buff_effects.push_back(tmp_buff_effect);
			}
			
			if (tmp_string.compare("projectilespawner") == 0) {
				ProjectileSpawner tmp_projectile_spawner;

				tmp_projectile_spawner.type = action_it->child("projectilespawner").attribute("name").value();
				tmp_projectile_spawner.amount = atoi(action_it->child("projectilespawner").attribute("amount").value());
				tmp_projectile_spawner.angle = atoi(action_it->child("projectilespawner").attribute("angle").value());
				tmp_projectile_spawner.angle_interval = atoi(action_it->child("projectilespawner").attribute("angleinterval").value());
				tmp_projectile_spawner.delay = atoi(action_it->child("projectilespawner").attribute("delay").value());
				tmp_projectile_spawner.delay_interval = atoi(action_it->child("projectilespawner").attribute("delayinterval").value());
				
				tmp_combo.projectile_spawners.push_back(tmp_projectile_spawner);
			}
			
			if (tmp_string.compare("trapspawner") == 0) {
				TrapSpawner tmp_trap_spawner;

				tmp_trap_spawner.type = action_it->child("trapspawner").attribute("name").value();
				tmp_trap_spawner.amount = atoi(action_it->child("trapspawner").attribute("amount").value());
				tmp_trap_spawner.angle = atoi(action_it->child("trapspawner").attribute("angle").value());
				tmp_trap_spawner.angle_interval = atoi(action_it->child("trapspawner").attribute("angleinterval").value());
				tmp_trap_spawner.delay = atoi(action_it->child("trapspawner").attribute("delay").value());
				tmp_trap_spawner.delay_interval = atoi(action_it->child("trapspawner").attribute("delayinterval").value());

				trap_spawners.push_back(tmp_trap_spawner);
			}
		}
		if (tmp_combo.name.compare("basic") == 0) {
			weapon.power = tmp_combo.damage;
			weapon.setHit(false);
			moves[ATTACK] = tmp_combo;
		} else if (tmp_combo.name.compare("midair_basic") == 0) {
			tmp_combo.disabled = true;
			moves[MID_AIR_BASIC_ATTACK] = tmp_combo;
		} else if (tmp_combo.name.compare("midair_downthrust") == 0) {
			tmp_combo.disabled = false;
			moves[DOWN_THRUST] = tmp_combo;
		} else if (tmp_combo.name.compare("special1") == 0) {
			tmp_combo.disabled = false;
			moves[SPECIAL_I] = tmp_combo;
		} else if (tmp_combo.name.compare("special2") == 0) {
			tmp_combo.disabled = true;
			moves[SPECIAL_II] = tmp_combo;
		} else if (tmp_combo.name.compare("special3") == 0) {
			tmp_combo.disabled = true;
			moves[SPECIAL_III] = tmp_combo;
		} else if (tmp_combo.name.compare("special4") == 0) {
			tmp_combo.disabled = true;
			moves[SPECIAL_IV] = tmp_combo;
		} else if (tmp_combo.name.compare("throw") == 0) {
			tmp_combo.disabled = true;
			moves[THROW] = tmp_combo;
		} else if (tmp_combo.name.compare("uppercut") == 0) {
			tmp_combo.disabled = false;
			tmp_combo.in_ground = true;
			moves[UPPERCUT] = tmp_combo;
		} else if (tmp_combo.name.compare("block") == 0) {
			tmp_combo.disabled = true;
			moves[BLOCK] = tmp_combo;
		} else if (tmp_combo.name.compare("crouch") == 0) {
			moves[CROUCH] = tmp_combo;
		} else if (tmp_combo.name.compare("death") == 0) {
			moves[DEATH] = tmp_combo;
		} else if (tmp_combo.name.compare("dodge") == 0) {
			tmp_combo.disabled = true;
			moves[DODGE] = tmp_combo;
		} else if (tmp_combo.name.compare("hanging") == 0) {
			tmp_combo.disabled = true;
			moves[HANGING] = tmp_combo;
		} else if (tmp_combo.name.compare("idle") == 0) {
			moves[IDLE] = tmp_combo;
		} else if (tmp_combo.name.compare("jump") == 0) {
			moves[JUMP] = tmp_combo;
		} else if (tmp_combo.name.compare("pushback") == 0) {
			tmp_combo.disabled = true;
			moves[PUSHBACK] = tmp_combo;
		} else if (tmp_combo.name.compare("run") == 0) {
			moves[RUN] = tmp_combo;
		}
	}
}
::std::string AccumuloConfiguration::getPassword() const {
    return ezConfiguration.getString(
        parseKey(g_EzBakeProperty_constants.ACCUMULO_PASSWORD),
        "");
}
Exemplo n.º 25
0
int main()
{

	inits();

	DHT22 * dhtS = new DHT22(18, "Sisämittari(DIG)");
	DHT22 * dht2S = new DHT22(17, "Ulkomittari(DIG)");
	BMP180 * bmp = new BMP180(0x77, "Painemittari(DIG)");

	char *code = NULL;

	short prog = 1;

	clock_t timer1 = clock();
	clock_t timer2 = clock();

	for(tempSensIT it = tempSensors.begin(); it != tempSensors.end(); ++it) {
		it->second->update();
	}

	//while(lirc_nextcode(&code) != 0) {
	while(1) {

		if(float(clock())/CLOCKS_PER_SEC - float(timer1)/CLOCKS_PER_SEC >= 0.012) {

			// Turn on DHT22's
			digitalWrite(20, HIGH);
			usleep(1000);

			for(tempSensIT it = tempSensors.begin(); it != tempSensors.end(); ++it) {
				it->second->update();
			}

			digitalWrite(20, LOW);

			timer1 = clock();

		}

		if(float(clock())/CLOCKS_PER_SEC - float(timer2)/CLOCKS_PER_SEC >= 0.25) {
			#ifdef HCDEBUG
				logfile << "MySQL connection: " << (mysql_ping(sqlcon) == 0 ? "Up" : "Down") << endl;
			#endif
			for(tempSensIT it = tempSensors.begin(); it != tempSensors.end(); ++it) {
				it->second->saveCurTemp();
			}
			for(humSensIT it = humSens.begin(); it != humSens.end(); ++it) {
				it->second->saveCurHumi();
			}
			for(pressSensIT it = pressSens.begin(); it != pressSens.end(); ++it) {
				it->second->saveCurPress();
			}
			timer2 = clock();
		}

		switch(prog) {
			case 0:
			{
				lcdClear(lcdHandle);
				break;
			}
			case 1:
			{
				lcdPrint1("Temperatures("+string(1, (unsigned char)(int)223)+"C)");

				stringstream ss;
				for(tempSensIT it = tempSensors.begin(); it != tempSensors.end(); ++it) {
					ss << (int)it->second->getTemp() << " ";
				}
				lcdPrint2(ss.str());
				break;
			}
			case 2:
			{
				lcdPrint1("Humidities(%)");
				stringstream ss;
				for(humSensIT it = humSens.begin(); it != humSens.end(); ++it) {
					ss << (int)it->second->getHumi() << " ";
				}
				lcdPrint2(ss.str());
				break;
			}
			case 3:
			{
				lcdPrint1("Pressures(hPa)");
				stringstream ss;
				for(pressSensIT it = pressSens.begin(); it != pressSens.end(); ++it) {
					ss << (int)it->second->getPress() << " ";
				}
				lcdPrint2(ss.str());
				break;
			}
		}

		if(code != NULL) {
			if(parseKey(code) == "KEY_SUSPEND") {
				if(shutdown()) {
					break;
				}
			}
			if(parseKey(code) == "KEY_MODE") {
				calibrateAnalogTempSensors();
			}
			if(parseKey(code) == "KEY_0") {
				prog = 0;
			}
			if(parseKey(code) == "KEY_1") {
				prog = 1;
			}
			if(parseKey(code) == "KEY_2") {
				prog = 2;
			}
			free(code);
		}
	}

	delete diS;
	delete diS2;
	delete dhtS;
	delete dht2S;
	delete bmp;

	deinits();

	return EXIT_SUCCESS;
}
::std::string MongoDBConfiguration::getMongoDBUserName() const {
    return ezConfiguration.getString(
        parseKey(g_EzBakeProperty_constants.MONGODB_USER_NAME),
        "");
}
bool MongoDBConfiguration::useMongoDBSSL() const {
    return ezConfiguration.getBoolean(
        parseKey(g_EzBakeProperty_constants.MONGODB_USE_SSL),
        false);
}
Exemplo n.º 28
0
QList<KeyData> QCrmlParser::parseKeyRange(quint32 repoUid)
{
    QList<KeyData> rv;

    //if keyRange has no ref attribute it must
    //only be used for creating access control
    //policies which we do not need to worry about
    if (attributes().value(QLatin1String("ref")).isNull())
        return rv;

    QStringList mandatoryAttributes;
    mandatoryAttributes << QLatin1String("firstInt") << QLatin1String("lastInt");
    if (!checkMandatoryAttributes(mandatoryAttributes))
        return rv;

    bool ok = false;
    QString pathPrefix;
    pathPrefix = attributes().value(QLatin1String("ref")).toString();
    if (!pathPrefix.startsWith(QLatin1Char('/')))
        pathPrefix.prepend(QLatin1Char('/'));

    if (!attributes().value(QLatin1String("countInt")).isNull()) {
        quint32 countInt =
            uidStringToUInt32(attributes().value(QLatin1String("countInt")).toString(), &ok);
        if (!ok) {
            setError(ParseError, QObject::tr("keyRange element has invalid countInt attribute on line %1")
                    .arg(QString::number(lineNumber())));
            rv.clear();
            return rv;
        }

        rv.append(KeyData(pathPrefix,(quint64)countInt + (((quint64)repoUid) << 32), m_target));
    }

    if (!pathPrefix.endsWith(QLatin1Char('/')))
        pathPrefix.append(QLatin1Char('/'));

    quint32 firstInt =
        uidStringToUInt32(attributes().value(QLatin1String("firstInt")).toString(), &ok);
    if (!ok) {
        setError(ParseError, QObject::tr("keyRange element has invalid firstInt attribute on line %1")
                .arg(QString::number(lineNumber())));
        rv.clear();
        return rv;
    }

    quint32 lastInt =
        uidStringToUInt32(attributes().value(QLatin1String("lastInt")).toString(),&ok);
    if (!ok) {
        setError(ParseError, QObject::tr("keyRange element has invalid lastInt attribute on line %1")
                .arg(QString::number(lineNumber())));
        rv.clear();
        return rv;
    }

    quint32 maxNum =0;
    quint32 indexBits = 0;
    quint32 firstIndex = 0;
    if (attributes().value(QLatin1String("indexBits")).isNull()) {
        //keyRange doesn't map to sequence setting

        maxNum = lastInt - firstInt + 1;
        for (quint32 i=0; i < maxNum; i++) {
            rv.append(KeyData(pathPrefix + QString::number(i),
                                (quint64)firstInt + (((quint64)repoUid) << 32) + i,
                                m_target));
        }

        while (!atEnd()) {
            readNext();
            if (QXmlStreamReader::error() != QXmlStreamReader::NoError) {
                setError(ParseError, QXmlStreamReader::errorString());
                rv.clear();
                return rv;
            }

            if (isEndElement())
                break;

            if (isStartElement())
                parseUnknownElement();
        }
    } else {
        //keyRanges does  map to sequence setting
        indexBits =
            uidStringToUInt32(attributes().value(QLatin1String("indexBits")).toString(), &ok);
        if (!ok) {
            setError(ParseError, QObject::tr("keyRange elment has invalid indexBits attribute on line %1")
                    .arg(QString::number(lineNumber())));
            rv.clear();
            return rv;
        }

        if (!attributes().value(QLatin1String("firstIndex")).isNull()) {
            QString firstIndexStr = attributes().value(QLatin1String("firstIndex")).toString();
            firstIndex = firstIndexStr.toUInt(&ok, 10);
            if (!ok) {
                setError(ParseError, QObject::tr("keyRange element has invalid firstIndex attribute on line %1")
                        .arg(QString::number(lineNumber())));
                rv.clear();
                return rv;
            }
        }

        int indexBitsLSB =0;
        quint32 bitmask = 1;
        while ( (bitmask & indexBits) == 0) {
            bitmask = bitmask << 1;
            bitmask +=1;
            indexBitsLSB+=1;
        }

        maxNum =( ((lastInt - firstInt) & indexBits) >> indexBitsLSB) + 1 - firstIndex;

        int indexBitsMSB=31;
        bitmask = 0x80000000;
        while ((bitmask & indexBits) == 0) {
            bitmask = bitmask >> 1;
            bitmask += 0x80000000;
            indexBitsMSB -=1;
        }
        bitmask = bitmask << 1;
        quint32 settingIdentifier = lastInt & bitmask;

        QList<KeyData> subSettings;

        while (!atEnd()) {
            readNext();
            if (QXmlStreamReader::error() != QXmlStreamReader::NoError) {
                setError(ParseError, QXmlStreamReader::errorString());
                rv.clear();
                return rv;
            }

            if (isEndElement())
                break;

            if (isStartElement()) {
                if (name() == "key") {
                    subSettings.append(parseKey(repoUid));

                    if (QXmlStreamReader::error() != QXmlStreamReader::NoError) {
                        rv.clear();
                        return rv;
                    }
                } else {
                    parseUnknownElement();
                }
            }

        }

        for(quint32 i = 0; i < maxNum; i++) {
            for(int j = 0; j < subSettings.count(); j++) {
                rv.append(KeyData(pathPrefix + QString::number(i) + subSettings.at(j).path(),
                                 subSettings.at(j).uid() + settingIdentifier + ((firstIndex + 1*i)  << indexBitsLSB),
                                 m_target, subSettings.at(j).bitIndex()));
            }
        }
    }

    return rv;
}
Exemplo n.º 29
0
QList<KeyData> QCrmlParser::parseRepository()
{
    QList<KeyData> rv;
    QStringList mandatoryAttributes;
    mandatoryAttributes << QLatin1String("uidValue");
    setError(NoError, QString());
    if (!checkMandatoryAttributes(mandatoryAttributes))
        return rv;

    bool ok;
    quint32 uidValue =
        uidStringToUInt32(attributes().value(QLatin1String("uidValue")).toString(), &ok);
    if (!ok) {
        setError(ParseError, QObject::tr("repository element has invalid uidValue on line %1")
                               .arg(QString::number(lineNumber())));
        return rv;
    }

    QString targetStr = attributes().value(QLatin1String("target")).toString();
    if (targetStr.isEmpty() || targetStr == QLatin1String("CRepository")) {
        m_target = KeyData::CRepository;
    } else if (targetStr == QLatin1String("RProperty")) {
        m_target = KeyData::RProperty;
    } else {
        setError(ParseError, QObject::tr("repository element has unrecognised target attribute "
                                        "on line %1, attribute must be CRepository, RProperty or "
                                        "be left undefined").arg(QString::number(lineNumber())));
        return rv;
    }

    while (!atEnd())
    {
        readNext();
         if (QXmlStreamReader::error() != QXmlStreamReader::NoError) {
            setError(ParseError, QXmlStreamReader::errorString());
            rv.clear();
           return rv;
        }

        if (isEndElement()  && name() == "repository")
            break;

        if (isStartElement()) {
            if (name() == "key")
                rv.append(parseKey(uidValue));
            else if (name() == "keyRange")
                rv.append(parseKeyRange(uidValue));
            else
                parseUnknownElement();
        }

        if (m_error != NoError) {
            rv.clear();
            break;
        }
    }

    if (!isEndElement() && name() != "repository") {
        setError(ParseError, QObject::tr("File did not end with a repository end tag"));
        rv.clear();
        return rv;
    }

    return rv;

}
::std::string ZookeeperConfiguration::getZookeeperConnectionString() const {
    return ezConfiguration.getString(
               parseKey(g_EzBakeProperty_constants.ZOOKEEPER_CONNECTION_STRING),
               "");
}