Documentation
¶
Overview ¶
* Archon PSO Server * Copyright (C) 2014 Andrew Rodman * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * --------------------------------------------------------------------- * * Functions and constants shared between server components.
Index ¶
- func BytesFromStruct(data interface{}) ([]byte, int)
- func ConvertToUtf16(str string) []byte
- func ExpandUtf16(src []uint16) []uint8
- func GetPacketSize(data []byte) (uint16, error)
- func PrintPayload(data []uint8, pktLen int)
- func StripPadding(b []byte) []byte
- func StructFromBytes(data []byte, targetStruct interface{})
- func ZeroSlice(arr []byte, length int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesFromStruct ¶
Serializes the fields of a struct to an array of bytes in the order in which the fields are declared. Calls panic() if data is not a struct or pointer to struct, or if there was an error writing a field.
func ConvertToUtf16 ¶
Convert a UTF-8 string to UTF-16 LE and return it as an array of bytes.
func ExpandUtf16 ¶
Expands an array of UTF-16 elements to a slice of uint8 elements in little endian order. E.g: [0x1234] -> [0x34, 0x12]
func GetPacketSize ¶
Extract the packet length from the first two bytes of data.
func PrintPayload ¶
Print the contents of a packet to stdout in two columns, one for bytes and the other for their ascii representation.
func StripPadding ¶
Returns a slice of b without the trailing 0s.
func StructFromBytes ¶
func StructFromBytes(data []byte, targetStruct interface{})
Populates the struct pointed to by targetStruct by reading in a stream of bytes and filling the values in sequential order.
Types ¶
This section is empty.