Example #1
1
 /**
  * Wait for the username/password message and verify or throw SOCKSException on failure
  *
  * @since 0.8.2
  */
 private void verifyPassword(DataInputStream in, DataOutputStream out)
     throws IOException, SOCKSException {
   int c = in.readUnsignedByte();
   if (c != AUTH_VERSION) throw new SOCKSException("Unsupported authentication version");
   c = in.readUnsignedByte();
   if (c <= 0) throw new SOCKSException("Bad authentication");
   byte[] user = new byte[c];
   in.readFully(user);
   c = in.readUnsignedByte();
   if (c <= 0) throw new SOCKSException("Bad authentication");
   byte[] pw = new byte[c];
   in.readFully(pw);
   // Hopefully these are in UTF-8, since that's what our config file is in
   // these throw UnsupportedEncodingException which is an IOE
   String u = new String(user, "UTF-8");
   String p = new String(pw, "UTF-8");
   String configUser = props.getProperty(I2PTunnelHTTPClientBase.PROP_USER);
   String configPW = props.getProperty(I2PTunnelHTTPClientBase.PROP_PW);
   if ((!u.equals(configUser)) || (!p.equals(configPW))) {
     _log.error("SOCKS authorization failure");
     sendAuthReply(AUTH_FAILURE, out);
     throw new SOCKSException("SOCKS authorization failure");
   }
   if (_log.shouldLog(Log.INFO)) _log.info("SOCKS authorization success, user: " + u);
   sendAuthReply(AUTH_SUCCESS, out);
 }
Example #2
0
  /**
   * SOCKS5 connection initialization. This method assumes that SOCKS "VER" field has been stripped
   * from the input stream.
   */
  private void init(DataInputStream in, DataOutputStream out) throws IOException, SOCKSException {
    int nMethods = in.readUnsignedByte();
    int method = Method.NO_ACCEPTABLE_METHODS;

    for (int i = 0; i < nMethods; ++i) {
      int meth = in.readUnsignedByte();
      if (((!authRequired) && meth == Method.NO_AUTH_REQUIRED)
          || (authRequired && meth == Method.USERNAME_PASSWORD)) {
        // That's fine, we do support this method
        method = meth;
      }
    }

    switch (method) {
      case Method.USERNAME_PASSWORD:
        _log.debug("username/password authentication required");
        sendInitReply(Method.USERNAME_PASSWORD, out);
        verifyPassword(in, out);
        return;
      case Method.NO_AUTH_REQUIRED:
        _log.debug("no authentication required");
        sendInitReply(Method.NO_AUTH_REQUIRED, out);
        return;
      default:
        _log.debug(
            "no suitable authentication methods found (" + Integer.toHexString(method) + ")");
        sendInitReply(Method.NO_ACCEPTABLE_METHODS, out);
        throw new SOCKSException("Unsupported authentication method");
    }
  }
  public void unmarshal(DataInputStream dis) {
    super.unmarshal(dis);

    try {
      minefieldID.unmarshal(dis);
      requestingEntityID.unmarshal(dis);
      requestID = (short) dis.readUnsignedByte();
      numberOfPerimeterPoints = (short) dis.readUnsignedByte();
      pad2 = (short) dis.readUnsignedByte();
      numberOfSensorTypes = (short) dis.readUnsignedByte();
      dataFilter = dis.readInt();
      requestedMineType.unmarshal(dis);
      for (int idx = 0; idx < numberOfPerimeterPoints; idx++) {
        Point anX = new Point();
        anX.unmarshal(dis);
        requestedPerimeterPoints.add(anX);
      }

      for (int idx = 0; idx < numberOfSensorTypes; idx++) {
        TwoByteChunk anX = new TwoByteChunk();
        anX.unmarshal(dis);
        sensorTypes.add(anX);
      }

    } // end try
    catch (Exception e) {
      System.out.println(e);
    }
  } // end of unmarshal method
 public void testFormat() {
   InputConnection conn = null;
   DataInputStream dis = null;
   try {
     conn = (InputConnection) Connector.open("scratchpad:///0");
     dis = conn.openDataInputStream();
     assertEquals("bytes per sector", 256, dis.readUnsignedShort());
     assertEquals("sector per cluster", 1, dis.readUnsignedByte());
     assertEquals("reserved sector", 1, dis.readUnsignedShort());
     assertEquals("number of fats", 1, dis.readUnsignedByte());
     assertEquals("root entries", 256, dis.readUnsignedShort());
     assertEquals("total sectors", 200, dis.readUnsignedShort());
     assertEquals("sector per fat", 100, dis.readUnsignedShort());
   } catch (IOException e) {
     fail(e.toString());
   } finally {
     if (dis != null)
       try {
         dis.close();
       } catch (IOException e) {
       }
     ;
     if (conn != null)
       try {
         conn.close();
       } catch (IOException e) {
       }
     ;
   }
 }
Example #5
0
  public int read(DataInputStream istream) throws IOException {
    preRead();
    int retVal = 0;

    // read header
    retVal += header.read(istream);
    // read length
    {
      length = (short) (istream.readUnsignedByte());
      retVal += 1;
    }
    // read programIndex
    {
      programIndex = (short) (istream.readUnsignedByte());
      retVal += 1;
    }
    // read txnId
    {
      txnId = (short) (istream.readUnsignedByte());
      retVal += 1;
    }
    // read ltsid
    {
      ltsid = (short) (istream.readUnsignedByte());
      retVal += 1;
    }
    // read programNumber
    {
      programNumber = istream.readUnsignedShort();
      retVal += 2;
    }
    // read sourceId
    {
      sourceId = istream.readUnsignedShort();
      retVal += 2;
    }
    // read caPmtCmdId
    {
      caPmtCmdId = (short) (istream.readUnsignedByte());
      retVal += 1;
    }
    // read bf2
    retVal += bf2.read(istream);
    // read StatusfieldCheckInstance
    if (getProgramInfoLength() != 0) {
      StatusfieldCheckInstance = new StatusfieldCheck(this);
      retVal += StatusfieldCheckInstance.read(istream);
    }
    // read CaEntries
    for (; istream.available() > 0; ) {
      CaPmtModeMsg temp;
      temp = new CaPmtModeMsg();
      retVal += temp.read(istream);
      CaEntries.add(temp);
    }

    postRead();
    return retVal;
  }
Example #6
0
 private static int readInt() throws IOException {
   int a = dis.readUnsignedByte();
   int b = dis.readUnsignedByte();
   int c = dis.readUnsignedByte();
   int d = dis.readUnsignedByte();
   int i = (d << 24) | (c << 16) | (b << 8) | a;
   return i;
 }
  /**
   * Private API - A protocol version mismatch is detected by checking the three next bytes if a
   * frame type of (int)'A' is read from an input stream. If the next three bytes are 'M', 'Q' and
   * 'P', then it's likely the broker is trying to tell us we are speaking the wrong AMQP protocol
   * version.
   *
   * @throws MalformedFrameException if an AMQP protocol version mismatch is detected
   * @throws MalformedFrameException if a corrupt AMQP protocol identifier is read
   */
  public static void protocolVersionMismatch(DataInputStream is) throws IOException {
    MalformedFrameException x;

    // We expect the letters M, Q, P in that order: generate an informative error if they're not
    // found
    byte[] expectedBytes = new byte[] {'M', 'Q', 'P'};
    for (byte expectedByte : expectedBytes) {
      int nextByte = is.readUnsignedByte();
      if (nextByte != expectedByte) {
        throw new MalformedFrameException(
            "Invalid AMQP protocol header from server: expected character "
                + expectedByte
                + ", got "
                + nextByte);
      }
    }

    try {
      int[] signature = new int[4];

      for (int i = 0; i < 4; i++) {
        signature[i] = is.readUnsignedByte();
      }

      if (signature[0] == 1 && signature[1] == 1 && signature[2] == 8 && signature[3] == 0) {
        x =
            new MalformedFrameException(
                "AMQP protocol version mismatch; we are version "
                    + AMQP.PROTOCOL.MAJOR
                    + "-"
                    + AMQP.PROTOCOL.MINOR
                    + "-"
                    + AMQP.PROTOCOL.REVISION
                    + ", server is 0-8");
      } else {
        String sig = "";
        for (int i = 0; i < 4; i++) {
          if (i != 0) sig += ",";
          sig += signature[i];
        }

        x =
            new MalformedFrameException(
                "AMQP protocol version mismatch; we are version "
                    + AMQP.PROTOCOL.MAJOR
                    + "-"
                    + AMQP.PROTOCOL.MINOR
                    + "-"
                    + AMQP.PROTOCOL.REVISION
                    + ", server sent signature "
                    + sig);
      }

    } catch (IOException ex) {
      x = new MalformedFrameException("Invalid AMQP protocol header from server");
    }
    throw x;
  }
  public static Level load(String file) throws IOException {
    com.mojang.minecraft.level.Level level = new com.mojang.minecraft.level.Level();

    File f = new File(OpenClassic.getGame().getDirectory(), file);
    FileInputStream in = new FileInputStream(f);
    GZIPInputStream decompressor = new GZIPInputStream(in);

    DataInputStream data = new DataInputStream(decompressor);

    int magic = convert(data.readShort());

    if (magic != 1874) {
      OpenClassic.getLogger()
          .severe(
              String.format(
                  OpenClassic.getGame().getTranslator().translate("level.format-mismatch"),
                  "MCSharp v1"));
      OpenClassic.getLogger()
          .severe(OpenClassic.getGame().getTranslator().translate("level.try-mcforge"));
      return MCForgeLevelFormat.load(file);
    }

    short width = convert(data.readShort());
    short height = convert(data.readShort());
    short depth = convert(data.readShort());

    level.xSpawn = data.readShort();
    level.ySpawn = data.readShort();
    level.zSpawn = data.readShort();
    level.rotSpawn = (byte) data.readUnsignedByte();
    data.readUnsignedByte();

    byte[] blocks = new byte[width * depth * height];

    for (int z = 0; z < depth; z++) {
      for (int y = 0; y < height; y++) {
        byte[] row = new byte[height];
        data.readFully(row);

        for (int x = 0; x < width; x++) {
          blocks[(y * height + z) * width + x] = translateBlock(row[x]);
        }
      }
    }

    level.setData(width, height, depth, blocks);

    data.close();

    try {
      f.delete();
    } catch (SecurityException e) {
      e.printStackTrace();
    }

    return level.openclassic;
  }
Example #9
0
  /**
   * Read a constant from the constant pool.
   *
   * @param in The stream from which to read.
   * @return The constant.
   * @exception IOException If an error occurs while reading.
   */
  Constant readConstant(DataInputStream in) throws IOException {
    int tag = in.readUnsignedByte();
    Object value;

    switch (tag) {
      case Constant.CLASS:
      case Constant.STRING:
      case Constant.METHOD_TYPE: // @since 1.8
        value = Integer.valueOf(in.readUnsignedShort());
        break;
      case Constant.FIELD_REF:
      case Constant.METHOD_REF:
      case Constant.INTERFACE_METHOD_REF:
      case Constant.NAME_AND_TYPE:
      case Constant.INVOKE_DYNAMIC: // @since 1.8
        value = new int[2];

        ((int[]) value)[0] = in.readUnsignedShort();
        ((int[]) value)[1] = in.readUnsignedShort();
        break;
      case Constant.INTEGER:
        value = Integer.valueOf(in.readInt());
        break;
      case Constant.FLOAT:
        value = Float.valueOf(in.readFloat());
        break;
      case Constant.LONG:
        // Longs take up 2 constant pool entries.
        value = Long.valueOf(in.readLong());
        break;
      case Constant.DOUBLE:
        // Doubles take up 2 constant pool entries.
        value = Double.valueOf(in.readDouble());
        break;
      case Constant.UTF8:
        value = in.readUTF();
        break;
      case Constant.METHOD_HANDLE: // @since 1.8
        value = new int[2];

        ((int[]) value)[0] = in.readUnsignedByte();
        ((int[]) value)[1] = in.readUnsignedShort();
        break;
      default:
        throw new ClassFormatError("Invalid constant tag: " + tag);
    }

    return new Constant(tag, value);
  }
Example #10
0
  public static Cp readCp(DataInputStream source) throws IOException {
    byte tag;

    tag = (byte) source.readUnsignedByte();
    switch (tag) {
      case TAG_Class:
        return new CpClass(source);
      case TAG_Fieldref:
        return new CpFieldref(source);
      case TAG_Methodref:
        return new CpMethodref(source);
      case TAG_InterfaceMethodref:
        return new CpInterfaceMethodref(source);
      case TAG_String:
        return new CpString(source);
      case TAG_Integer:
        return new CpInteger(source);
      case TAG_Float:
        return new CpFloat(source);
      case TAG_Long:
        return new CpLong(source);
      case TAG_Double:
        return new CpDouble(source);
      case TAG_NameAndType:
        return new CpNameAndType(source);
      case TAG_Utf8:
        return new CpUtf8(source);
      default:
        throw new Error("Unknown tag type in constant pool: " + tag);
    }
  }
  // Returns important image data to the main class
  @Override
  public ImageData getImages(int limit) {
    try {
      DataInputStream imgInputStream = new DataInputStream(new FileInputStream(imageFilePath));
      imgInputStream.readInt(); // magic number
      int numImgs = imgInputStream.readInt();
      if (limit >= 0 && limit <= numImgs) numImgs = limit;
      int numRows = imgInputStream.readInt();
      int numCols = imgInputStream.readInt();

      // Reduces each image pixel to its grayscale value for processing by the neural network
      double[][] images = new double[numImgs][numRows * numCols];
      for (int i = 0; i < images.length; i++) {
        for (int j = 0; j < images[i].length; j++) {
          images[i][j] = imgInputStream.readUnsignedByte() / 255.0;
        }
      }
      imgInputStream.close();

      return new ImageData(images, numRows, numCols);
    } catch (IOException e) {
      e.printStackTrace();
    }

    return null;
  }
 /**
  * Auxiliary method to extract the bootstrap methods associated with the resource. This is fetched
  * from the 'SourceDebugExtension_attribute' structure, which has the following format:
  *
  * <p>[java 8] SourceDebugExtension_attribute { u2 attribute_name_index; u4 attribute_length; u1
  * debug_extension[attribute_length]; }
  *
  * <p>- debug_extension[]: The 'debug_extension' array holds extended debugging information which
  * has no semantic effect on the Java Virtual Machine. The information is represented using a
  * modified UTF-8 string with no terminating zero byte. Note that the 'debug_extension' array may
  * denote a string longer than that which can be represented with an instance of class String.
  *
  * @param dataInputStream The byte stream associated with the resource (aka .class file).
  * @param attributeLength The length of the debug extension.
  * @param resource The resource associated with the attribute.
  * @throws IOException When reading bytes from the stream fails.
  */
 public static void extractSourceDebugExtension(
     DataInputStream dataInputStream, int attributeLength, Resource resource) throws IOException {
   int debug;
   for (int index = 0; index < attributeLength; index++) {
     debug = dataInputStream.readUnsignedByte();
   }
 }
Example #13
0
  void loadConstants(LPrototype f) throws IOException {
    int n = loadInt();
    LValue[] values = new LValue[n];
    for (int i = 0; i < n; i++) {
      switch (is.readByte()) {
        case Lua.LUA_TNIL:
          values[i] = LNil.NIL;
          break;
        case Lua.LUA_TBOOLEAN:
          values[i] = (0 != is.readUnsignedByte() ? LBoolean.TRUE : LBoolean.FALSE);
          break;
        case Lua.LUA_TINT:
          values[i] = LInteger.valueOf(loadInt());
          break;
        case Lua.LUA_TNUMBER:
          values[i] = loadNumber();
          break;
        case Lua.LUA_TSTRING:
          values[i] = loadString();
          break;
        default:
          throw new IllegalStateException("bad constant");
      }
    }
    f.k = values;

    n = loadInt();
    LPrototype[] protos = new LPrototype[n];
    for (int i = 0; i < n; i++) protos[i] = loadFunction(f.source);
    f.p = protos;
  }
Example #14
0
  public void writeStream(DataInputStream input) throws IOException, NoSuchAlgorithmException {
    try {
      int bytesRead = 0;
      int bytesToSkip = 0;

      while (true) {
        final int value = input.readUnsignedByte();
        bytesRead++;
        check.nextByte(value);
        writeRaw(value);
        final int weakChecksum = check.weakChecksum();
        String strongChecksum = null;

        if (bytesToSkip > 0) {
          bytesToSkip--;
        } else {
          Map<String, Integer> weakMatches = inputBlocks.get(weakChecksum);
          if (weakMatches != null) {
            strongChecksum = check.strongChecksum();
            Integer previousOffset = weakMatches.get(strongChecksum);
            if (previousOffset != null) {
              snipRawBuffer();
              System.err.println(
                  "Using previously remembered : "
                      + previousOffset
                      + " : "
                      + (bytesRead - BLOCK_SIZE));
              writeBlock(previousOffset);
              bytesToSkip = BLOCK_SIZE - 1;
            }
          }
        }

        if ((bytesRead % BLOCK_SIZE) == 0) {
          Map<String, Integer> weakMatches = inputBlocks.get(weakChecksum);
          if (weakMatches == null) {
            weakMatches = new HashMap<String, Integer>();
            inputBlocks.put(weakChecksum, weakMatches);
          }
          if (strongChecksum == null) {
            strongChecksum = check.strongChecksum();
          }
          if (!weakMatches.containsKey(strongChecksum)) {
            weakMatches.put(strongChecksum, bytesRead - BLOCK_SIZE);
            System.err.println(
                "Remembering : "
                    + weakChecksum
                    + " : "
                    + strongChecksum
                    + " : "
                    + (bytesRead - BLOCK_SIZE));
          }
        }
      }
    } catch (EOFException e) {
      flushRaw();
    }
    System.err.println("Original data: " + rawChunks);
    System.err.println("Reused data: " + blockChunks);
  }
Example #15
0
  @SuppressWarnings("unchecked")
  public SenseData decode(ByteBuffer buffer) throws IOException {
    DataInputStream in = new DataInputStream(new ByteBufferInputStream(buffer));

    int b1 = in.readUnsignedByte();
    ResponseCode code = ResponseCode.valueOf((byte) (b1 & 0x7F)); // throws IOException

    SenseData sense = null;

    switch (code) {
      case CURRENT_FIXED:
        sense = new FixedSenseData();
        break;
      case CURRENT_DESCRIPTOR:
        sense = new DescriptorSenseData();
        break;
      case DEFERRED_FIXED:
        sense = new FixedSenseData();
        break;
      case DEFERRED_DESCRIPTOR:
        sense = new DescriptorSenseData();
        break;
    }

    sense.decode(new byte[] {(byte) b1}, buffer);
    return sense;
  }
 private short readUnsignedByte() {
   try {
     return (short) inStream.readUnsignedByte();
   } catch (IOException e) {
     IOError();
   }
   return 0;
 }
Example #17
0
  void readServerInit() throws IOException {
    framebufferWidth = is.readUnsignedShort();
    framebufferHeight = is.readUnsignedShort();
    bitsPerPixel = is.readUnsignedByte();
    depth = is.readUnsignedByte();
    bigEndian = (is.readUnsignedByte() != 0);
    trueColour = (is.readUnsignedByte() != 0);
    redMax = is.readUnsignedShort();
    greenMax = is.readUnsignedShort();
    blueMax = is.readUnsignedShort();
    redShift = is.readUnsignedByte();
    greenShift = is.readUnsignedByte();
    blueShift = is.readUnsignedByte();
    byte[] pad = new byte[3];
    readFully(pad);
    int nameLength = is.readInt();
    byte[] name = new byte[nameLength];
    readFully(name);
    desktopName = new String(name);

    // Read interaction capabilities (TightVNC protocol extensions)
    if (protocolTightVNC) {
      int nServerMessageTypes = is.readUnsignedShort();
      int nClientMessageTypes = is.readUnsignedShort();
      int nEncodingTypes = is.readUnsignedShort();
      is.readUnsignedShort();
      readCapabilityList(serverMsgCaps, nServerMessageTypes);
      readCapabilityList(clientMsgCaps, nClientMessageTypes);
      readCapabilityList(encodingCaps, nEncodingTypes);
    }

    inNormalProtocol = true;
  }
  public void unmarshal(DataInputStream dis) {
    super.unmarshal(dis);

    try {
      minefieldID.unmarshal(dis);
      requestingEntityID.unmarshal(dis);
      minefieldSequenceNumbeer = (int) dis.readUnsignedShort();
      requestID = (short) dis.readUnsignedByte();
      pduSequenceNumber = (short) dis.readUnsignedByte();
      numberOfPdus = (short) dis.readUnsignedByte();
      numberOfMinesInThisPdu = (short) dis.readUnsignedByte();
      numberOfSensorTypes = (short) dis.readUnsignedByte();
      pad2 = (short) dis.readUnsignedByte();
      dataFilter = dis.readInt();
      mineType.unmarshal(dis);
      for (int idx = 0; idx < numberOfSensorTypes; idx++) {
        TwoByteChunk anX = new TwoByteChunk();
        anX.unmarshal(dis);
        sensorTypes.add(anX);
      }

      pad3 = (short) dis.readUnsignedByte();
      for (int idx = 0; idx < numberOfMinesInThisPdu; idx++) {
        Vector3Float anX = new Vector3Float();
        anX.unmarshal(dis);
        mineLocation.add(anX);
      }

    } // end try
    catch (Exception e) {
      System.out.println(e);
    }
  } // end of unmarshal method
Example #19
0
  public int read(DataInputStream istream) throws IOException {
    preRead();
    int retVal = 0;

    // read featureId
    {
      featureId = (short) (istream.readUnsignedByte());
      retVal += 1;
    }
    // read status
    {
      status = (short) (istream.readUnsignedByte());
      retVal += 1;
    }

    postRead();
    return retVal;
  }
Example #20
0
 public static NSEC3PARAM parse(DataInputStream dis) throws IOException {
   byte hashAlgorithm = dis.readByte();
   byte flags = dis.readByte();
   int iterations = dis.readUnsignedShort();
   int saltLength = dis.readUnsignedByte();
   byte[] salt = new byte[saltLength];
   if (dis.read(salt) != salt.length && salt.length != 0) throw new IOException();
   return new NSEC3PARAM(hashAlgorithm, flags, iterations, salt);
 }
 public static long convert8BytesToLong(byte[] buffer, int offset) throws IOException {
   ByteArrayInputStream byte_in = new ByteArrayInputStream(buffer);
   DataInputStream data_in = new DataInputStream(byte_in);
   /* skip the offset */
   data_in.skip(offset);
   //
   long value;
   value = data_in.readUnsignedByte();
   value += (long) data_in.readUnsignedByte() << 8;
   value += (long) data_in.readUnsignedByte() << 16;
   value += (long) data_in.readUnsignedByte() << 24;
   value += (long) data_in.readUnsignedByte() << 32;
   value += (long) data_in.readUnsignedByte() << 40;
   value += (long) data_in.readUnsignedByte() << 48;
   value += (long) data_in.readUnsignedByte() << 56;
   return value;
   // return convertNBytesToLong(buffer, offset, 8);
 }
 public static int readUnsignedByte(DataInputStream dataInputStream, long[] alRemainingBytes)
     throws IOException {
   int nByte = dataInputStream.readUnsignedByte();
   // already done in DataInputStream.readUnsignedByte();
   // 		if (nByte < 0)
   // 		{
   // 			throw new EOFException();
   // 		}
   alRemainingBytes[0]--;
   return nByte;
 }
Example #23
0
  private int getByte(DataInputStream ds) {
    int y;

    try { // read starting line #
      y = ds.readUnsignedByte();
    } catch (IOException e) {
      System.out.println("Error reading byte : " + e);
      return (-1);
    }
    return (y);
  }
Example #24
0
 /**
  * Parse a domain name starting at the current offset and moving the input stream pointer past
  * this domain name (even if cross references occure).
  *
  * @param dis The input stream.
  * @param data The raw data (for cross references).
  * @return The domain name string.
  * @throws IOException Should never happen.
  */
 public static String parse(DataInputStream dis, byte data[]) throws IOException {
   int c = dis.readUnsignedByte();
   if ((c & 0xc0) == 0xc0) {
     c = ((c & 0x3f) << 8) + dis.readUnsignedByte();
     HashSet<Integer> jumps = new HashSet<Integer>();
     jumps.add(c);
     return parse(data, c, jumps);
   }
   if (c == 0) {
     return "";
   }
   byte b[] = new byte[c];
   dis.readFully(b);
   String s = IDN.toUnicode(new String(b));
   String t = parse(dis, data);
   if (t.length() > 0) {
     s = s + "." + t;
   }
   return s;
 }
  public int read(DataInputStream istream) throws IOException {
    preRead();
    int retVal = 0;

    // read header
    retVal += header.read(istream);
    // read protocol_version
    {
      protocol_version = (short) (istream.readUnsignedByte());
      retVal += 1;
    }
    // read configuration_count_change
    {
      configuration_count_change = (short) (istream.readUnsignedByte());
      retVal += 1;
    }
    // read resources
    retVal += resources.read(istream);
    // read pvData
    {
      IntegerHolder iHolder = new IntegerHolder();
      DataInputStream disTemp = istream;
      pvData = PVDataFactory.createMsg(protocol_version, disTemp, iHolder);
      retVal += iHolder.getValue();
    }
    // read certificateCount
    {
      certificateCount = (short) (istream.readUnsignedByte());
      retVal += 1;
    }
    // read cvCertificates
    for (int iIdx = 0; iIdx < certificateCount + (0); iIdx++) {
      CVCertificate temp;
      temp = new CVCertificate();
      retVal += temp.read(istream);
      cvCertificates.add(temp);
    }

    postRead();
    return retVal;
  }
Example #26
0
  public LPrototype loadFunction(LString p) throws IOException {
    LPrototype f = new LPrototype();
    //		this.L.push(f);
    f.source = loadString();
    if (f.source == null) f.source = p;
    f.linedefined = loadInt();
    f.lastlinedefined = loadInt();
    f.nups = is.readUnsignedByte();
    f.numparams = is.readUnsignedByte();
    f.is_vararg = is.readUnsignedByte();
    f.maxstacksize = is.readUnsignedByte();
    f.code = loadIntArray();
    loadConstants(f);
    loadDebug(f);

    // TODO: add check here, for debugging purposes, I believe
    // see ldebug.c
    //		 IF (!luaG_checkcode(f), "bad code");

    //		 this.L.pop();
    return f;
  }
Example #27
0
  public int readNoHeader(DataInputStream istream) throws IOException {

    preRead();
    int retVal = 0;
    // read length
    {
      length = (short) (istream.readUnsignedByte());
      retVal += 1;
    }

    postRead();
    return retVal;
  }
Example #28
0
  public int readNoHeader(DataInputStream istream) throws IOException {

    preRead();
    int retVal = 0;
    // read length
    {
      length = (short) (istream.readUnsignedByte());
      retVal += 1;
    }
    // read caPmtlisMngement
    {
      caPmtlisMngement = (short) (istream.readUnsignedByte());
      retVal += 1;
    }
    // read programNumber
    {
      programNumber = istream.readUnsignedShort();
      retVal += 2;
    }
    // read bf1
    retVal += bf1.read(istream);
    // read bf2
    retVal += bf2.read(istream);
    // read StatusfieldCheckInstance
    if (getProgramInfoLength() != 0) {
      StatusfieldCheckInstance = new StatusfieldCheck(this);
      retVal += StatusfieldCheckInstance.read(istream);
    }
    // read CaEntries
    for (; istream.available() > 0; ) {
      CaPmtModeMsg temp;
      temp = new CaPmtModeMsg();
      retVal += temp.read(istream);
      CaEntries.add(temp);
    }

    postRead();
    return retVal;
  }
Example #29
0
 @Override
 public int read() throws IOException {
   output.writeByte(ForkServer.RESOURCE);
   output.writeByte(resource);
   output.writeInt(1);
   output.flush();
   int n = input.readInt();
   if (n == 1) {
     return input.readUnsignedByte();
   } else {
     return n;
   }
 }
Example #30
0
 int readCompactLen() throws IOException {
   int[] portion = new int[3];
   portion[0] = is.readUnsignedByte();
   // int byteCount = 1;
   int len = portion[0] & 0x7F;
   if ((portion[0] & 0x80) != 0) {
     portion[1] = is.readUnsignedByte();
     // byteCount++;
     len |= (portion[1] & 0x7F) << 7;
     if ((portion[1] & 0x80) != 0) {
       portion[2] = is.readUnsignedByte();
       // byteCount++;
       len |= (portion[2] & 0xFF) << 14;
     }
   }
   /*-
      if (rec != null && recordFromBeginning)
        for (int i = 0; i < byteCount; i++)
   rec.writeByte(portion[i]);
   */
   return len;
 }