Example #1
0
static bool isTransparentSilverlightBackgroundValue(const String& lowercaseBackgroundValue)
{
    // This checks if the background color value is transparent, according to
    // the format documented at http://msdn.microsoft.com/en-us/library/cc838148(VS.95).aspx
    if (lowercaseBackgroundValue.startsWith('#')) {
        if (lowercaseBackgroundValue.length() == 5 && lowercaseBackgroundValue[1] != 'f') {
            // An 8-bit RGB value with alpha transparency, in the form #ARGB.
            return true;
        }

        if (lowercaseBackgroundValue.length() == 9 && !(lowercaseBackgroundValue[1] == 'f' && lowercaseBackgroundValue[2] == 'f')) {
            // A 16-bit RGB value with alpha transparency, in the form #AARRGGBB.
            return true;
        }
    } else if (lowercaseBackgroundValue.startsWith("sc#")) {
        Vector<String> components;
        lowercaseBackgroundValue.substring(3).split(",", components);

        // An ScRGB value with alpha transparency, in the form sc#A,R,G,B.
        if (components.size() == 4) {
            if (components[0].toDouble() < 1)
                return true;
        }
    } else if (lowercaseBackgroundValue == "transparent")
        return true;

    // This is an opaque color.
    return false;
}
Example #2
0
/*******************************************************************************
 * Function Name  : tinkerDigitalRead
 * Description    : Reads the digital value of a given pin
 * Input          : Pin
 * Output         : None.
 * Return         : Value of the pin (0 or 1) in INT type
                    Returns a negative number on failure
 *******************************************************************************/
int tinkerDigitalRead(String pin)
{
    //convert ascii to integer
    int pinNumber = pin.charAt(1) - '0';
    //Sanity check to see if the pin numbers are within limits
    if (pinNumber < 0 || pinNumber > 7) return -1;

    if(pin.startsWith("D"))
    {
        pinMode(pinNumber, INPUT_PULLDOWN);
        return digitalRead(pinNumber);
    }
    else if (pin.startsWith("A"))
    {
        pinMode(pinNumber+10, INPUT_PULLDOWN);
        return digitalRead(pinNumber+10);
    }
#if Wiring_Cellular
    else if (pin.startsWith("B"))
    {
        if (pinNumber > 5) return -3;
        pinMode(pinNumber+24, INPUT_PULLDOWN);
        return digitalRead(pinNumber+24);
    }
    else if (pin.startsWith("C"))
    {
        if (pinNumber > 5) return -4;
        pinMode(pinNumber+30, INPUT_PULLDOWN);
        return digitalRead(pinNumber+30);
    }
#endif
    return -2;
}
void JucerDocument::setParentClasses (const String& classes)
{
    if (classes != parentClasses)
    {
        StringArray parentClassLines (getCleanedStringArray (StringArray::fromTokens (classes, ",", StringRef())));

        for (int i = parentClassLines.size(); --i >= 0;)
        {
            String s (parentClassLines[i]);
            String type;

            if (s.startsWith ("public ")
                || s.startsWith ("protected ")
                || s.startsWith ("private "))
            {
                type = s.upToFirstOccurrenceOf (" ", true, false);
                s = s.fromFirstOccurrenceOf (" ", false, false);

                if (s.trim().isEmpty())
                    type = s = String::empty;
            }

            s = type + CodeHelpers::makeValidIdentifier (s.trim(), false, false, true);

            parentClassLines.set (i, s);
        }

        parentClasses = parentClassLines.joinIntoString (", ");
        changed();
    }
}
Example #4
0
  static bool canFileBeReincluded (File const& f)
  {
    String content (f.loadFileAsString());

    for (;;)
    {
      content = content.trimStart();

      if (content.startsWith ("//"))
        content = content.fromFirstOccurrenceOf ("\n", false, false);
      else if (content.startsWith ("/*"))
        content = content.fromFirstOccurrenceOf ("*/", false, false);
      else
        break;
    }

    StringArray lines;
    lines.addLines (content);
    lines.trim();
    lines.removeEmptyStrings();

    const String l1 (lines[0].removeCharacters (" \t").trim());
    const String l2 (lines[1].removeCharacters (" \t").trim());

    bool result;
    if (l1.replace ("#ifndef", "#define") == l2)
      result = false;
    else
      result = true;

    return result;
  }
Example #5
0
/*******************************************************************************
 * Function Name  : tinkerDigitalWrite
 * Description    : Sets the specified pin HIGH or LOW
 * Input          : Pin and value
 * Output         : None.
 * Return         : 1 on success and a negative number on failure
 *******************************************************************************/
int tinkerDigitalWrite(String command)
{
    bool value = 0;
    //convert ascii to integer
    int pinNumber = command.charAt(1) - '0';
    //Sanity check to see if the pin numbers are within limits
    if (pinNumber< 0 || pinNumber >7) return -1;

    if(command.substring(3,7) == "HIGH") value = 1;
    else if(command.substring(3,6) == "LOW") value = 0;
    else return -2;

    if(command.startsWith("D"))
    {
        pinMode(pinNumber, OUTPUT);
        digitalWrite(pinNumber, value);
        return 1;
    }
    else if(command.startsWith("A"))
    {
        pinMode(pinNumber+10, OUTPUT);
        digitalWrite(pinNumber+10, value);
        return 1;
    }
    else return -3;
}
Example #6
0
bool NumberLocalizer::detectSignAndGetDigitRange(const String& input, bool& isNegative, unsigned& startIndex, unsigned& endIndex)
{
    startIndex = 0;
    endIndex = input.length();
    if (m_negativePrefix.isEmpty() && m_negativeSuffix.isEmpty()) {
        if (input.startsWith(m_positivePrefix) && input.endsWith(m_positiveSuffix)) {
            isNegative = false;
            startIndex = m_positivePrefix.length();
            endIndex -= m_positiveSuffix.length();
        } else
            isNegative = true;
    } else {
        if (input.startsWith(m_negativePrefix) && input.endsWith(m_negativeSuffix)) {
            isNegative = true;
            startIndex = m_negativePrefix.length();
            endIndex -= m_negativeSuffix.length();
        } else {
            isNegative = false;
            if (input.startsWith(m_positivePrefix) && input.endsWith(m_positiveSuffix)) {
                startIndex = m_positivePrefix.length();
                endIndex -= m_positiveSuffix.length();
            } else
                return false;
        }
    }
    return true;
}
bool DOMImplementation::hasFeature(const String& feature, const String& version)
{
    String lower = feature.lower();
    if (lower == "core" || lower == "html" || lower == "xml" || lower == "xhtml")
        return version.isEmpty() || version == "1.0" || version == "2.0";
    if (lower == "css"
            || lower == "css2"
            || lower == "events"
            || lower == "htmlevents"
            || lower == "mouseevents"
            || lower == "mutationevents"
            || lower == "range"
            || lower == "stylesheets"
            || lower == "traversal"
            || lower == "uievents"
            || lower == "views")
        return version.isEmpty() || version == "2.0";
    if (lower == "xpath" || lower == "textevents")
        return version.isEmpty() || version == "3.0";

#if ENABLE(SVG)
    if ((version.isEmpty() || version == "1.1") && feature.startsWith("http://www.w3.org/tr/svg11/feature#", false)) {
        if (isSVG11Feature(feature.right(feature.length() - 35)))
            return true;
    }

    if ((version.isEmpty() || version == "1.0") && feature.startsWith("org.w3c.", false)) {
        if (isSVG10Feature(feature.right(feature.length() - 8)))
            return true;
    }
#endif
    
    return false;
}
static bool TreatAsAttachment(const String& content_disposition) {
    // Some broken sites just send
    // Content-Disposition: ; filename="file"
    // screen those out here.
    if (content_disposition.startsWith(";"))
        return false;

    if (content_disposition.startsWith("inline", false))
        return false;

    // Some broken sites just send
    // Content-Disposition: filename="file"
    // without a disposition token... screen those out.
    if (content_disposition.startsWith("filename", false))
        return false;

    // Also in use is Content-Disposition: name="file"
    if (content_disposition.startsWith("name", false))
        return false;

    // We have a content-disposition of "attachment" or unknown.
    // RFC 2183, section 2.8 says that an unknown disposition
    // value should be treated as "attachment"
    return true;
}
bool MIMETypeRegistry::isJavaAppletMIMEType(const String& mimeType)
{
    // Since this set is very limited and is likely to remain so we won't bother with the overhead
    // of using a hash set.
    // Any of the MIME types below may be followed by any number of specific versions of the JVM,
    // which is why we use startsWith()
    return mimeType.startsWith("application/x-java-applet", false)
        || mimeType.startsWith("application/x-java-bean", false)
        || mimeType.startsWith("application/x-java-vm", false);
}
Example #10
0
void parseHttp() {
  String line = Serial.readStringUntil('\n');
  if (line.startsWith("Content-Length: ")) {
    sscanf(line.c_str() + 16, "%d", &contentLength);
  } else if (line.startsWith("GET")) {
    method = GET;
    path = parsePath(line);
  } else if (line.startsWith("PUT")) {
    method = PUT;
    path = parsePath(line);
  } else if (line == "\r") {
    if (path.startsWith("/reset")) {
      sendResponse(200);
      setup();
    } else if (path.startsWith("/sensors") && method == GET) {
      getSensors();
    } else if (path.startsWith("/leds") && (method == GET)) {
      getLeds();
    } else if (path.startsWith("/leds") && (method == PUT)) {
      putLeds();
    } else if (path.startsWith("/settings") && (method == GET)) {
      getSettings();
    } else if (path.startsWith("/settings") && (method == PUT)) {
      putSettings();
    } else {
      sendResponse(404);
    }
    contentLength = 0;
  }
}
Example #11
0
bool DOMImplementation::hasFeature(const String& feature, const String& version)
{
    if (feature.startsWith("http://www.w3.org/TR/SVG", false)
        || feature.startsWith("org.w3c.dom.svg", false)
        || feature.startsWith("org.w3c.svg", false)) {
        // FIXME: SVG 2.0 support?
        return isSupportedSVG10Feature(feature, version) || isSupportedSVG11Feature(feature, version);
    }

    return true;
}
Example #12
0
bool String::filenameIsAbsolutePath(const char* szText)
{
  String sText = szText;
  return 
#if defined(WIN32)
      sText.subString(1, 1) == ":" || sText.startsWith("/") || sText.subString(0, 2) == String_FILEPATHSEPARATOR String_FILEPATHSEPARATOR
#else
      sText.startsWith(String_FILEPATHSEPARATOR);
#endif
    ;
}
Example #13
0
void SVGSVGElement::setupInitialView(const String& fragmentIdentifier, Element* anchorNode)
{
    RenderObject* renderer = this->renderer();
    SVGViewSpec* view = m_viewSpec.get();
    if (view)
        view->reset();

    bool hadUseCurrentView = m_useCurrentView;
    m_useCurrentView = false;

    if (fragmentIdentifier.startsWith("xpointer(")) {
        // FIXME: XPointer references are ignored (https://bugs.webkit.org/show_bug.cgi?id=17491)
        if (renderer && hadUseCurrentView)
            RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
        return;
    }

    if (fragmentIdentifier.startsWith("svgView(")) {
        if (!view)
            view = currentView(); // Create the SVGViewSpec.

        if (view->parseViewSpec(fragmentIdentifier))
            m_useCurrentView = true;
        else
            view->reset();

        if (renderer && (hadUseCurrentView || m_useCurrentView))
            RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
        return;
    }

    // Spec: If the SVG fragment identifier addresses a ‘view’ element within an SVG document (e.g., MyDrawing.svg#MyView
    // or MyDrawing.svg#xpointer(id('MyView'))) then the closest ancestor ‘svg’ element is displayed in the viewport.
    // Any view specification attributes included on the given ‘view’ element override the corresponding view specification
    // attributes on the closest ancestor ‘svg’ element.
    if (anchorNode && anchorNode->hasTagName(SVGNames::viewTag)) {
        if (SVGViewElement* viewElement = anchorNode->hasTagName(SVGNames::viewTag) ? static_cast<SVGViewElement*>(anchorNode) : 0) {
            SVGElement* element = SVGLocatable::nearestViewportElement(viewElement);
            if (element->hasTagName(SVGNames::svgTag)) {
                SVGSVGElement* svg = static_cast<SVGSVGElement*>(element);
                svg->inheritViewAttributes(viewElement);

                if (RenderObject* renderer = svg->renderer())
                    RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
            }
        }
        return;
    }

    // FIXME: We need to decide which <svg> to focus on, and zoom to it.
    // FIXME: We need to actually "highlight" the viewTarget(s).
}
MediaPlayer::SupportsType MediaPlayerPrivateQt::supportsType(const String& mime, const String& codec, const KURL&)
{
    if (!mime.startsWith("audio/") && !mime.startsWith("video/"))
        return MediaPlayer::IsNotSupported;

    // Parse and trim codecs.
    QString codecStr = codec;
    QStringList codecList = codecStr.split(QLatin1Char(','), QString::SkipEmptyParts);
    QStringList codecListTrimmed;
    foreach (const QString& codecStrNotTrimmed, codecList) {
        QString codecStrTrimmed = codecStrNotTrimmed.trimmed();
        if (!codecStrTrimmed.isEmpty())
            codecListTrimmed.append(codecStrTrimmed);
    }
Example #15
0
//----------------------------------------------------------------------------
// MQTT client callback, topic=<client-id>/... msg=...
//----------------------------------------------------------------------------
void ICACHE_FLASH_ATTR mqttOnPublish(String strTopic, String strMsg)
{
  tUint32 cbTopic = strTopic.length(), cbMsg = strMsg.length();

  do {
    // make sure topic starts with <client-id>
    Debug.logTxt(CLSLVL_MQTT | 0x0000, "mqttOnPublish,topic=%s,msg=%s", strTopic.c_str(), strMsg.c_str());
    if (strTopic.startsWith(AppSettings.mqttClientId + "/") == 0) {
      Debug.logTxt(CLSLVL_MQTT | 0x0010, "mqttOnPublish,not for us,dropping");
      g_mqttPktRxDropped++;
      return;
      } // if

    g_mqttPktRx++;

    // copy topic/msg to modifiable buffer on stack
    tChar szTopic[cbTopic + 1], szMsg[cbMsg + 1];
    tChar *pTopic = szTopic;
    gstrcpy(szTopic, strTopic.c_str());
    gstrcpy(szMsg, strMsg.c_str());

    // pass topic=<pfx>/<obj>... on to GPIOD
    pTopic += (AppSettings.mqttClientId.length() + 1);
    gpiodOnMqttPublish(pTopic, szMsg);
    } while (FALSE);

  } // mqttOnPublish
Example #16
0
static bool isSupportedSVG10Feature(const String& feature, const String& version)
{
    if (!version.isEmpty() && version != "1.0")
        return false;

#if !PLATFORM(WKC)
    static bool initialized = false;
#else
    WKC_DEFINE_STATIC_BOOL(initialized, false);
#endif
    DEPRECATED_DEFINE_STATIC_LOCAL(FeatureSet, svgFeatures, ());
    if (!initialized) {
#if ENABLE(SVG_FONTS)
        addString(svgFeatures, "svg");
        addString(svgFeatures, "svg.static");
#endif
//      addString(svgFeatures, "svg.animation");
//      addString(svgFeatures, "svg.dynamic");
//      addString(svgFeatures, "svg.dom.animation");
//      addString(svgFeatures, "svg.dom.dynamic");
#if ENABLE(SVG_FONTS)
        addString(svgFeatures, "dom");
        addString(svgFeatures, "dom.svg");
        addString(svgFeatures, "dom.svg.static");
#endif
//      addString(svgFeatures, "svg.all");
//      addString(svgFeatures, "dom.svg.all");
        initialized = true;
    }
    return feature.startsWith("org.w3c.", false)
        && svgFeatures.contains(feature.right(feature.length() - 8));
}
void DefaultPolicyDelegate::decidePolicyForMIMEType(
    /*[in]*/ WebView* webView, 
    /*[in]*/ String type, 
    /*[in]*/ WebMutableURLRequest* request, 
    /*[in]*/ WebFrame* /*frame*/, 
    /*[in]*/ WebFramePolicyListener* listener)
{
    bool canShowMIMEType = webView->canShowMIMEType(type);
    if (canShowMIMEType)
        canShowMIMEType = false;

    String url = request->URL();

    if (url.startsWith("file:")) {
        bool isDirectory = false;
        struct stat st;
        if (stat(url.utf8().data(), &st))
            isDirectory = S_ISDIR(st.st_mode);

        if (isDirectory)
            listener->ignore();
        else if(canShowMIMEType)
            listener->use();
        else
            listener->ignore();
    } else if (canShowMIMEType)
        listener->use();
    else
        listener->ignore();
}
void DefaultPolicyDelegate::decidePolicyForNavigationAction(WebView* webView, 
    /*[in]*/ WebActionPropertyBag* actionInformation, 
    /*[in]*/ WebMutableURLRequest* request, 
    /*[in]*/ WebFrame* /*frame*/, 
    /*[in]*/ WebFramePolicyListener* listener)
{
    int navType = 0;

    String ret = actionInformation->Read(WebActionNavigationTypeKey);
    navType = ret.toInt();

    bool canHandleRequest = webView->canHandleRequest(request);
    if (canHandleRequest)
        listener->use();
    else if (navType == WebNavigationTypePlugInRequest)
        listener->use();
    else {
        String url = request->URL();
        // A file URL shouldn't fall through to here, but if it did,
        // it would be a security risk to open it.
        if (!url.startsWith("file:")) {
            // FIXME: Open the URL not by means of a webframe, but by handing it over to the system and letting it determine how to open that particular URL scheme.  See documentation for [NSWorkspace openURL]
            ;
        }
        listener->ignore();
    }
}
Example #19
0
    void actionListenerCallback (const String& message)
    {
        JUCEApplication* const app = JUCEApplication::getInstance();

        if (app != 0 && message.startsWith (app->getApplicationName() + "/"))
            app->anotherInstanceStarted (message.substring (app->getApplicationName().length() + 1));
    }
Color::Color(const String& name)
{
    if (name.startsWith("#"))
        m_valid = parseHexColor(name.substring(1), m_color);
    else
        setNamedColor(name);
}
Example #21
0
HTMLMapElement* TreeScope::getImageMap(const String& url) const {
  if (url.isNull())
    return nullptr;
  if (!m_imageMapsByName)
    return nullptr;
  size_t hashPos = url.find('#');
  String name = hashPos == kNotFound ? url : url.substring(hashPos + 1);
  HTMLMapElement* map = toHTMLMapElement(
      rootNode().document().isHTMLDocument()
          ? m_imageMapsByName->getElementByLowercasedMapName(
                AtomicString(name.lower()), this)
          : m_imageMapsByName->getElementByMapName(AtomicString(name), this));
  if (!map || !rootNode().document().isHTMLDocument())
    return map;
  const AtomicString& nameValue = map->fastGetAttribute(nameAttr);
  if (nameValue.isNull())
    return map;
  String strippedName = nameValue;
  if (strippedName.startsWith('#'))
    strippedName = strippedName.substring(1);
  if (strippedName == name)
    UseCounter::count(rootNode().document(), UseCounter::MapNameMatchingStrict);
  else if (equalIgnoringASCIICase(strippedName, name))
    UseCounter::count(rootNode().document(),
                      UseCounter::MapNameMatchingASCIICaseless);
  else
    UseCounter::count(rootNode().document(),
                      UseCounter::MapNameMatchingUnicodeLower);
  return map;
}
Example #22
0
void FrameFactory::updateGenre(TextIdentificationFrame *frame) const
{
  StringList fields = frame->fieldList();
  StringList newfields;

  for(StringList::Iterator it = fields.begin(); it != fields.end(); ++it) {
    String s = *it;
    int end = s.find(")");

    if(s.startsWith("(") && end > 0) {
      // "(12)Genre"
      String text = s.substr(end + 1);
      bool ok;
      int number = s.substr(1, end - 1).toInt(&ok);
      if(ok && number >= 0 && number <= 255 && !(ID3v1::genre(number) == text))
        newfields.append(s.substr(1, end - 1));
      if(!text.isEmpty())
        newfields.append(text);
    }
    else {
      // "Genre" or "12"
      newfields.append(s);
    }
  }

  if(newfields.isEmpty())
    fields.append(String::null);

  frame->setText(newfields);

}
Example #23
0
static void removeMarkupPrefix(String& markup)
{
    // The markup prefix is not harmful, but we remove it from the string anyway, so that
    // we can have consistent results with other ports during the layout tests.
    if (markup.startsWith(gMarkupPrefix))
        markup.remove(0, gMarkupPrefix.length());
}
Example #24
0
bool ESP8266WebServer::authenticate(const char * username, const char * password){
  if(hasHeader(AUTHORIZATION_HEADER)){
    String authReq = header(AUTHORIZATION_HEADER);
    if(authReq.startsWith("Basic")){
      authReq = authReq.substring(6);
      authReq.trim();
      char toencodeLen = strlen(username)+strlen(password)+1;
      char *toencode = new char[toencodeLen + 1];
      if(toencode == NULL){
        authReq = String();
        return false;
      }
      char *encoded = new char[base64_encode_expected_len(toencodeLen)+1];
      if(encoded == NULL){
        authReq = String();
        delete[] toencode;
        return false;
      }
      sprintf(toencode, "%s:%s", username, password);
      if(base64_encode_chars(toencode, toencodeLen, encoded) > 0 && authReq.equals(encoded)){
        authReq = String();
        delete[] toencode;
        delete[] encoded;
        return true;
      }
      delete[] toencode;
      delete[] encoded;
    }
    authReq = String();
  }
  return false;
}
Example #25
0
void WTFInitializeLogChannelStatesFromString(WTFLogChannel* channels[], size_t count, const char* logLevel)
{
    String logLevelString = logLevel;
    Vector<String> components;
    logLevelString.split(',', components);

    for (size_t i = 0; i < components.size(); ++i) {
        String component = components[i];

        WTFLogChannelState logChannelState = WTFLogChannelOn;
        if (component.startsWith('-')) {
            logChannelState = WTFLogChannelOff;
            component = component.substring(1);
        }

        if (equalIgnoringCase(component, "all")) {
            setStateOfAllChannels(channels, count, logChannelState);
            continue;
        }

        if (WTFLogChannel* channel = WTFLogChannelByName(channels, count, component.utf8().data()))
            channel->state = logChannelState;
        else
            WTFLogAlways("Unknown logging channel: %s", component.utf8().data());
    }
}
Example #26
0
bool WebServer::authenticate(const char * username, const char * password)
{
  if(_autorization.length()>0)
  {
    String authReq = _autorization;
    if(authReq.startsWith("Basic")){
      authReq = authReq.substring(6);
      authReq.trim();
      char toencodeLen = strlen(username)+strlen(password)+1;
      char *toencode = new char[toencodeLen + 1];
      if(toencode == NULL){
        return false;
      }
      char *encoded = new char[base64_encode_expected_len(toencodeLen)+1];
      if(encoded == NULL){
        delete[] toencode;
        return false;
      }
      sprintf(toencode, "%s:%s", username, password);
      if(base64_encode_chars(toencode, toencodeLen, encoded) > 0 && authReq.equals(encoded)){
        delete[] toencode;
        delete[] encoded;
        return true;
      }
      delete[] toencode;
      delete[] encoded;
    }
  }
  return false;
}
Example #27
0
//==============================================================================
static File resolveXDGFolder (const char* const type, const char* const fallbackFolder)
{
    File userDirs ("~/.config/user-dirs.dirs");
    StringArray confLines;

    if (userDirs.existsAsFile())
    {
        FileInputStream in (userDirs);

        if (in.openedOk())
            confLines.addLines (in.readEntireStreamAsString());
    }

    for (int i = 0; i < confLines.size(); ++i)
    {
        const String line (confLines[i].trimStart());

        if (line.startsWith (type))
        {
            // eg. resolve XDG_MUSIC_DIR="$HOME/Music" to /home/user/Music
            const File f (line.replace ("$HOME", File ("~").getFullPathName())
                          .fromFirstOccurrenceOf ("=", false, false)
                          .trim().unquoted());

            if (f.isDirectory())
                return f;
        }
    }

    return File (fallbackFolder);
}
Example #28
0
/*******************************************************************************
 * Function Name  : tinkerAnalogRead
 * Description    : Reads the analog value of a pin
 * Input          : Pin
 * Output         : None.
 * Return         : Returns the analog value in INT type (0 to 4095)
                    Returns a negative number on failure
 *******************************************************************************/
int tinkerAnalogRead(String pin)
{
    //convert ascii to integer
    int pinNumber = pin.charAt(1) - '0';
    //Sanity check to see if the pin numbers are within limits
    if (pinNumber< 0 || pinNumber >7) return -1;

    if(pin.startsWith("D"))
    {
        return -3;
    }
    else if (pin.startsWith("A"))
    {
        return analogRead(pinNumber+10);
    }
    return -2;
}
void SVGSVGElement::setupInitialView(const String& fragmentIdentifier, Element* anchorNode)
{
    LayoutObject* layoutObject = this->layoutObject();
    SVGViewSpec* view = m_viewSpec.get();
    if (view)
        view->reset();

    bool hadUseCurrentView = m_useCurrentView;
    m_useCurrentView = false;

    if (fragmentIdentifier.startsWith("svgView(")) {
        if (!view)
            view = currentView(); // Create the SVGViewSpec.

        view->inheritViewAttributesFromElement(this);

        if (view->parseViewSpec(fragmentIdentifier)) {
            UseCounter::count(document(), UseCounter::SVGSVGElementFragmentSVGView);
            m_useCurrentView = true;
        } else {
            view->reset();
        }

        if (layoutObject && (hadUseCurrentView || m_useCurrentView))
            markForLayoutAndParentResourceInvalidation(layoutObject);
        return;
    }

    // Spec: If the SVG fragment identifier addresses a 'view' element within an SVG document (e.g., MyDrawing.svg#MyView
    // or MyDrawing.svg#xpointer(id('MyView'))) then the closest ancestor 'svg' element is displayed in the viewport.
    // Any view specification attributes included on the given 'view' element override the corresponding view specification
    // attributes on the closest ancestor 'svg' element.
    // TODO(ed): The spec text above is a bit unclear.
    // Should the transform from outermost svg to nested svg be applied to "display"
    // the inner svg in the viewport, then let the view element override the inner
    // svg's view specification attributes. Should it fill/override the outer viewport?
    if (isSVGViewElement(anchorNode)) {
        SVGViewElement& viewElement = toSVGViewElement(*anchorNode);

        if (SVGSVGElement* svg = viewElement.ownerSVGElement()) {
            svg->inheritViewAttributes(&viewElement);

            if (LayoutObject* layoutObject = svg->layoutObject())
                markForLayoutAndParentResourceInvalidation(layoutObject);

            return;
        }
    }

    // If we previously had a view and didn't get a new one, we need to
    // layout again.
    if (layoutObject && hadUseCurrentView)
        markForLayoutAndParentResourceInvalidation(layoutObject);

    // FIXME: We need to decide which <svg> to focus on, and zoom to it.
    // FIXME: We need to actually "highlight" the viewTarget(s).
}
Example #30
0
boolean TinyGSM::SMSreceived(){
	if (_serial->available()){
		_serial->setTimeout(200);
		String input = _serial->readStringUntil('"');
		input.trim();
		if (input.startsWith("+CMT:")) return true;
	}
	return false;
}