// Returns a nick for the nick n, if we're tracking it.
969911
func (st *stateTracker) GetNick(n string) *Nick {
	st.mu.Lock()
	defer st.mu.Unlock()
	if nk, ok := st.nicks[n]; ok {
		return nk.Nick()
	}
	return nil
}
420214
func (ens *NetpluginNameServer) NsLookup(nsq []byte, vrfPtr *string) ([]byte, error) {
	tenant := *vrfPtr
	req := new(dns.Msg)
	err := req.Unpack(nsq)
	if err != nil {
		ens.incTenantStats(tenant, "invalidQuery")
		return nil, err
	}

	// no fancy requests
	if req.Response {
		ens.incTenantStats(tenant, "invalidQuery")
		return nil, errors.New("")
	}

	if req.IsTsig() != nil {
		ens.incTenantStats(tenant, "invalidQuery")
		return nil, errors.New("")
	}

	d, err := ens.serveNameRecord(tenant, req)
	if err != nil {
		logrus.Infof("no name record: %s", err)
		ens.incTenantStats(tenant, "noNameRecord")
		return nil, err
	}

	ens.incTenantStats(tenant, "foundNameRecord")
	return d, err

}
659480
func (nm *NickMode) Copy() *NickMode {
	if nm == nil {
		return nil
	}
	n := *nm
	return &n
}
458210
func (st *stateTracker) IsOn(c, n string) (*ChanPrivs, bool) {
	st.mu.Lock()
	defer st.mu.Unlock()
	nk, nok := st.nicks[n]
	ch, cok := st.chans[c]
	if nok && cok {
		return nk.isOn(ch)
	}
	return nil, false
}
1104075
func (r Utility_Network) NsLookup(address *string, typ *string) (resp string, err error) {
	params := []interface{}{
		address,
		typ,
	}
	err = r.Session.DoRequest("SoftLayer_Utility_Network", "nsLookup", params, &r.Options, &resp)
	return
}
236465
func newNick(n string) *nick {
	return &nick{
		nick:   n,
		modes:  new(NickMode),
		chans:  make(map[*channel]*ChanPrivs),
		lookup: make(map[string]*channel),
	}
}
614850
func (mg *MailgunImpl) GetDomainTracking(ctx context.Context, domain string) (DomainTracking, error) {
	r := newHTTPRequest(generatePublicApiUrl(mg, domainsEndpoint) + "/" + domain + "/tracking")
	r.setClient(mg.Client())
	r.setBasicAuth(basicAuthUser, mg.APIKey())
	var resp domainTrackingResponse
	err := getResponseFromJSON(ctx, r, &resp)
	return resp.Tracking, err
}
1047990
func (po *Po) GetNC(str, plural string, n int, ctx string, vars ...interface{}) string {
	// Sync read
	po.RLock()
	defer po.RUnlock()

	if po.contexts != nil {
		if _, ok := po.contexts[ctx]; ok {
			if po.contexts[ctx] != nil {
				if _, ok := po.contexts[ctx][str]; ok {
					return Printf(po.contexts[ctx][str].GetN(po.pluralForm(n)), vars...)
				}
			}
		}
	}

	if n == 1 {
		return Printf(str, vars...)
	}
	return Printf(plural, vars...)
}
1232811
func (daemon *Daemon) GetNetworksByIDPrefix(partialID string) []libnetwork.Network {
	c := daemon.netController
	if c == nil {
		return nil
	}
	list := []libnetwork.Network{}
	l := func(nw libnetwork.Network) bool {
		if strings.HasPrefix(nw.ID(), partialID) {
			list = append(list, nw)
		}
		return false
	}
	c.WalkNetworks(l)

	return list
}
748660
func (nk *Nick) IsOn(ch string) (*ChanPrivs, bool) {
	cp, ok := nk.Channels[ch]
	return cp, ok
}
483753
func (ch *channel) addNick(nk *nick, cp *ChanPrivs) {
	if _, ok := ch.nicks[nk]; !ok {
		ch.nicks[nk] = cp
		ch.lookup[nk.nick] = nk
	} else {
		logging.Warn("Channel.addNick(): %s already on %s.", nk.nick, ch.name)
	}
}
1086054
func (c *httpClient) getNoFollow(url string) (*http.Response, error) {
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		return nil, err
	}
	for k, vs := range c.header {
		req.Header[k] = vs
	}
	t := c.client.Transport
	if t == nil {
		t = http.DefaultTransport
	}
	resp, err := t.RoundTrip(req)
	if err != nil {
		return nil, &RemoteError{req.URL.Host, err}
	}
	return resp, err
}
632624
func (nm *NickMode) String() string {
	if nm == nil {
		return "No modes set"
	}
	str := "+"
	v := reflect.Indirect(reflect.ValueOf(nm))
	t := v.Type()
	for i := 0; i < v.NumField(); i++ {
		switch f := v.Field(i); f.Kind() {
		// only bools here at the mo!
		case reflect.Bool:
			if f.Bool() {
				str += NickModeToString[t.Field(i).Name]
			}
		}
	}
	if str == "+" {
		str = "No modes set"
	}
	return str
}
1155212
func (h *Handle) GetNetNsIdByFd(fd int) (int, error) {
	return h.getNetNsId(NETNSA_FD, uint32(fd))
}
399838
func (s *NetworkService) GetNetworkByName(name string, opts ...OptionFunc) (*Network, int, error) {
	id, count, err := s.GetNetworkID(name, opts...)
	if err != nil {
		return nil, count, err
	}

	r, count, err := s.GetNetworkByID(id, opts...)
	if err != nil {
		return nil, count, err
	}
	return r, count, nil
}
584043
func (conn *Conn) Me() *state.Nick {
	if conn.st != nil {
		conn.cfg.Me = conn.st.Me()
	}
	return conn.cfg.Me
}
1317603
func (t *nfcTrie) lookup(s []byte) (v uint16, sz int) {
	c0 := s[0]
	switch {
	case c0 < 0x80: // is ASCII
		return nfcValues[c0], 1
	case c0 < 0xC0:
		return 0, 1 // Illegal UTF-8: not a starter, not ASCII.
	case c0 < 0xE0: // 2-byte UTF-8
		if len(s) < 2 {
			return 0, 0
		}
		i := nfcIndex[c0]
		c1 := s[1]
		if c1 < 0x80 || 0xC0 <= c1 {
			return 0, 1 // Illegal UTF-8: not a continuation byte.
		}
		return t.lookupValue(uint32(i), c1), 2
	case c0 < 0xF0: // 3-byte UTF-8
		if len(s) < 3 {
			return 0, 0
		}
		i := nfcIndex[c0]
		c1 := s[1]
		if c1 < 0x80 || 0xC0 <= c1 {
			return 0, 1 // Illegal UTF-8: not a continuation byte.
		}
		o := uint32(i)<<6 + uint32(c1)
		i = nfcIndex[o]
		c2 := s[2]
		if c2 < 0x80 || 0xC0 <= c2 {
			return 0, 2 // Illegal UTF-8: not a continuation byte.
		}
		return t.lookupValue(uint32(i), c2), 3
	case c0 < 0xF8: // 4-byte UTF-8
		if len(s) < 4 {
			return 0, 0
		}
		i := nfcIndex[c0]
		c1 := s[1]
		if c1 < 0x80 || 0xC0 <= c1 {
			return 0, 1 // Illegal UTF-8: not a continuation byte.
		}
		o := uint32(i)<<6 + uint32(c1)
		i = nfcIndex[o]
		c2 := s[2]
		if c2 < 0x80 || 0xC0 <= c2 {
			return 0, 2 // Illegal UTF-8: not a continuation byte.
		}
		o = uint32(i)<<6 + uint32(c2)
		i = nfcIndex[o]
		c3 := s[3]
		if c3 < 0x80 || 0xC0 <= c3 {
			return 0, 3 // Illegal UTF-8: not a continuation byte.
		}
		return t.lookupValue(uint32(i), c3), 4
	}
	// Illegal rune
	return 0, 1
}