Beispiel #1
0
func _readLong3(file *bytes.Reader, offset int64) int64 {
	buf := make([]byte, 4)
	file.ReadAt(buf, offset)
	buf[3] = 0x00

	return int64(binary.LittleEndian.Uint32(buf))
}
Beispiel #2
0
func getIpLocation(file *bytes.Reader, offset int64) (loc tIp2LocationResp) {

	buf := make([]byte, 1024)

	file.ReadAt(buf[0:1], offset+4)

	mod := buf[0]

	//log.Printf("C1 FLAG: %#v", mod)

	descOffset := int64(0)
	op_descOffset := int64(0)

	if 0x01 == mod {
		descOffset = _readLong3(file, offset+5)
		//log.Printf("Redirect to: %#v",descOffset);

		file.ReadAt(buf[0:1], descOffset)

		mod2 := buf[0]

		//log.Printf("C2 FLAG: %#v", mod2)

		if 0x02 == mod2 {
			loc.area_desc = _readString(file, _readLong3(file, descOffset+1))
			op_descOffset = descOffset + 4
		} else {
			loc.area_desc = _readString(file, descOffset)
			op_descOffset = descOffset + int64(len(loc.area_desc)) + 1
			// op_descOffset = file.Seek(0,1) // got the pos
			// log.Printf("cPOS: %#v aPOS: %#v err: %#v",descOffset,op_descOffset,err3)

		}

		loc.op_desc = _readArea(file, op_descOffset)

	} else if 0x02 == mod {
		loc.area_desc = _readString(file, _readLong3(file, offset+5))
		loc.op_desc = _readArea(file, offset+8)
	} else {
		loc.area_desc = _readString(file, offset+4)
		op_descOffset = offset + 4 + int64(len(loc.area_desc)) + 1
		//op_descOffset,_ = file.Seek(0,1)

		loc.op_desc = _readArea(file, op_descOffset)
	}

	loc.ok = true

	return
}
Beispiel #3
0
func _readString(file *bytes.Reader, offset int64) string {

	buf := make([]byte, 1024)
	got := int64(0)

	for ; got < 1024; got++ {
		file.ReadAt(buf[got:got+1], offset+got)

		if buf[got] == 0x00 {
			break
		}
	}

	return string(buf[0:got])
}
Beispiel #4
0
func _readArea(file *bytes.Reader, offset int64) string {
	buf := make([]byte, 4)

	file.ReadAt(buf[0:1], offset)

	mod := buf[0]

	//log.Printf("A FLAG: %#v", mod)

	if 0x01 == mod || 0x02 == mod {
		op_descOffset := _readLong3(file, offset+1)
		if op_descOffset == 0 {
			return ""
		} else {
			return _readString(file, op_descOffset)
		}
	}
	return _readString(file, offset)
}