Пример #1
0
  static void reqChangeProperty(Client c) throws IOException {
    int foo;
    byte mode;
    int prpty;
    byte frmt;
    int typ;
    int n;
    IO io = c.client;

    mode = (byte) c.data;
    if ((mode != PropModeReplace) && (mode != PropModeAppend) && (mode != PropModePrepend)) {
      // System.err.println("error!!");
      c.errorValue = mode;
      c.errorReason = 2; // BadValue;
    }

    n = c.length;
    ;
    foo = io.readInt();
    Window w = c.lookupWindow(foo);
    if (c.errorReason == 0 && w == null) {
      c.errorValue = foo;
      c.errorReason = 3; // BadWindow;
    }
    prpty = io.readInt();
    typ = io.readInt();
    frmt = (byte) io.readByte();
    if (c.errorReason == 0 && (frmt != 8) && (frmt != 16) && (frmt != 32)) {
      c.errorValue = frmt;
      c.errorReason = 3; // BadWindow;
    }
    io.readPad(3);
    foo = io.readInt();
    int totalSize = foo * (frmt / 8);
    byte[] bar = null;
    if (totalSize > 0) {
      bar = new byte[totalSize];
      io.readByte(bar, 0, totalSize);
      if (c.swap) {
        switch (frmt) {
          case 16:
            swapS(bar, 0, totalSize);
            break;
          case 32:
            swapL(bar, 0, totalSize);
            break;
          default:
        }
      }
      io.readPad((-totalSize) & 3);
    }
    c.length = 0;
    if (c.errorReason != 0) {
      return;
    }
    changeWindowProperty(c, w, prpty, typ, frmt, mode, foo, bar, true);
  }