コード例 #1
0
    vector<CharSet> GetCharSets(CharRange ranges)
    {
        vector<CharSet> ret_val;

        for(int i = 1; i & static_cast<int>(CharRange::All); i <<= 1)
        {
            if(! (i & static_cast<int>(ranges)))
                continue;

            CharRange range = static_cast<CharRange>(i);
            switch(range)
            {
                case CharRange::LowerAtoZ:
                    ret_val.push_back(CharSet(GetLowerAtoZ(), range));
                    break;
                case CharRange::UpperAtoZ:
                    ret_val.push_back(CharSet(GetUpperAtoZ(), range));
                    break;
                case CharRange::Numbers:
                    ret_val.push_back(CharSet(GetNumbers(), range));
                    break;
                case CharRange::Symbols:
                    ret_val.push_back(CharSet(GetSymbols(), range));
                    break;
                case CharRange::Other:
                    // ignore
                    break;
                default:
                    assert(false);
                    return ret_val;
            }
        }

        return ret_val;
    }
コード例 #2
0
ファイル: Gold.cpp プロジェクト: CodeBlack0/RougeConsole
Gold::Gold(std::string line)
{
	std::vector<std::string> linedata;
	linedata = tokenize(line, ';');
	
	pos = Coords(std::stoi(linedata.at(1)), std::stoi(linedata.at(2)));
	value = std::stoi(linedata.at(3));
	sym = CharSet('$', '³');

	used = false;
}
コード例 #3
0
// ======================================================================
void EventInputQueue::push_KeyboardEventCallback(OSObject* target,
                                                 unsigned int eventType,
                                                 unsigned int flags,
                                                 unsigned int key,
                                                 unsigned int charCode,
                                                 unsigned int charSet,
                                                 unsigned int origCharCode,
                                                 unsigned int origCharSet,
                                                 unsigned int keyboardType,
                                                 bool repeat,
                                                 AbsoluteTime ts,
                                                 OSObject* sender,
                                                 void* refcon) {
  GlobalLock::ScopedLock lk;
  if (!lk) return;

  Params_KeyboardEventCallBack::log(true, EventType(eventType), Flags(flags), KeyCode(key), KeyboardType(keyboardType), repeat);

  // ------------------------------------------------------------
  // Ignore unknown modifiers
  //
  // You can confirm an unknown modifier by setting key code to 255 on Seil.
  // This event also will be sent by Fn key on Leopold FC660M.
  //
  //   KeyboardEventCallback [ caught]: eventType 12, flags 0x80000000, key 0x00ff, kbdType  43, repeat = 0
  //
  // This key sends the same event at key pressing and key releasing.
  // Therefore, we cannot recognize whether key is pressed or key is released.
  // So, we have to ignore this key for PressingPhysicalKeys.
  //
  if (EventType::MODIFY == EventType(eventType)) {
    if (KeyCode(key).getModifierFlag() == ModifierFlag::ZERO) {
      IOLOG_DEBUG("An unknown modifier is pressed (KeyCode:0x%x, Flags:0x%x). Ignore it.\n", key, flags);
      return;
    }
  }

  // ------------------------------------------------------------
  KeyboardType newkeyboardtype(keyboardType);
  RemapClassManager::remap_setkeyboardtype(newkeyboardtype);

  KeyCode newkey(key);
  Flags newflags(flags);
  KeyCode::normalizeKey(newkey, newflags, EventType(eventType), newkeyboardtype);

  // ------------------------------------------------------------
  Params_KeyboardEventCallBack params(EventType(eventType),
                                      newflags,
                                      newkey,
                                      CharCode(charCode),
                                      CharSet(charSet),
                                      OrigCharCode(origCharCode),
                                      OrigCharSet(origCharSet),
                                      newkeyboardtype,
                                      repeat);

  // ------------------------------------------------------------
  IOHIKeyboard* device = OSDynamicCast(IOHIKeyboard, sender);
  if (!device) return;

  ListHookedKeyboard::Item* item = static_cast<ListHookedKeyboard::Item*>(ListHookedKeyboard::instance().get(device));
  if (!item) return;

  // ------------------------------------------------------------
  // Device Hacks

  // Drop events if "Disable an internal keyboard while external keyboards are connected" is enabled.
  if (Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_disable_internal_keyboard_if_external_keyboard_exsits)) {
    if (item->isInternalDevice() &&
        ListHookedKeyboard::instance().isExternalDevicesConnected()) {
      return;
    }
  }

  // Logitech Cordless Presenter (LCP) Hack
  //
  // When an LCP is first plugged in, it will send a CONTROL_L down event
  // when the first pageup/pagedown key is pressed without sending a corresponding
  // up event -- effectively rendering the device (and the Mac) useless until it is
  // unplugged from the system.
  //
  // Similarly, when the volume keys are first pressed, a SHIFT_L down event
  // is generated, with now up event.
  //
  // This code effectively throws these events away if they are received from an LCP.
  //
  // *** LCP has 6 keys (Page Up, Page Down, a 'B' key, an 'Esc' key, and volume up / down keys). ***
  // *** So, we can drop CONTROL_L and SHIFT_L without a problem. ***
  if ((item->getDeviceIdentifier()).isEqualVendorProduct(DeviceVendor::LOGITECH, DeviceProduct::LOGITECH_CORDLESS_PRESENTER)) {
    if (params.key == KeyCode::CONTROL_L) return;
    if (params.key == KeyCode::SHIFT_L) return;
  }

  // ------------------------------------------------------------
  // NumLock Hacks
  //
  // As for some keypads, NumLock is off when it was connected.
  // We need to call setAlphaLock(true) to activate a device.
  RemapClassManager::remap_forcenumlockon(item);

  // ------------------------------------------------------------
  CommonData::setcurrent_ts(ts);

  // ------------------------------------------------------------
  // Because we handle the key repeat ourself, drop the key repeat by hardware.
  if (repeat) return;

  // ------------------------------------------------------------
  bool retainFlagStatusTemporaryCount = false;
  bool push_back = true;
  bool isSimultaneousKeyPressesTarget = true;
  enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier(), push_back, isSimultaneousKeyPressesTarget);

  setTimer();
}
コード例 #4
0
ファイル: strings.cpp プロジェクト: 5nw/httpserver
string part(const string &str, int &pos, const string &delim, bool empty)
{
    return part(str, pos, CharSet(delim), empty);
}
コード例 #5
0
ファイル: charset_matcher.hpp プロジェクト: AlexS2172/IVRM
 charset_matcher(CharSet const &charset = CharSet())
   : charset_(charset)
 {
 }
コード例 #6
0
  // ======================================================================
  void
  EventInputQueue::push_KeyboardEventCallback(OSObject* target,
                                              unsigned int eventType,
                                              unsigned int flags,
                                              unsigned int key,
                                              unsigned int charCode,
                                              unsigned int charSet,
                                              unsigned int origCharCode,
                                              unsigned int origCharSet,
                                              unsigned int keyboardType,
                                              bool repeat,
                                              AbsoluteTime ts,
                                              OSObject* sender,
                                              void* refcon)
  {
    IOLockWrapper::ScopedLock lk_eventlock(CommonData::getEventLock());
    if (! lk_eventlock) return;
    IOLockWrapper::ScopedLock lk(timer_.getlock());
    if (! lk) return;

    // ------------------------------------------------------------
    KeyboardType newkeyboardtype(keyboardType);
    RemapClassManager::remap_setkeyboardtype(newkeyboardtype);

    KeyCode newkey(key);
    Flags newflags(flags);
    KeyCode::normalizeKey(newkey, newflags, EventType(eventType), newkeyboardtype);

    // ------------------------------------------------------------
    Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(EventType(eventType),
                                                                                   newflags,
                                                                                   newkey,
                                                                                   CharCode(charCode),
                                                                                   CharSet(charSet),
                                                                                   OrigCharCode(origCharCode),
                                                                                   OrigCharSet(origCharSet),
                                                                                   newkeyboardtype,
                                                                                   repeat));
    if (! ptr) return;
    Params_KeyboardEventCallBack& params = *ptr;

    // ------------------------------------------------------------
    DeviceVendor deviceVendor(0);
    DeviceProduct deviceProduct(0);
    {
      IOLockWrapper::ScopedLock lk_device(ListHookedKeyboard::instance().getListLock());
      if (! lk_device) return;

      IOHIKeyboard* device = OSDynamicCast(IOHIKeyboard, sender);
      if (! device) return;

      ListHookedKeyboard::Item* item = static_cast<ListHookedKeyboard::Item*>(ListHookedKeyboard::instance().get_nolock(device));
      if (! item) return;

      // ------------------------------------------------------------
      // Logitech Cordless Presenter (LCP) Hack
      //
      // When an LCP is first plugged in, it will send a CONTROL_L down event
      // when the first pageup/pagedown key is pressed without sending a corresponding
      // up event -- effectively rendering the device (and the Mac) useless until it is
      // unplugged from the system.
      //
      // Similarly, when the volume keys are first pressed, a SHIFT_L down event
      // is generated, with now up event.
      //
      // This code effectively throws these events away if they are received from an LCP.
      //
      // *** LCP has 6 keys (Page Up, Page Down, a 'B' key, an 'Esc' key, and volume up / down keys). ***
      // *** So, we can drop CONTROL_L and SHIFT_L without a problem. ***
      if (item->isEqualVendorProduct(DeviceVendor::LOGITECH, DeviceProduct::LOGITECH_CORDLESS_PRESENTER)) {
        if (params.key == KeyCode::CONTROL_L) return;
        if (params.key == KeyCode::SHIFT_L) return;
      }

      // ------------------------------------------------------------
      // "ts & keyboardType" are not used in filters like <not>/<only>.
      // Therefore, we can set current ts and keyboardType here.
      CommonData::setcurrent_ts(ts);
      CommonData::setcurrent_keyboardType(params.keyboardType);
      deviceVendor = item->getVendor();
      deviceProduct = item->getProduct();
    }

    // ------------------------------------------------------------
    // Because we handle the key repeat ourself, drop the key repeat by hardware.
    if (repeat) return;

    // ------------------------------------------------------------
    bool retainFlagStatusTemporaryCount = false;
    bool push_back = true;
    enqueue_(params, retainFlagStatusTemporaryCount, deviceVendor, deviceProduct, push_back);

    setTimer();
  }
コード例 #7
0
	TextScanner( const Iterator& p_iterator)
		:start(p_iterator),input(p_iterator),val(0),cur(0),state(0),charset(CharSet())
	{
		for (unsigned int ii=0; ii<sizeof(buf); ii++) buf[ii] = 0;
	}
コード例 #8
0
EXPORT_C TBool CHTTPResponse::CharSet(TPtrC8& aDesc) const
    {
//	__LOG_ENTER(_L("CHTTPResponse::CharSet"));
	// Find the byte index in the header for the content type value
    TInt index = LocateField(EHttpContentType);

    TUint8 byteCode = 0;
	TInt paramByteCode = KErrNotFound;
	TInt valueByteCode1 = KErrNotFound;
	TInt charsetCode = 0;
	// Read the byte code, unless KErrNotFound was returned
	if (index != KErrNotFound)
		{
		TPtr8 respChars = iResponse->Des();
		TInt respLength = iResponse->Length();

		// If the byteCode is in the range 0-30 then a range of bytes is
		// indicated: the following byte gives the content type and the
		// remainder are arranged as a series of parameter attribute-value
		// pairs. This method checks for the presence of a 'charset' parameter.
		byteCode = respChars[index];
//		__LOG1(_L("CHTTPResponse::CharSet : found bytecode = %d"), byteCode);

		// Check valid range ... note that a range of zero could not contain a charset
		// parameter anyway, so exclude it...
		if ((byteCode > 0) && (byteCode <= 30))
			{
			// Check for overrun... if this occurs it should be an error.  Note that
			// corruption _could_ occur in this response buffer - some gateways, which
			// don't return error decks (e.g. AnyTime GW) send a response buffer 1 byte
			// long, containing only the value 0x01 - which is invalid WSP.
			// Be conservative and safe here - we can't overrun.  Use the value of byte-
			// -Code (which should be the WSP encoding of how many bytes follow), or the
			// total length of the response - whichever is smaller.
			if (index + byteCode < respLength)
				{
				// e,g, header to illustrate use of offsets in this code:
				// 03 94 81 84 : Content-Type: application/vnd.wap.wmlc; charset=iso-8859-1
				// +0 +1 +2 +3 : 03 = no. bytes in Content-Type header
				//			   : 94 = 14 | 80 = application/vnd.wap.wmlc
				//			   : 81 = 01 | 80 = Charset parameter
				//			   : 84 = 04 | 80 = iso-8859-1
				paramByteCode = respChars[index + 2];

				if ((paramByteCode & 0x7f) == EHttpCharset)
					{
					// We have a charset
					paramByteCode &= 0x7f;
					valueByteCode1 = respChars[index + 3];

					if (valueByteCode1 & 0x80)
						{
						// A short one-byte value
						charsetCode = valueByteCode1 & 0x7f;
						}
					else
						{
						// A multibyte value
						ExtractMultiOctetInteger(charsetCode, 
												 respChars.Mid(index + 3));
						}
					}
				}
			else
				{
				index = KErrNotFound;
				}
			}
		}

	// If a parameter-value pair was found, determine whether it encodes a
	// charset
	if ( (index != KErrNotFound) && (paramByteCode == EHttpCharset) )
		{
		// Look up the value from the charset table.
		const TText8* chset;
		chset = CharSet(charsetCode);

		// Convert the charset string to the supplied descriptor
		if (chset)
			aDesc.Set(TPtrC8(chset));
		else
			index = KErrNotFound; // We've found a charset but we don't recognise it
		}
	else	// Either no content-type header (hence no charset) or a content-type
			// header with a parameter other than charset
		{
		index = KErrNotFound;
		}

//	__LOG1(_L("CHTTPResponse::CharSet : CharSet = %S"), &aDesc);
//	__LOG_RETURN;
	return (index !=KErrNotFound);
    }