コード例 #1
0
ファイル: bml.cpp プロジェクト: jperrot/MeMoPlayer
 void addAttribute (char * name, char * value) {
     int id = getTagId (name); // create the entry if necessary
     if (m_dumpTable) {
         encodeSize (id+1);
         encodeString (value);
     }
 }
void InfinityPortal::processReceivedPacket(unsigned char* packet) {

	if(packet[0x00] == 0xab) {
		// printf("Something was placed somewhere!\n");

		// printf("Received: ");

		// for(int i = 0 ; i < 32 ; i++) {
		// 	printf("%x ",packet[i]);
		// }
		// printf("\n");

		char platformSetting = packet[2];
		char placedRemoved = packet[5];

		if(placedRemoved == 0x00) {
			printf("Tag placed on platform: %d\n",platformSetting);
		} else {
			printf("Tag removed from platform: %d\n",platformSetting);
		}

		getTagId();

	} else if(packet[0x00] == 0xaa && packet[0x01] == 0x09) {
		printf("Got tag info\n");

		// make print tag info!!!
		for(int i = 10 ; i > 2 ; i--) {
			printf("%x ",packet[i]);
		}
		printf("\n");
	}

}
コード例 #3
0
ファイル: bml.cpp プロジェクト: jperrot/MeMoPlayer
 void open (char * t, bool selfClosing) {
     int id = getTagId (t); // create the entry if necessary
     if (m_dumpTable) {
         encodeChar (selfClosing ? 2 : 1);
         encodeSize (id);
     }
 }
コード例 #4
0
// note: If name starts with a digit or by '_', another '_'
// is added.
// (*): In such case, the flag is mandatory.
void TColorStyle::save(TOutputStreamInterface &os) const {
  std::wstring name = getName();
  bool numberedName =
      !name.empty() && ('0' <= name[0] && name[0] <= '9' || name[0] == '_');

  if (m_flags > 0 || (name.length() == 1 && numberedName))
    os << ("_" + QString::number(m_flags)).toStdString();
  std::wstring gname    = getGlobalName();
  std::wstring origName = getOriginalName();

  if (gname != L"") {
    os << ::to_string(L"|" + gname);

    // save the original name from studio palette
    if (origName != L"") {
      // write two "@"s if the edited flag is ON
      os << ::to_string(((m_isEditedFromOriginal) ? L"@@" : L"@") + origName);
    }
  }

  if (numberedName) name.insert(0, L"_");

  os << ::to_string(name) << getTagId();
  saveData(os);
}
コード例 #5
0
    bool RFIDeasReaderUnit::waitRemoval(unsigned int maxwait)
    {
        bool removed = false;

        if (d_insertedChip)
        {
            unsigned int currentWait = 0;
            do
            {
                std::vector<unsigned char> tagid = getTagId();
                if (tagid.size() > 0)
                {
                    if (tagid != d_insertedChip->getChipIdentifier())
                    {
                        d_insertedChip.reset();
                        removed = true;
                    }
                }
                else
                {
                    d_insertedChip.reset();
                    removed = true;
                }

                if (!removed)
                {
                    std::this_thread::sleep_for(std::chrono::milliseconds(250));
                    currentWait += 250;
                }
            } while (!removed && (maxwait == 0 || currentWait < maxwait));
        }

        return removed;
    }
コード例 #6
0
bool TColorStyle::operator==(const TColorStyle &cs) const {
  if (getTagId() != cs.getTagId()) return false;

  if (getMainColor() != cs.getMainColor()) return false;

  int paramCount = getParamCount();
  if (paramCount != cs.getParamCount()) return false;

  int colorParamCount = getColorParamCount();
  if (colorParamCount != cs.getColorParamCount()) return false;

  if (m_name != cs.getName()) return false;
  if (m_originalName != cs.getOriginalName()) return false;
  if (m_globalName != cs.getGlobalName()) return false;
  if (m_isEditedFromOriginal != cs.getIsEditedFlag()) return false;
  if (m_pickedPosition != cs.getPickedPosition()) return false;
  if (m_flags != cs.getFlags()) return false;

  for (int p = 0; p < colorParamCount; ++p)
    if (getColorParamValue(p) != cs.getColorParamValue(p)) return false;

  for (int p = 0; p < paramCount; ++p) {
    switch (getParamType(p)) {
    case BOOL:
      if (getParamValue(bool_tag(), p) != cs.getParamValue(bool_tag(), p))
        return false;
      break;
    case INT:
    case ENUM:
      if (getParamValue(int_tag(), p) != cs.getParamValue(int_tag(), p))
        return false;
      break;
    case DOUBLE:
      if (getParamValue(double_tag(), p) != cs.getParamValue(double_tag(), p))
        return false;
      break;
    case FILEPATH:
      if (getParamValue(TFilePath_tag(), p) !=
          cs.getParamValue(TFilePath_tag(), p))
        return false;
      break;
    default:
      assert(false);
    }
  }

  return true;
}
コード例 #7
0
nodeid_t getTagId ( char *s , NodeType **retp ) {

	// init table?
	static bool s_init = false;
	static HashTableX  s_ht;
	static char s_buf[10000];
	if ( ! s_init ) {
		s_init = true;
		s_ht.set ( 4 ,4,1024,s_buf,10000,false,0,"tagids");//niceness=0
		// how many NodeTypes do we have in g_nodes?
		static int32_t nn = sizeof(g_nodes) / sizeof(NodeType);
		// set the hash table
		for ( int32_t i = 0 ; i < nn ; i++ ) {
			char *name = g_nodes[i].m_nodeName;
			int32_t  nlen = gbstrlen(name);
			int64_t h = hash64Upper_a ( name,nlen,0LL );
			NodeType *nt = &g_nodes[i];
			if ( ! s_ht.addKey(&h,&nt) ) { 
				char *xx=NULL;*xx=0; }
		}
		// sanity
		if ( s_ht.m_numSlots != 1024 ) { char *xx=NULL;*xx=0; }
		// sanity test
		nodeid_t tt = getTagId ( "br" );
		if ( tt != TAG_BR ) { char *xx=NULL;*xx=0; }
	}


	// find end of tag name. hyphens are ok to be in name.
	// facebook uses underscores like <start_time>
	char *e = s; for ( ; *e && (is_alnum_a(*e) || *e=='-'|| *e=='_'); e++);
	// hash it for lookup
	int64_t h = hash64Upper_a ( s , e - s , 0 );
	// look it up
	NodeType **ntp = (NodeType **)s_ht.getValue(&h);
	// assume none
	if ( retp ) *retp = NULL;
	// none?
	if ( ! ntp ) return 0;
	// got one
	if ( retp ) *retp = *ntp;
	// get id otherwise
	return (*ntp)->m_nodeId;
}
コード例 #8
0
    bool RFIDeasReaderUnit::waitInsertion(unsigned int maxwait)
    {
        bool inserted = false;
        unsigned int currentWait = 0;

        do
        {
            std::vector<unsigned char> tagid = getTagId();
            if (tagid.size() > 0)
            {
                d_insertedChip = ReaderUnit::createChip(
					(d_card_type == CHIP_UNKNOWN) ? CHIP_GENERICTAG : d_card_type,
                    tagid
                    );
                inserted = true;
            }

            std::this_thread::sleep_for(std::chrono::milliseconds(250));
            currentWait += 250;
        } while (!inserted && (maxwait == 0 || currentWait < maxwait));

        return inserted;
    }
コード例 #9
0
ファイル: shmcachemanager.cpp プロジェクト: 52M/openlitespeed
int ShmCacheManager::processPurgeCmdEx(
    ShmPrivatePurgeData *pPrivate, const char *pValue, int iValLen,
    time_t curTime, int curTimeMS)
{
    int flag;
    const char *pValueEnd, *pNext;
    const char *pEnd = pValue + iValLen;
    while (pValue < pEnd)
    {
        if (isspace(*pValue))
        {
            ++pValue;
            continue;
        }
        pValueEnd = (const char *)memchr(pValue, ',', pEnd - pValue);
        if (!pValueEnd)
            pValueEnd = pNext = pEnd;
        else
            pNext = pValueEnd + 1;

        while (isspace(pValueEnd[-1]))
            --pValueEnd;

        flag = PDF_PURGE;
        if (strncmp(pValue, "tag=", 4) == 0)
        {
            pValue += 4;
            flag |= PDF_TAG;
        }
        if (*pValue == '*')
        {
            if (pValue == pValueEnd - 1)
            {
                //only a "*".
                if (pPrivate)
                    pPrivate->setLastFlushTime(curTime, curTimeMS);
                else
                {
                    CacheInfo *pInfo = (CacheInfo *)m_pStr2IdHash->
                                       offset2ptr(m_CacheInfoOff);
                    pInfo->setPurgeTime(curTime, curTimeMS);
                }
                pValue = pNext;
                continue;
            }
            else
            {
                //prefix
                flag |= PDF_PREFIX;
            }
        }
        else if (pValueEnd[-1] == '*')
            flag |= PDF_POSTFIX;
        if (pPrivate)
        {
            int idTag = getTagId(pValue, pValueEnd - pValue);
            if (idTag != -1)
            {
                purgeinfo_t purgeinfo = { (int32_t)curTime, (int16_t)curTimeMS,
                                          (uint8_t)flag, (uint8_t)idTag
                                        };
                pPrivate->addUpdate(&purgeinfo);
            }
        }
        else
            addUpdate(pValue, pValueEnd - pValue, flag, curTime, curTimeMS);
        pValue = pNext;
    }
    return 0;
}
コード例 #10
0
// Parsing relies on the std:isw* family of functions doing the "right thing"
// Otherwise, we'd use the SBCS/DBCS tables from the *.nls files as parsed in
// the nls object
Lexer::Token Lexer::lex( IpfData* input )
{
    Token type( END );
    if( input ) {
        wchar_t ch;
        wchar_t quoteChar;
        bool inQuote( false );
        buffer.clear();
        charNum = input->currentCol();
        lineNum = input->currentLine();
        while( ( ch = input->get() ) != EOB ) {
            buffer.push_back( ch );
            if( inTag ) {
                if( type == END ) { //first char after tag name
                    if( ch == L'.' ) {
                        type = TAGEND;
                        inTag = false;
                        break;
                    }
                    else if( std::iswspace( ch ) ) //ignore leading whitespace
                        buffer.erase( buffer.size() - 1 );
                    else if( std::iswalpha( ch ) ) {
                        type = FLAG;    //tentatively
                        inQuote = false;
                    }
                }
                else {
                    if( !inQuote && ch == L'.' ) {
                        input->unget( ch );
                        buffer.erase( buffer.size() - 1 );
                        break;
                    }
                    else if( !inQuote && ch == L':' ) {
                        //syntax error
                        type = ERROR_TAG;
                        break;
                    }
                    else if ( type == FLAG ) {
                        if( ch == L'=' )
                            type = ATTRIBUTE;
                        else if( std::iswspace( ch ) ) {
                            buffer.erase( buffer.size() - 1 );
                            break;
                        }
                    }
                    else if ( type == ATTRIBUTE ) {
                        if( ch == L'\'' || ch == '\"' ) {
                            if( !inQuote ) {
                                inQuote = true;
                                quoteChar = ch;
                            }
                            else if( ch == quoteChar ) {
                                inQuote = false;
                            }
                        }
                        else if( !inQuote && std::iswspace( ch ) ) {
                            buffer.erase( buffer.size() - 1 );
                            break;
                        }
                    }
                    else if( std::iswspace( ch ) ) {
                        //ignore trailing space
                        buffer.erase( buffer.size() - 1 );
                        break;
                    }
                }
            }
            else {
                if( type == END ) {
                    //first character of token
                    if( std::iswspace( ch ) ) {
                        type = WHITESPACE;
                        if( ch == L'\n' )   //don't concatenate spaces
                            break;
                    }
                    else if ( ch == L':' ) {
                        wchar_t ch2( input->get() );
                        input->unget( ch2 );
                        if( std::iswalpha( ch2 ) ) {
                            type = TAG;
                            inTag = true;
                        }
                        else {
                            type = PUNCTUATION;
                            break;
                        }
                    }
                    else if ( ch == L'&' ) {
                        wchar_t ch2( input->get() );
                        input->unget( ch2 );
                        if( std::iswalnum( ch2 ) )
                            type = ENTITY;
                        else
                            type = WORD;
                    }
                    else if ( ch == L'.' ) {
                        if( charNum == 1 )
                            type = COMMAND;
                        else {
                            type = PUNCTUATION;
                            break;
                        }
                    }
                    else if ( std::iswpunct( ch ) ) {
                        //single character, but not '.' or '&' or ':'
                        type = PUNCTUATION;
                        break;
                    }
                    else //if ( std::iswalnum( ch ) )
                        type = WORD;
                }
                else {
                    if( type == COMMAND ) {
                        if( ch == L'\n' ) {
                            break;
                        }
                    }
                    else if( ch == L':' || ch == L'&' ) {
                        //beginning of another token
                        input->unget( ch );
                        buffer.erase( buffer.size() - 1 );
                        if( type == ENTITY )
                            type = ERROR_ENTITY;    //'.' not found
                        break;
                    }
                    else if( type == ENTITY ) {
                        if( ch == L'.' )
                            //end of entity
                            break;
                        if( !std::iswalnum( ch ) ) {
                            //non-fatal malformed entity
                            input->unget( ch );
                            buffer.erase( buffer.size() - 1 );
                            type = ERROR_ENTITY;
                            break;
                        }
                    }
                    else if( type == WHITESPACE &&
                             ( !std::iswspace( ch ) || ch == L'\n' ) ) {
                        //end of whitespace
                        //don't concatenate \n's
                        input->unget( ch );
                        buffer.erase( buffer.size() - 1 );
                        break;
                    }
                    else if( type == WORD &&
                             ( std::iswspace( ch ) || std::iswpunct( ch ) ) ) {
                        //!std::iswalnum( ch )
                        //end of token
                        input->unget( ch );
                        buffer.erase( buffer.size() - 1 );
                        break;
                    }
                }

            }
        }
        if ( type == TAG )
            getTagId();
        else if ( type == COMMAND )
            getCmdId();
    }
    return type;
}