]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/access.go
Add initial support for resource and info forks
[rbdr/mobius] / hotline / access.go
index 21b438f79e29cfe1f0e8516a447e82af8a07d2b9..f2e904d3eeb3fbe67d9b7c518a15b4c3eb54ff67 100644 (file)
@@ -6,8 +6,6 @@ import (
 )
 
 const (
-       accessAlwaysAllow      = -1 // Some transactions are always allowed
-
        // File System Maintenance
        accessDeleteFile   = 0
        accessUploadFile   = 1
@@ -28,15 +26,15 @@ const (
        accessOpenUser   = 16
        accessModifyUser = 17
        // accessChangeOwnPass    = 18 // Documented but unused?
-       accessSendPrivMsg      = 19 // This doesn't do what it seems like it should do. TODO: Investigate
-       accessNewsReadArt      = 20
-       accessNewsPostArt      = 21
-       accessDisconUser       = 22 // Toggles red user name in user list
-       accessCannotBeDiscon   = 23
-       accessGetClientInfo    = 24
-       accessUploadAnywhere   = 25
-       accessAnyName          = 26
-       accessNoAgreement      = 27
+       // accessSendPrivMsg      = 19 // This doesn't do what it seems like it should do. TODO: Investigate
+       accessNewsReadArt    = 20
+       accessNewsPostArt    = 21
+       accessDisconUser     = 22 // Toggles red user name in user list
+       accessCannotBeDiscon = 23
+       accessGetClientInfo  = 24
+       accessUploadAnywhere = 25
+       // accessAnyName          = 26
+       // accessNoAgreement      = 27
        accessSetFileComment   = 28
        accessSetFolderComment = 29
        accessViewDropBoxes    = 30
@@ -44,16 +42,21 @@ const (
        accessBroadcast        = 32
        accessNewsDeleteArt    = 33
        accessNewsCreateCat    = 34
-       accessNewsDeleteCat    = 35
-       accessNewsCreateFldr   = 36
-       accessNewsDeleteFldr   = 37
+       // accessNewsDeleteCat    = 35
+       accessNewsCreateFldr = 36
+       // accessNewsDeleteFldr   = 37
 )
 
+type accessBitmap [8]byte
+
+func (bits *accessBitmap) Set(i int) {
+       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 {
-       if accessBit == accessAlwaysAllow {
-               return true
-       }
-       accessBitmap := big.NewInt(int64(binary.BigEndian.Uint64(*access)))
+       bits := big.NewInt(int64(binary.BigEndian.Uint64(*access)))
 
-       return accessBitmap.Bit(63-accessBit) == 1
+       return bits.Bit(63-accessBit) == 1
 }