// getCode retrieves the next code using the provided
// huffman tree. It sets f.err on error.
2365
func (f *decompressor) getCode(h *huffman) uint16 {
	if h.maxbits > 0 {
		if f.nbits < maxTreePathLen {
			f.feed()
		}

		// For codes with length < tablebits, it doesn't matter
		// what the remainder of the bits used for table lookup
		// are, since entries with all possible suffixes were
		// added to the table.
		c := h.table[f.c>>(32-tablebits)]
		if c >= 1<<lenshift {
			// The code is already in c.
		} else {
			c = h.extra[c][f.c<<tablebits>>(32-(h.maxbits-tablebits))]
		}

		n := byte(c >> lenshift)
		if f.nbits >= n {
			// Only consume the length of the code, not the maximum
			// code length.
			f.c <<= n
			f.nbits -= n
			return c & codemask
		}

		f.fail(io.ErrUnexpectedEOF)
		return 0
	}

	// This is an empty tree. It should not be used.
	f.fail(errCorrupt)
	return 0
}
386164
func (v *KeyValue_SetValue_Args) GetKey() (o string) {
	if v != nil && v.Key != nil {
		return *v.Key
	}

	return
}
33210
func (service *Service) GetSmsCode(w http.ResponseWriter, request *http.Request) {
	phoneLabel := mux.Vars(request)["phoneLabel"]

	values := struct {
		LangKey string `json:"langkey"`
	}{}
	if err := json.NewDecoder(request.Body).Decode(&values); err != nil {
		log.Debug("Error decoding the GetSmsCode langkey request:", err)
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}

	loginSession, err := service.GetSession(request, SessionLogin, "loginsession")
	if err != nil {
		log.Error("Error getting login session", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}
	sessionInfo, err := newLoginSessionInformation()
	if err != nil {
		log.Error("Error creating login session information", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}
	username, ok := loginSession.Values["username"].(string)
	if username == "" || !ok {
		http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
		return
	}
	userMgr := user.NewManager(request)
	userFromDB, err := userMgr.GetByName(username)
	if err != nil {
		log.Error("Error getting user", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}
	phoneNumber, err := userFromDB.GetPhonenumberByLabel(phoneLabel)
	if err != nil {
		log.Debug(userFromDB.Phonenumbers)
		http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
		return
	}
	loginSession.Values["sessionkey"] = sessionInfo.SessionKey
	authClientId := loginSession.Values["auth_client_id"]
	authenticatingOrganization := ""
	if authClientId != nil {
		authenticatingOrganization = authClientId.(string)
	}
	mgoCollection := db.GetCollection(db.GetDBSession(request), mongoLoginCollectionName)
	mgoCollection.Insert(sessionInfo)

	link := fmt.Sprintf("https://%s/sc?c=%s&k=%s&l=%s", request.Host, sessionInfo.SMSCode, url.QueryEscape(sessionInfo.SessionKey), values.LangKey)
	translationValues := make(tools.TranslationValues)
	if authenticatingOrganization != "" {
		split := strings.Split(authenticatingOrganization, ".")
		translationValues["authorizeorganizationsms"] = struct {
			Organization string
			Code         string
			Link         string
		}{
			Organization: split[len(split)-1],
			Code:         sessionInfo.SMSCode,
			Link:         link,
		}
	} else {
		translationValues["signinsms"] = struct {
			Code string
			Link string
		}{
			Code: sessionInfo.SMSCode,
			Link: link,
		}
	}

	translations, err := tools.ParseTranslations(values.LangKey, translationValues)
	if err != nil {
		log.Error("Failed to parse translations: ", err)
		return
	}

	smsmessage := ""
	if authenticatingOrganization != "" {
		smsmessage = translations["authorizeorganizationsms"]
	} else {
		smsmessage = translations["signinsms"]
	}

	sessions.Save(request, w)
	go service.smsService.Send(phoneNumber.Phonenumber, smsmessage)
	w.WriteHeader(http.StatusNoContent)
}
646646
func (err *gojoyentError) code() Code {
	if err.errcode != UnknownErrorError {
		return err.errcode
	}
	if e, ok := err.cause.(*gojoyentError); ok {
		return e.code()
	}
	return UnknownErrorError
}
247489
func (s *Status) Code() codes.Code {
	if s == nil || s.s == nil {
		return codes.OK
	}
	return codes.Code(s.s.Code)
}
330458
func (v *Xception2) GetErrorCode() (o int32) {
	if v != nil && v.ErrorCode != nil {
		return *v.ErrorCode
	}

	return
}
853901
func (c *CodeStore) GetAirlineByCode(code string) (*Airline, error) {
	return getAirlineByKey(c.CodeToAirline, code)
}
337688
func (cpcode *CpCode) GetCpCode() error {
	req, err := client.NewRequest(
		Config,
		"GET",
		fmt.Sprintf(
			"/papi/v1/cpcodes/%s?contractId=%s&groupId=%s",
			cpcode.CpcodeID,
			cpcode.parent.Contract.ContractID,
			cpcode.parent.Group.GroupID,
		),
		nil,
	)
	if err != nil {
		return err
	}

	res, err := client.Do(Config, req)

	if client.IsError(res) {
		return client.NewAPIError(res)
	}

	newCpcodes := NewCpCodes(nil, nil)
	if err = client.BodyJSON(res, newCpcodes); err != nil {
		return err
	}
	if len(newCpcodes.CpCodes.Items) == 0 {
		return fmt.Errorf("CP Code \"%s\" not found", cpcode.CpcodeID)
	}

	cpcode.CpcodeID = newCpcodes.CpCodes.Items[0].CpcodeID
	cpcode.CpcodeName = newCpcodes.CpCodes.Items[0].CpcodeName
	cpcode.ProductID = newCpcodes.CpCodes.Items[0].ProductID
	cpcode.ProductIDs = newCpcodes.CpCodes.Items[0].ProductIDs
	cpcode.CreatedDate = newCpcodes.CpCodes.Items[0].CreatedDate

	cpcode.parent.AddCpCode(cpcode)

	return nil
}
504094
func Coded(code int32, msg string, detail ...string) *CodedError {
	e := &CodedError{
		Code:    code,
		Message: msg,
	}
	if len(detail) > 0 {
		e.Detail = detail[0]
	}
	return e
}
605352
func GetErrorCodeGroup(name string) []ErrorDescriptor {
	desc := groupToDescriptors[name]
	sort.Sort(byValue(desc))
	return desc
}
1025494
func GetStatusCode(o dhcp6.Options) (*StatusCode, error) {
	v, err := o.GetOne(dhcp6.OptionStatusCode)
	if err != nil {
		return nil, err
	}

	s := new(StatusCode)
	err = s.UnmarshalBinary(v)
	return s, err
}
1092372
func getError(r *http.Response, req *http.Request) error {
	if c := r.StatusCode; 200 <= c && c <= 299 {
		return nil
	}

	errorResponse := &ErrorResponse{Response: r}
	data, err := ioutil.ReadAll(r.Body)
	if err == nil && data != nil {
		json.Unmarshal(data, errorResponse)
	}
	errorResponse.Status = r.Status
	errorResponse.StatusCode = r.StatusCode
	errorResponse.Request = req

	switch r.StatusCode {
	case http.StatusBadRequest:
		return &ErrBadRequest{ErrorResponse: errorResponse}
	case http.StatusUnauthorized:
		return &ErrUnauthorized{ErrorResponse: errorResponse}
	case http.StatusServiceUnavailable:
		return &ErrTemporarilyUnavailable{ErrorResponse: errorResponse}
	case http.StatusNotFound:
		return &ErrNotFound{ErrorResponse: errorResponse}
	case http.StatusGone:
		return &ErrDeleted{ErrorResponse: errorResponse}
	default:
		return &ErrUnexpected{ErrorResponse: errorResponse}
	}
}
598690
func goCode(b []byte, f *ast.File) []byte {
	furthestPos := f.Name.End()
	for _, node := range f.Imports {
		if pos := node.End(); pos > furthestPos {
			furthestPos = pos
		}
	}
	if furthestPos < token.Pos(len(b)) {
		furthestPos++

		// Avoid wrong output on windows-encoded files
		if b[furthestPos-2] == '\r' && b[furthestPos-1] == '\n' && furthestPos < token.Pos(len(b)) {
			furthestPos++
		}
	}
	return b[furthestPos:]
}
1069198
func getAPIError(code APIErrorCode) APIError {
	if apiErr, ok := errorCodes[code]; ok {
		return apiErr
	}
	return errorCodes.ToAPIErr(ErrInternalError)
}
839159
func (d *Context) GetErrorCode(index int) int {
	code := int(C.duk_get_error_code(d.duk_context, C.duk_idx_t(index)))
	return code
}
238691
func (w *Waiter) GoCode() string {
	var buf bytes.Buffer
	if err := waiterTmpls.ExecuteTemplate(&buf, "waiter", w); err != nil {
		panic(err)
	}

	return buf.String()
}
897386
func (err *Error) Get(k byte) (v string) {
	switch k {
	case 'S':
		return err.Severity
	case 'C':
		return string(err.Code)
	case 'M':
		return err.Message
	case 'D':
		return err.Detail
	case 'H':
		return err.Hint
	case 'P':
		return err.Position
	case 'p':
		return err.InternalPosition
	case 'q':
		return err.InternalQuery
	case 'W':
		return err.Where
	case 's':
		return err.Schema
	case 't':
		return err.Table
	case 'c':
		return err.Column
	case 'd':
		return err.DataTypeName
	case 'n':
		return err.Constraint
	case 'F':
		return err.File
	case 'L':
		return err.Line
	case 'R':
		return err.Routine
	}
	return ""
}