Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/media/webrtc/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  PeerIdentity.cpp   Sprache: C

 
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 * vim: sw=2 ts=2 sts=2 expandtab
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#include "PeerIdentity.h"

#include "mozilla/DebugOnly.h"
#include "nsCOMPtr.h"
#include "nsNetUtil.h"
#include "nsNetCID.h"
#include "nsServiceManagerUtils.h"

namespace mozilla {

bool PeerIdentity::Equals(const PeerIdentity& aOther) const {
  return Equals(aOther.mPeerIdentity);
}

bool PeerIdentity::Equals(const nsAString& aOtherString) const {
  nsString user;
  GetUser(mPeerIdentity, user);
  nsString otherUser;
  GetUser(aOtherString, otherUser);
  if (user != otherUser) {
    return false;
  }

  nsString host;
  GetHost(mPeerIdentity, host);
  nsString otherHost;
  GetHost(aOtherString, otherHost);

  nsCString normHost;
  GetNormalizedHost(host, normHost);
  nsCString normOtherHost;
  GetNormalizedHost(otherHost, normOtherHost);
  return normHost == normOtherHost;
}

/* static */
void PeerIdentity::GetUser(const nsAString& aPeerIdentity, nsAString& aUser) {
  int32_t at = aPeerIdentity.FindChar('@');
  if (at >= 0) {
    aUser = Substring(aPeerIdentity, 0, at);
  } else {
    aUser.Truncate();
  }
}

/* static */
void PeerIdentity::GetHost(const nsAString& aPeerIdentity, nsAString& aHost) {
  int32_t at = aPeerIdentity.FindChar('@');
  if (at >= 0) {
    aHost = Substring(aPeerIdentity, at + 1);
  } else {
    aHost = aPeerIdentity;
  }
}

/* static */
void PeerIdentity::GetNormalizedHost(const nsAString& aHost,
                                     nsACString& aNormalizedHost) {
  const nsCString chost = NS_ConvertUTF16toUTF8(aHost);
  DebugOnly<nsresult> rv = NS_DomainToASCII(chost, aNormalizedHost);
  NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
                       "Failed to convert UTF-8 host to ASCII");
}

/* namespace mozilla */

Messung V0.5
C=90 H=95 G=92

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.