aboutsummaryrefslogtreecommitdiff
path: root/field.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2021-07-28 18:21:52 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2021-07-28 14:21:52 -0700
commit22c599abc18895f73e96095f35b71cf3357d41b4 (patch)
tree482ef57d386c955692ea43c43e4655b3c3763499 /field.go
parent71c56068adca18f76ebee86355f000a3e51d3127 (diff)
Move code to hotline dir
Diffstat (limited to 'field.go')
-rw-r--r--field.go120
1 files changed, 0 insertions, 120 deletions
diff --git a/field.go b/field.go
deleted file mode 100644
index 161a9b2..0000000
--- a/field.go
+++ /dev/null
@@ -1,120 +0,0 @@
-package hotline
-
-import (
- "encoding/binary"
- "github.com/jhalter/mobius/concat"
-)
-
-const fieldError = 100
-const fieldData = 101
-const fieldUserName = 102
-const fieldUserID = 103
-const fieldUserIconID = 104
-const fieldUserLogin = 105
-const fieldUserPassword = 106
-const fieldRefNum = 107
-const fieldTransferSize = 108
-const fieldChatOptions = 109
-const fieldUserAccess = 110
-const fieldUserAlias = 111
-const fieldUserFlags = 112
-const fieldOptions = 113
-const fieldChatID = 114
-const fieldChatSubject = 115
-const fieldWaitingCount = 116
-const fieldVersion = 160
-const fieldCommunityBannerID = 161
-const fieldServerName = 162
-const fieldFileNameWithInfo = 200
-const fieldFileName = 201
-const fieldFilePath = 202
-const fieldFileTypeString = 205
-const fieldFileCreatorString = 206
-const fieldFileSize = 207
-const fieldFileCreateDate = 208
-const fieldFileModifyDate = 209
-const fieldFileComment = 210
-const fieldFileNewName = 211
-const fieldFileNewPath = 212
-const fieldFileType = 213
-const fieldQuotingMsg = 214 // Defined but unused in the Hotline Protocol spec
-const fieldAutomaticResponse = 215
-const fieldFolderItemCount = 220
-const fieldUsernameWithInfo = 300
-const fieldNewsArtListData = 321
-const fieldNewsCatName = 322
-const fieldNewsCatListData15 = 323
-const fieldNewsPath = 325
-const fieldNewsArtID = 326
-const fieldNewsArtDataFlav = 327
-const fieldNewsArtTitle = 328
-const fieldNewsArtPoster = 329
-const fieldNewsArtDate = 330
-const fieldNewsArtPrevArt = 331
-const fieldNewsArtNextArt = 332
-const fieldNewsArtData = 333
-const fieldNewsArtFlags = 334
-const fieldNewsArtParentArt = 335
-const fieldNewsArt1stChildArt = 336
-const fieldNewsArtRecurseDel = 337
-
-type Field struct {
- ID []byte // Type of field
- FieldSize []byte // Size of the data part
- Data []byte // Actual field content
-}
-
-type requiredField struct {
- ID int
- minLen int
- maxLen int
-}
-
-func NewField(id uint16, data []byte) Field {
- idBytes := make([]byte, 2)
- binary.BigEndian.PutUint16(idBytes, id)
-
- bs := make([]byte, 2)
- binary.BigEndian.PutUint16(bs, uint16(len(data)))
-
- return Field{
- ID: idBytes,
- FieldSize: bs,
- Data: data,
- }
-}
-
-func (f Field) Payload() []byte {
- return concat.Slices(f.ID, f.FieldSize, f.Data)
-}
-
-type FileNameWithInfo struct {
- Type string // file type code
- Creator []byte // File creator code
- FileSize uint32 // File Size in bytes
- NameScript []byte // TODO: What is this?
- NameSize []byte // Length of name field
- Name string // File name
-}
-
-func (f FileNameWithInfo) Payload() []byte {
- name := []byte(f.Name)
- nameSize := make([]byte, 2)
- binary.BigEndian.PutUint16(nameSize, uint16(len(name)))
-
- kb := f.FileSize
-
- fSize := make([]byte, 4)
- binary.BigEndian.PutUint32(fSize, kb)
-
- return concat.Slices(
- []byte(f.Type),
- f.Creator,
- fSize,
- []byte{0, 0, 0, 0},
- f.NameScript,
- nameSize,
- []byte(f.Name),
- )
-
-}