]> git.r.bdr.sh - rbdr/mobius/blame - hotline/field.go
Prune unused code
[rbdr/mobius] / hotline / field.go
CommitLineData
6988a057
JH
1package hotline
2
3import (
4 "encoding/binary"
5 "github.com/jhalter/mobius/concat"
6)
7
8const fieldError = 100
9const fieldData = 101
10const fieldUserName = 102
11const fieldUserID = 103
12const fieldUserIconID = 104
13const fieldUserLogin = 105
14const fieldUserPassword = 106
15const fieldRefNum = 107
16const fieldTransferSize = 108
17const fieldChatOptions = 109
18const fieldUserAccess = 110
eabc4b6c 19//const fieldUserAlias = 111 TODO: implement
6988a057
JH
20const fieldUserFlags = 112
21const fieldOptions = 113
22const fieldChatID = 114
23const fieldChatSubject = 115
24const fieldWaitingCount = 116
25const fieldVersion = 160
26const fieldCommunityBannerID = 161
27const fieldServerName = 162
28const fieldFileNameWithInfo = 200
29const fieldFileName = 201
30const fieldFilePath = 202
31const fieldFileTypeString = 205
32const fieldFileCreatorString = 206
33const fieldFileSize = 207
34const fieldFileCreateDate = 208
35const fieldFileModifyDate = 209
36const fieldFileComment = 210
37const fieldFileNewName = 211
38const fieldFileNewPath = 212
39const fieldFileType = 213
40const fieldQuotingMsg = 214 // Defined but unused in the Hotline Protocol spec
41const fieldAutomaticResponse = 215
42const fieldFolderItemCount = 220
43const fieldUsernameWithInfo = 300
44const fieldNewsArtListData = 321
45const fieldNewsCatName = 322
46const fieldNewsCatListData15 = 323
47const fieldNewsPath = 325
48const fieldNewsArtID = 326
49const fieldNewsArtDataFlav = 327
50const fieldNewsArtTitle = 328
51const fieldNewsArtPoster = 329
52const fieldNewsArtDate = 330
53const fieldNewsArtPrevArt = 331
54const fieldNewsArtNextArt = 332
55const fieldNewsArtData = 333
56const fieldNewsArtFlags = 334
57const fieldNewsArtParentArt = 335
58const fieldNewsArt1stChildArt = 336
59const fieldNewsArtRecurseDel = 337
60
61type Field struct {
62 ID []byte // Type of field
63 FieldSize []byte // Size of the data part
64 Data []byte // Actual field content
65}
66
67type requiredField struct {
68 ID int
69 minLen int
70 maxLen int
71}
72
73func NewField(id uint16, data []byte) Field {
74 idBytes := make([]byte, 2)
75 binary.BigEndian.PutUint16(idBytes, id)
76
77 bs := make([]byte, 2)
78 binary.BigEndian.PutUint16(bs, uint16(len(data)))
79
80 return Field{
81 ID: idBytes,
82 FieldSize: bs,
83 Data: data,
84 }
85}
86
87func (f Field) Payload() []byte {
88 return concat.Slices(f.ID, f.FieldSize, f.Data)
89}