/* 9P Protocol JAVA
 * P9P/msg/Rwalk9P.java
 * Autor: Jaime Garzon (2006) jgarzon@gmail.com
 *
 * Esta clase es una implementacion del mensaje
 * Rwalk, usado en el protocolo 9P de Plan9P, descrito
 * en la seccion 5 del manual de Plan 9: "Plan 9 File Protocol"
 *
 * Los metodos Write y Read, permiten escribir el valor
 * en un Buffer o leerlo de un array de bytes, respectivamente.
 * El metodo debug() es usado para depuracion de los mensajes.
*/

package P9P.msg;
import P9P.type.*;
import java.io.*;

public class Rwalk9P extends rmsg9P {

   public short9P nwqid = new short9P();
   public qid9P[] wqid;

   public void write(ByteArrayOutputStream buf) {
      type.write(buf);
      tag.write(buf);
      nwqid.write(buf);
      for (int i=0; i<nwqid.value; i++)
         wqid[i].write(buf);
   }

   public void read (byte[] msg, int i) {
      type.read(msg,i);
      tag.read(msg,i+=1);
      nwqid.read(msg,i+=2);
      i+=2;
      for (int j=0; j<nwqid.value; j++) {
         wqid[j].read(msg,i);
         i+=13;
      }
   }

   public String toString() {
      return tagDb()+"Rwalk nwqid:"+ nwqid;
   }
}