/* 9P Protocol JAVA
 * P9P/msg/Tcreate9P.java
 * Autor: Jaime Garzon (2006) jgarzon@gmail.com
 *
 * Esta clase es una implementacion del mensaje
 * Tcreate, 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 Tcreate9P extends tmsg9P {

   public int9P fid = new int9P();
   public String9P name = new String9P();
   public int9P perm = new int9P();
   public byte9P mode = new byte9P();

   public void write(ByteArrayOutputStream buf) {
      type.write(buf);
      tag.write(buf);
      fid.write(buf);
      name.write(buf);
      perm.write(buf);
      mode.write(buf);
   }

   public void read (byte[] msg, int i) {
      type.read(msg,i);
      tag.read(msg,i+=1);
      fid.read(msg,i+=2);
      name.read(msg,i+=4);
      perm.read(msg,i+=name.len());
      mode.read(msg,i+4);
   }

   public String toString() {
      return tagDb()+"Tcreate fid:"+fid+"name:"+name+
         "perm:"+perm+"mode:"+mode;
   }
}