Commit 02926be3 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 541e343f
......@@ -49,3 +49,34 @@ func (p *RowInfo) NEODecode(data []byte) (int, error) {
}
return 0 /* + TODO variable part */, nil
}
func (p *Notify) NEODecode(data []byte) (int, error) {
{
l := BigEndian.Uint32(data[0:])
data = data[4:]
if len(data) < l {
return 0, ErrDecodeOverflow
}
p.Message = string(data[:l])
data = data[l:]
}
return 0 /* + TODO variable part */, nil
}
func (p *Error) NEODecode(data []byte) (int, error) {
p.Code = BigEndian.Uint32(data[0:])
{
l := BigEndian.Uint32(data[4:])
data = data[8:]
if len(data) < l {
return 0, ErrDecodeOverflow
}
p.Message = string(data[:l])
data = data[l:]
}
return 0 /* + TODO variable part */, nil
}
func (p *Ping) NEODecode(data []byte) (int, error) {
return 0 /* + TODO variable part */, nil
}
func (p *CloseClient) NEODecode(data []byte) (int, error) {
return 0 /* + TODO variable part */, nil
}
......@@ -177,7 +177,6 @@ type RowInfo struct {
/*
// // XXX link request <-> answer ?
// // XXX naming -> PktHeader ?
// type PktHead struct {
......@@ -186,7 +185,6 @@ type RowInfo struct {
// Len be32 // whole packet length (including header)
// }
// TODO generate .Encode() / .Decode()
// General purpose notification (remote logging)
type Notify struct {
......@@ -210,6 +208,7 @@ type Ping struct {
type CloseClient struct {
}
/*
// Request a node identification. This must be the first packet for any
// connection. Any -> Any.
type RequestIdentification struct {
......
......@@ -209,6 +209,7 @@ func (d *decoder) emitslice(assignto string, obj types.Object, typ *types.Slice)
d.emit("{ l := %v", d.decodedBasic(nil, types.Typ[types.Uint32]))
d.emit("data = data[%v:]", d.n)
d.emit("%v = make(%v, l)", assignto, typ)
// TODO size check
// TODO if size(item)==const - check l in one go
//d.emit("if len(data) < l { return 0, ErrDecodeOverflow }")
d.emit("for i := 0; i < l; i++ {")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment