// Masks handles a request for multiple QR masks.
979144
func Masks(w http.ResponseWriter, req *http.Request) {
	arg := func(s string) int { x, _ := strconv.Atoi(req.FormValue(s)); return x }
	v := arg("v")
	scale := arg("scale")
	if scale == 0 {
		scale = 8
	}
	font := req.FormValue("font")
	pt := arg("pt")
	var mm []image.Image
	for m := 0; m < 8; m++ {
		mm = append(mm, makeMask(req, font, pt, v, m, scale))
	}
	dx := mm[0].Bounds().Dx()
	dy := mm[0].Bounds().Dy()

	sep := arg("sep")
	if sep == 0 {
		sep = 10
	}
	c := image.NewRGBA(image.Rect(0, 0, (dx+sep)*4-sep, (dy+sep)*2-sep))
	for m := 0; m < 8; m++ {
		x := (m % 4) * (dx + sep)
		y := (m / 4) * (dy + sep)
		draw.Draw(c, c.Bounds().Add(image.Pt(x, y)), mm[m], image.ZP, draw.Src)
	}

	w.Header().Set("Cache-Control", "public, max-age=3600")
	w.Write(pngEncode(c))
}
28283
func (ctx *Context) ParamEscape(key string, defaults ...string) string {
	return ctx.Params().MustEscape(key, defaults...)
}
160602
func RequestHeaders(c context.Context) (*taskqueue.RequestHeaders, error) {
	if hdr, ok := c.Value(&requestHeadersKey).(*taskqueue.RequestHeaders); ok {
		return hdr, nil
	}
	return nil, errOutsideHandler
}
610690
func (ctx *Context) FormEscape(key string, defaults ...string) string {
	return (*Forms)(ctx.req).MustEscape(key, defaults...)
}
832175
func (tap TunnelAttrsPresence) mask() (res TunnelAttrs) {
	if tap.TunnelId {
		res.TunnelId = [8]byte{
			0xff, 0xff, 0xff, 0xff,
			0xff, 0xff, 0xff, 0xff,
		}
	}

	if tap.Ipv4Src {
		res.Ipv4Src = [4]byte{0xff, 0xff, 0xff, 0xff}
	}

	if tap.Ipv4Dst {
		res.Ipv4Dst = [4]byte{0xff, 0xff, 0xff, 0xff}
	}

	if tap.Tos {
		res.Tos = 0xff
	}

	if tap.Ttl {
		res.Ttl = 0xff
	}

	res.Df = tap.Df
	res.Csum = tap.Csum

	if tap.TpSrc {
		res.TpSrc = 0xffff
	}

	if tap.TpDst {
		res.TpDst = 0xffff
	}

	return
}
347981
func CamelCaseFieldMask(mask *field_mask.FieldMask) {
	if mask == nil || mask.Paths == nil {
		return
	}

	var newPaths []string
	for _, path := range mask.Paths {
		lowerCasedParts := strings.Split(path, ".")
		var camelCasedParts []string
		for _, part := range lowerCasedParts {
			camelCasedParts = append(camelCasedParts, generator.CamelCase(part))
		}
		newPaths = append(newPaths, strings.Join(camelCasedParts, "."))
	}

	mask.Paths = newPaths
}
661277
func (o OATH) QR(t Type, label string) ([]byte, error) {
	u := o.URL(t, label)
	code, err := qr.Encode(u, qr.Q)
	if err != nil {
		return nil, err
	}
	return code.PNG(), nil
}
1334020
func (q *Query) ApplyFilters(objects Objects) Objects {
	for _, f := range q.Filters {
		objects = f(objects)
	}
	return objects
}
129758
func Compresses(exts []string) HandlerFunc {
	extsmap := make(map[string]bool)
	for _, ext := range exts {
		extsmap[strings.ToLower(ext)] = true
	}

	return func(ctx *Context) {
		ae := ctx.Req().Header.Get("Accept-Encoding")
		if ae == "" {
			ctx.Next()
			return
		}

		if len(extsmap) > 0 {
			ext := strings.ToLower(path.Ext(ctx.Req().URL.Path))
			if _, ok := extsmap[ext]; ok {
				compress(ctx, "auto")
				return
			}
		}

		if action := ctx.Action(); action != nil {
			if c, ok := action.(Compresser); ok {
				compress(ctx, c.CompressType())
				return
			}
		}

		// if blank, then no compress
		ctx.Next()
	}
}
118360
func (l *locksFlags) Filters() (map[string]string, error) {
	filters := make(map[string]string)

	if l.Path != "" {
		path, err := lockPath(l.Path)
		if err != nil {
			return nil, err
		}

		filters["path"] = path
	}
	if l.Id != "" {
		filters["id"] = l.Id
	}

	return filters, nil
}
257687
func (addr DevAddr) Mask(bits int) (masked DevAddr) {
	return empty.WithPrefix(DevAddrPrefix{addr, bits})
}
888411
func MasksToPixelFormatEnum(bpp int, rmask, gmask, bmask, amask uint32) uint {
	return uint(C.SDL_MasksToPixelFormatEnum(C.int(bpp), C.Uint32(rmask), C.Uint32(gmask),
		C.Uint32(bmask), C.Uint32(amask)))
}
442911
func (v qrCodeVersion) formatInfo(maskPattern int) *bitset.Bitset {
	formatID := 0

	switch v.level {
	case Low:
		formatID = 0x08 // 0b01000
	case Medium:
		formatID = 0x00 // 0b00000
	case High:
		formatID = 0x18 // 0b11000
	case Highest:
		formatID = 0x10 // 0b10000
	default:
		log.Panicf("Invalid level %d", v.level)
	}

	if maskPattern < 0 || maskPattern > 7 {
		log.Panicf("Invalid maskPattern %d", maskPattern)
	}

	formatID |= maskPattern & 0x7

	result := bitset.New()

	result.AppendUint32(formatBitSequence[formatID].regular, formatInfoLengthBits)

	return result
}
187897
func MaskToRegex(rawMask string) (*regexp.Regexp, error) {
	input := bytes.NewBufferString(rawMask)

	output := &bytes.Buffer{}
	output.WriteByte('^')

	for {
		c, err := input.ReadByte()
		if err != nil {
			break
		}

		if c == '\\' {
			c, err = input.ReadByte()
			if err != nil {
				output.WriteString(regexp.QuoteMeta("\\"))
				break
			}

			if c == '?' || c == '*' || c == '\\' {
				output.WriteString(regexp.QuoteMeta(string(c)))
			} else {
				output.WriteString(regexp.QuoteMeta("\\" + string(c)))
			}
		} else if trans, ok := maskTranslations[c]; ok {
			output.WriteString(trans)
		} else {
			output.WriteString(regexp.QuoteMeta(string(c)))
		}
	}

	output.WriteByte('$')

	return regexp.Compile(output.String())
}
1095647
func QueryEscape(params map[string]string, buf *bytes.Buffer) ([]byte, bool) {
	s, b := Query(params, buf)
	if len(s) == 0 {
		return nil, b
	}

	return []byte(url.QueryEscape(string(s))), false // TODO: remove bytes convert
}
191772
func MaskFromFlags(flags ...Flag) Mask {
	var mask Mask
	for _, flag := range flags {
		mask |= Mask(flag)
	}

	return mask
}
876115
func (r *Request) Params(p *Params) *Request {
	for k, v := range p.LabelSelector {
		r.params.Add("labelSelectors", k+"="+v)
	}

	return r
}