// Given a keysym, find all keycodes mapped to it in the current X environment.
// keybind.Initialize MUST have been called before using this function.
324365
func keycodesGet(xu *xgbutil.XUtil, keysym xproto.Keysym) []xproto.Keycode {
	min, max := minMaxKeycodeGet(xu)
	keyMap := KeyMapGet(xu)
	if keyMap == nil {
		panic("keybind.Initialize must be called before using the keybind " +
			"package.")
	}

	var c byte
	var keycode xproto.Keycode
	keycodes := make([]xproto.Keycode, 0)
	set := make(map[xproto.Keycode]bool, 0)

	for kc := int(min); kc <= int(max); kc++ {
		keycode = xproto.Keycode(kc)
		for c = 0; c < keyMap.KeysymsPerKeycode; c++ {
			if keysym == KeysymGet(xu, keycode, c) && !set[keycode] {
				keycodes = append(keycodes, keycode)
				set[keycode] = true
			}
		}
	}
	return keycodes
}
389112
func (self *MapTypeDef) Init() *MapTypeDef {
	if self.Keys == "" {
		self.Keys = "String"
	}
	if self.Items == "" {
		self.Items = "Any"
	}
	return self
}
1248852
func (l *RWMutexD) Init() {
	if !l.initialized {
		l.wlocks = make(map[string]int64)
		l.rlocks = make(map[string]int64)
		l.signals = make(chan *lockSignal, 1000)

		go l.listner()

		l.initialized = true
	}
}
797036
func loadPrintable(keys map[rune]kb.Key, keycodeConverterMap, domKeyMap map[string][]string, layoutBuf []byte, scanCodeMap map[string][]int64) error {
	buf := extract(layoutBuf, "kPrintableCodeMap")

	matches := printableKeyRE.FindAllStringSubmatch(string(buf), -1)
	for _, m := range matches {
		domCode := m[1]

		// ignore domCodes that are duplicates of other unicode characters
		if domCode == "INTL_BACKSLASH" || domCode == "INTL_HASH" || strings.HasPrefix(domCode, "NUMPAD") {
			continue
		}

		kc, ok := keycodeConverterMap[domCode]
		if !ok {
			panic(fmt.Sprintf("could not find key %s in keycode map", domCode))
		}

		code := getCode(kc[5])
		r1, r2 := decodeRune(m[2]), decodeRune(m[3])
		addKey(keys, r1, kb.Key{
			Code:       code,
			Key:        string(r1),
			Text:       string(r1),
			Unmodified: string(r1),
			Print:      true,
		}, scanCodeMap, true)

		// shifted value is same as non-shifted, so skip
		if r2 == r1 {
			continue
		}
		// skip for duplicate keys
		if r2 == '|' && domCode != "BACKSLASH" {
			continue
		}

		addKey(keys, r2, kb.Key{
			Code:       code,
			Key:        string(r2),
			Text:       string(r2),
			Unmodified: string(r1),
			Shift:      true,
			Print:      true,
		}, scanCodeMap, true)
	}

	return nil
}
941916
func (k *KeyBindings) Less(i, j int) bool {
	return k.Bindings[i].Keys[k.seqIndex].Index() < k.Bindings[j].Keys[k.seqIndex].Index()
}
162067
func loadKeys(keys map[rune]kb.Key) error {
	// load key converter data
	keycodeConverterMap, err := loadKeycodeConverterData()
	if err != nil {
		return err
	}

	// load dom code map
	domKeyMap, err := loadDomKeyData()
	if err != nil {
		return err
	}

	// load US layout data
	layoutBuf, err := grab(domUsLayoutDataH)
	if err != nil {
		return err
	}

	// load scan code map
	scanCodeMap, err := loadScanCodes(keycodeConverterMap, domKeyMap, layoutBuf)
	if err != nil {
		return err
	}

	// process printable
	err = loadPrintable(keys, keycodeConverterMap, domKeyMap, layoutBuf, scanCodeMap)
	if err != nil {
		return err
	}

	// process non-printable
	err = loadNonPrintable(keys, keycodeConverterMap, domKeyMap, layoutBuf, scanCodeMap)
	if err != nil {
		return err
	}

	return nil
}
1210056
func (b *AESGCMBarrier) Initialized(ctx context.Context) (bool, error) {
	// Read the keyring file
	keys, err := b.backend.List(ctx, keyringPrefix)
	if err != nil {
		return false, errwrap.Wrapf("failed to check for initialization: {{err}}", err)
	}
	if strutil.StrListContains(keys, "keyring") {
		return true, nil
	}

	// Fallback, check for the old sentinel file
	out, err := b.backend.Get(ctx, barrierInitPath)
	if err != nil {
		return false, errwrap.Wrapf("failed to check for initialization: {{err}}", err)
	}
	return out != nil, nil
}
1048962
func KeyValuesMap(keyvals []interface{}) map[string]interface{} {
	length := len(keyvals) / 2
	vals := make(map[string]interface{}, length)
	for i := 0; i < 2*length; i += 2 {
		vals[StringifyKey(keyvals[i])] = keyvals[i+1]
	}
	return vals
}
841535
func KeyIsSymbol(event termbox.Event) bool {
	symbols := []rune{'!', '@', '#', '$', '%', '^', '&', '*',
		'(', ')', '-', '_', '=', '+', '[', ']', '{', '}', '|',
		';', ':', '"', '\'', ',', '<', '.', '>', '/', '?', '`', '~'}
	k := event.Ch
	for i := range symbols {
		if k == symbols[i] {
			return true
		}
	}
	return false
}
265687
func attachKeyBindCallback(xu *xgbutil.XUtil, evtype int, win xproto.Window,
	mods uint16, keycode xproto.Keycode, fun xgbutil.CallbackKey) {

	xu.KeybindsLck.Lock()
	defer xu.KeybindsLck.Unlock()

	// Create key
	key := xgbutil.KeyKey{evtype, win, mods, keycode}

	// Do we need to allocate?
	if _, ok := xu.Keybinds[key]; !ok {
		xu.Keybinds[key] = make([]xgbutil.CallbackKey, 0)
	}

	xu.Keybinds[key] = append(xu.Keybinds[key], fun)
	xu.Keygrabs[key] += 1
}
365712
func init() {
	if os.Getenv("SEC51_KEYPATH") != "" {
		keyPath = os.Getenv("SEC51_KEYPATH")
	} else {
		keyPath = "keys"
	}

	keysFolderPrefixFormat = filepath.Join(keyPath, "%s")
	testKeysFolderPrefixFormat = filepath.Join(testKeyPath, "%s")
	if err := createBaseKeyFolder(keyPath); err != nil {
		log.Println(err)
	}
}
1200703
func getKeys(info map[string]interface{}, keysSet map[string]bool) {
	for k, v := range info {
		if strings.Contains(k, "*") {
			kew := strings.Replace(k, "*", "", 1)
			keysSet[kew] = true
		}

		listofouts, ok := v.([]interface{})
		if ok {
			for i := range listofouts {
				aux, ok := listofouts[i].(map[string]interface{})
				if !ok {
					continue
				}
				getKeys(aux, keysSet)
			}
		}

		if aux, ok := v.(map[string]interface{}); ok {
			getKeys(aux, keysSet)
		}
	}
}
412024
func Keys(m interface{}) []string {
	var list []string

	v := reflect.ValueOf(m)
	if v.Kind() == reflect.Map {
		for _, x := range v.MapKeys() {
			list = append(list, fmt.Sprintf("%s", x))
		}
	}

	return list
}
818702
func (s *SharedStore) keyPath(key NamedKey) string {
	// WARNING - STABLE API: The composition of the absolute key path
	// cannot be changed without breaking up and downgrades.
	return path.Join(s.conf.Prefix, key.GetKeyName())
}
738051
func MapKeys(m interface{}) []interface{} {
	keys := make([]interface{}, 0, 16)
	mapVal := reflect.ValueOf(m)
	for _, kv := range mapVal.MapKeys() {
		keys = append(keys, kv.Interface())
	}
	return keys
}
123666
func (api *PublicWhisperAPI) AddSymKey(ctx context.Context, key hexutil.Bytes) (string, error) {
	return api.w.AddSymKeyDirect([]byte(key))
}
1166767
func KeyMapSet(xu *xgbutil.XUtil, keyMapReply *xproto.GetKeyboardMappingReply) {
	xu.Keymap = &xgbutil.KeyboardMapping{keyMapReply}
}