public static Map<PtyMode, Integer> resolveShellTtyOptions(Map<PtyMode, Integer> modes) { Map<PtyMode, Integer> resolved = PtyMode.createEnabledOptions(PUTTY_OPTIONS); if (GenericUtils.size(modes) > 0) { resolved.putAll(modes); // TODO consider adding only non-overriding options } return resolved; } }
/** * @param v The value to be tested * @return {@code true} if <U>all</U> of these conditions hold:</BR> * <UL> * <LI>The mapped value is a {@link Number}</LI> * <LI>The {@link Number#intValue()} is non-zero</LI> * </UL> * @see #getBooleanSettingValue(int) */ public static boolean getBooleanSettingValue(Object v) { return (v instanceof Number) && getBooleanSettingValue(((Number) v).intValue()); }
public TtyFilterOutputStream(OutputStream out, TtyFilterInputStream echo, Map<PtyMode, ?> modes) { this(out, echo, PtyMode.resolveEnabledOptions(modes, OUTPUT_OPTIONS)); }
public static Map<PtyMode, Integer> parsePtyModes(String stty) { Map<PtyMode, Integer> modes = new EnumMap<>(PtyMode.class); for (PtyMode mode : PtyMode.values()) { if (mode == PtyMode.TTY_OP_ISPEED || mode == PtyMode.TTY_OP_OSPEED) { // TODO ... continue; } else { String str = mode.name().toLowerCase(); // Are we looking for a character? if (str.charAt(0) == 'v') { str = str.substring(1); int v = findChar(stty, str); if (v < 0 && "reprint".equals(str)) { v = findChar(stty, "rprnt"); } if (v >= 0) { modes.put(mode, v); } } else { int v = findFlag(stty, str); if (v >= 0) { modes.put(mode, v); } } } } return modes; }
| ((modes[i++] << 8) & 0x0000ff00) | ((modes[i++]) & 0x000000ff); PtyMode mode = PtyMode.fromInt(opcode); if (mode == null) { log.warn("handlePtyReq({}) unsupported pty opcode value: {}={}", this, opcode, val);
modes.putByte((byte) mode.toInt()); modes.putInt(value.longValue()); });
public static Map<PtyMode, Integer> parsePtyModes(String stty) { Map<PtyMode, Integer> modes = new EnumMap<>(PtyMode.class); for (PtyMode mode : PtyMode.values()) { if (mode == PtyMode.TTY_OP_ISPEED || mode == PtyMode.TTY_OP_OSPEED) { // TODO ... continue; } else { String str = mode.name().toLowerCase(); // Are we looking for a character? if (str.charAt(0) == 'v') { str = str.substring(1); int v = findChar(stty, str); if (v < 0 && "reprint".equals(str)) { v = findChar(stty, "rprnt"); } if (v >= 0) { modes.put(mode, v); } } else { int v = findFlag(stty, str); if (v >= 0) { modes.put(mode, v); } } } } return modes; }
| ((modes[i++] << 8) & 0x0000ff00) | ((modes[i++]) & 0x000000ff); PtyMode mode = PtyMode.fromInt(opcode); if (mode == null) { log.warn("handlePtyReq({}) unsupported pty opcode value: {}={}", this, opcode, val);
modes.putByte((byte) mode.toInt()); modes.putInt(value.longValue()); });
/** * @param v The value to be tested * @return {@code true} if <U>all</U> of these conditions hold:</BR> * <UL> * <LI>The mapped value is a {@link Number}</LI> * <LI>The {@link Number#intValue()} is non-zero</LI> * </UL> * @see #getBooleanSettingValue(int) */ public static boolean getBooleanSettingValue(Object v) { return (v instanceof Number) && getBooleanSettingValue(((Number) v).intValue()); }
public TtyFilterInputStream(InputStream in, Map<PtyMode, ?> modes) { this(in, PtyMode.resolveEnabledOptions(modes, INPUT_OPTIONS)); }
/** * @param options The options to enable - ignored if {@code null}/empty * @return A {@link Map} where all the specified {@link PtyMode}s have {@link #TRUE_SETTING} */ public static Map<PtyMode, Integer> createEnabledOptions(PtyMode... options) { return createEnabledOptions(GenericUtils.of(options)); }
/** * @param modes The current modes {@link Map}-ing * @param m The required {@link PtyMode} * @return {@code true} if <U>all</U> of these conditions hold:</BR> * <UL> * <LI>Modes map is not {@code null}/empty</LI> * <LI>Required mode setting is not {@code null}</LI> * <LI>The setting has a mapped value</LI> * <LI>The mapped value is a {@link Number}</LI> * <LI>The {@link Number#intValue()} is non-zero</LI> * </UL> * @see #getBooleanSettingValue(Object) */ public static boolean getBooleanSettingValue(Map<PtyMode, ?> modes, PtyMode m) { if ((m == null) || GenericUtils.isEmpty(modes)) { return false; } else { return getBooleanSettingValue(modes.get(m)); } }
public TtyFilterOutputStream(OutputStream out, TtyFilterInputStream echo, Map<PtyMode, ?> modes) { this(out, echo, PtyMode.resolveEnabledOptions(modes, OUTPUT_OPTIONS)); }
public static Map<PtyMode, Integer> resolveShellTtyOptions(Map<PtyMode, Integer> modes) { Map<PtyMode, Integer> resolved = PtyMode.createEnabledOptions(PUTTY_OPTIONS); if (GenericUtils.size(modes) > 0) { resolved.putAll(modes); // TODO consider adding only non-overriding options } return resolved; } }
/** * @param modes The current modes {@link Map}-ing * @param m The required {@link PtyMode} * @return {@code true} if <U>all</U> of these conditions hold:</BR> * <UL> * <LI>Modes map is not {@code null}/empty</LI> * <LI>Required mode setting is not {@code null}</LI> * <LI>The setting has a mapped value</LI> * <LI>The mapped value is a {@link Number}</LI> * <LI>The {@link Number#intValue()} is non-zero</LI> * </UL> * @see #getBooleanSettingValue(Object) */ public static boolean getBooleanSettingValue(Map<PtyMode, ?> modes, PtyMode m) { if ((m == null) || GenericUtils.isEmpty(modes)) { return false; } else { return getBooleanSettingValue(modes.get(m)); } }
public TtyFilterInputStream(InputStream in, Map<PtyMode, ?> modes) { this(in, PtyMode.resolveEnabledOptions(modes, INPUT_OPTIONS)); }
/** * @param options The options to enable - ignored if {@code null}/empty * @return A {@link Map} where all the specified {@link PtyMode}s have {@link #TRUE_SETTING} */ public static Map<PtyMode, Integer> createEnabledOptions(PtyMode... options) { return createEnabledOptions(GenericUtils.of(options)); }
/** * @param modes The PTY settings - ignored if {@code null}/empty * @param options The options that should be enabled * @return A {@link Set} of all the {@link PtyMode}s that appeared * in the settings and were enabled * @see #getBooleanSettingValue(Map, PtyMode) */ public static Set<PtyMode> resolveEnabledOptions(Map<PtyMode, ?> modes, Collection<PtyMode> options) { if (GenericUtils.isEmpty(modes) || GenericUtils.isEmpty(options)) { return Collections.emptySet(); } Set<PtyMode> enabled = EnumSet.noneOf(PtyMode.class); for (PtyMode m : options) { if (getBooleanSettingValue(modes, m)) { enabled.add(m); } } return enabled; }
public static Set<PtyMode> resolveEnabledOptions(Map<PtyMode, ?> modes, PtyMode... options) { return resolveEnabledOptions(modes, GenericUtils.of(options)); }