package hotline
-import (
- "encoding/binary"
- "math/big"
-)
-
const (
accessDeleteFile = 0 // File System Maintenance: Can Delete Files
accessUploadFile = 1 // File System Maintenance: Can Upload Files
accessOpenUser = 16 // User Maintenance: Can Read Accounts
accessModifyUser = 17 // User Maintenance: Can Modify Accounts
accessChangeOwnPass = 18 // Present in the Hotline 1.9 protocol documentation, but seemingly unused
- accessSendPrivMsg = 19 // Messaging: Can Send Messages
accessNewsReadArt = 20 // News: Can Read Articles
accessNewsPostArt = 21 // News: Can Post Articles
accessDisconUser = 22 // User Maintenance: Can Disconnect Users (Note: Turns username red in user list)
accessNewsDeleteCat = 35 // News: Can Delete Categories
accessNewsCreateFldr = 36 // News: Can Create News Bundles
accessNewsDeleteFldr = 37 // News: Can Delete News Bundles
+ accessSendPrivMsg = 40 // Messaging: Can Send Messages (Note: 1.9 protocol doc incorrectly says this is bit 19)
)
type accessBitmap [8]byte
bits[i/8] |= 1 << uint(7-i%8)
}
-// authorize checks if 64 bit access slice contain has accessBit set
-// TODO: refactor to use accessBitmap type
-func authorize(access *[]byte, accessBit int) bool {
- bits := big.NewInt(int64(binary.BigEndian.Uint64(*access)))
-
- return bits.Bit(63-accessBit) == 1
+func (bits *accessBitmap) IsSet(i int) bool {
+ return bits[i/8]&(1<<uint(7-i%8)) != 0
}