Documentation ¶
Index ¶
- Constants
- Variables
- func AppendBoardHeaderFileRecord(filename string, newBoardHeader *BoardHeader) error
- func AppendFileHeaderFileRecord(filename string, newFileHeader *FileHeader) error
- func GetBoardArticleFilePath(workDirectory string, boardID string, filename string) (string, error)
- func GetBoardArticlesDirectoryPath(workDirectory string, boardID string) (string, error)
- func GetBoardNameFilePath(workDirectory string, boardID string) (string, error)
- func GetBoardPath(workDirectory string) (string, error)
- func GetBoardTreasureFilePath(workDirectory string, boardID string, path []string, filename string) (string, error)
- func GetBoardTreasuresDirectoryPath(workDirectory string, boardID string, path []string) (string, error)
- func GetLoginRecentPath(workDirectory string, userID string) (string, error)
- func GetPasswdsPath(workDirectory string) (string, error)
- func GetUserDraftPath(workDirectory string, userID string, draftID string) (string, error)
- func GetUserFavoritePath(workDirectory string, userID string) (string, error)
- func GetUserMailPath(workDirectory string, userID string, filename string) (string, error)
- func RemoveBoardHeaderFileRecord(filename string, index int) error
- func UpdateFileHeaderFileRecord(filename string, index uint, fileHeader *FileHeader) error
- type BoardHeader
- func (b *BoardHeader) BM() []string
- func (b *BoardHeader) BoardID() string
- func (b *BoardHeader) ClassID() string
- func (b *BoardHeader) GetPostLimitBadPost() uint8
- func (b *BoardHeader) GetPostLimitLogins() uint8
- func (b *BoardHeader) GetPostLimitPosts() uint8
- func (b *BoardHeader) IsAlignedComment() bool
- func (b *BoardHeader) IsAngelAnonymous() bool
- func (b *BoardHeader) IsAnonymous() bool
- func (b *BoardHeader) IsBMCount() bool
- func (b *BoardHeader) IsBMMaskContent() bool
- func (b *BoardHeader) IsCPLog() bool
- func (b *BoardHeader) IsClass() bool
- func (b *BoardHeader) IsCooldown() bool
- func (b *BoardHeader) IsDefaultAnonymous() bool
- func (b *BoardHeader) IsGroupBoard() bool
- func (b *BoardHeader) IsGuestPost() bool
- func (b *BoardHeader) IsHide() bool
- func (b *BoardHeader) IsIPLogRecommend() bool
- func (b *BoardHeader) IsIsSymbolic() bool
- func (b *BoardHeader) IsNoBoo() bool
- func (b *BoardHeader) IsNoCount() bool
- func (b *BoardHeader) IsNoCredit() bool
- func (b *BoardHeader) IsNoFastRecommend() bool
- func (b *BoardHeader) IsNoRecommend() bool
- func (b *BoardHeader) IsNoReply() bool
- func (b *BoardHeader) IsNoSelfDeletePost() bool
- func (b *BoardHeader) IsOver18() bool
- func (b *BoardHeader) IsPostMask() bool
- func (b *BoardHeader) IsRestrictedPost() bool
- func (b *BoardHeader) IsTop() bool
- func (b *BoardHeader) IsVoteBoard() bool
- func (b *BoardHeader) IsWarnEL() bool
- func (b *BoardHeader) MarshalBinary() ([]byte, error)
- func (b *BoardHeader) SetBoardID(newValue string)
- func (b *BoardHeader) SetTitle(newValue string)
- func (b *BoardHeader) Title() string
- type Cache
- type Connector
- func (c *Connector) AddArticleRecordFileRecord(name string, article bbs.ArticleRecord) error
- func (c *Connector) AddBoardRecordFileRecord(name string, brd bbs.BoardRecord) error
- func (c *Connector) AppendBoardArticleFile(filename string, content []byte) error
- func (c *Connector) CreateBoardArticleFilename(boardID string) (filename string, err error)
- func (c *Connector) DeleteUserDraft(filename string) error
- func (c *Connector) GetBoardArticleFilePath(boardID string, filename string) (string, error)
- func (c *Connector) GetBoardArticleRecordsPath(boardID string) (string, error)
- func (c *Connector) GetBoardRecordsPath() (string, error)
- func (c *Connector) GetBoardTreasureFilePath(boardID string, treasureID []string, filename string) (string, error)
- func (c *Connector) GetBoardTreasureRecordsPath(boardID string, treasureID []string) (string, error)
- func (c *Connector) GetUserDraftPath(userID, draftID string) (string, error)
- func (c *Connector) GetUserFavoriteRecordsPath(userID string) (string, error)
- func (c *Connector) GetUserRecordsPath() (string, error)
- func (c *Connector) NewArticleRecord(filename, owner, date, title string) (bbs.ArticleRecord, error)
- func (c *Connector) NewArticleRecordWithMap(args map[string]interface{}) (bbs.ArticleRecord, error)
- func (c *Connector) NewBoardRecord(args map[string]interface{}) (bbs.BoardRecord, error)
- func (c *Connector) Open(dataSourceName string) error
- func (c *Connector) ReadArticleRecordsFile(filename string) ([]bbs.ArticleRecord, error)
- func (c *Connector) ReadBoardArticleFile(filename string) ([]byte, error)
- func (c *Connector) ReadBoardRecordFileRecord(name string, index uint) (bbs.BoardRecord, error)
- func (c *Connector) ReadBoardRecordsFile(path string) ([]bbs.BoardRecord, error)
- func (c *Connector) ReadUserDraft(filename string) ([]byte, error)
- func (c *Connector) ReadUserFavoriteRecordsFile(filename string) ([]bbs.FavoriteRecord, error)
- func (c *Connector) ReadUserRecordsFile(filename string) ([]bbs.UserRecord, error)
- func (c *Connector) RemoveBoardRecordFileRecord(name string, index uint) error
- func (c *Connector) UpdateArticleRecordFileRecord(filename string, index uint, article bbs.ArticleRecord) error
- func (c *Connector) UpdateBoardRecordFileRecord(name string, index uint, brd bbs.BoardRecord) error
- func (c *Connector) WriteBoardArticleFile(path string, content []byte) error
- func (c *Connector) WriteUserDraft(filename string, draft []byte) error
- type FavAttr
- type FavBoardItem
- type FavFile
- type FavFolder
- type FavFolderItem
- type FavItem
- func (favi *FavItem) BoardID() string
- func (favi *FavItem) GetBoard() *FavBoardItem
- func (favi *FavItem) GetFolder() *FavFolderItem
- func (favi *FavItem) GetLine() *FavLineItem
- func (favi *FavItem) MarshalBinary() ([]byte, error)
- func (favi *FavItem) Records() []bbs.FavoriteRecord
- func (favi *FavItem) Title() string
- func (favi *FavItem) Type() bbs.FavoriteType
- type FavItemType
- type FavLineItem
- type FileHeader
- func (f *FileHeader) AddRecommend(update int8)
- func (f *FileHeader) Date() string
- func (f *FileHeader) Filename() string
- func (f *FileHeader) IsVotePost() bool
- func (f *FileHeader) MarshalToByte() ([]byte, error)
- func (f *FileHeader) Modified() time.Time
- func (f *FileHeader) Money() int
- func (f *FileHeader) Owner() string
- func (f *FileHeader) Recommend() int
- func (f *FileHeader) SetDate(newValue string)
- func (f *FileHeader) SetFilename(newValue string)
- func (f *FileHeader) SetModified(newModified time.Time)
- func (f *FileHeader) SetOwner(newValue string)
- func (f *FileHeader) SetTitle(newValue string)
- func (f *FileHeader) Title() string
- type GameScore
- type LoginAttempt
- type LoginRecentRecord
- type MemoryMappingSetting
- type MessageQueueCache
- type UserInfoCache
- type Userec
- func (u *Userec) HashedPassword() string
- func (u *Userec) LastHost() string
- func (u *Userec) LastLogin() time.Time
- func (u *Userec) MarshalBinary() ([]byte, error)
- func (u *Userec) Money() int
- func (u *Userec) Nickname() string
- func (u *Userec) NumLoginDays() int
- func (u *Userec) NumPosts() int
- func (u *Userec) RealName() string
- func (u *Userec) UserFlag() uint32
- func (u *Userec) UserID() string
- func (u *Userec) VerifyPassword(password string) error
- type VoteLimits
Constants ¶
const ( PosOfBoardName = 0 PosOfBoardTitle = PosOfBoardName + IDLength + 1 PosOfBM = PosOfBoardTitle + BoardTitleLength + 1 PosOfBrdAttr = 3 + PosOfBM + IDLength*3 + 3 PosOfChessCountry = PosOfBrdAttr + 4 PosOfVoteLimitPosts = PosOfChessCountry + 1 PosOfVoteLimitLogins = PosOfVoteLimitPosts + 1 PosOfBUpdate = 1 + PosOfVoteLimitLogins + 1 PosOfPostLimitPosts = PosOfBUpdate + 4 PosOfPostLimitLogins = PosOfPostLimitPosts + 1 PosOfBVote = 1 + PosOfPostLimitLogins + 1 PosOfVTime = PosOfBVote + 1 PosOfLevel = PosOfVTime + 4 PosOfPermReload = PosOfLevel + 4 PosOfGid = PosOfPermReload + 4 PosOfNext = PosOfGid + 4 PosOfFirstChild = PosOfNext + 4*2 PosOfParent = PosOfFirstChild + 4*2 PosOfChildCount = PosOfParent + 4 PosOfNuser = PosOfChildCount + 4 PosOfPostExpire = PosOfNuser + 4 PosOfEndGamble = PosOfPostExpire + 4 PosOfPostType = PosOfEndGamble + 4 PosOfPostTypeF = PosOfPostType + 33 PosOfFastRecommendPause = PosOfPostTypeF + 1 PosOfVoteLimitBadPost = PosOfFastRecommendPause + 1 PosOfPostLimitBadPost = PosOfVoteLimitBadPost + 1 PosOfSRExpire = 3 + PosOfPostLimitBadPost + 1 )
const ( // BoardPostMask https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L211 BoardPostMask = 0x00000020 // BoardGroupBoard https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L209 BoardGroupBoard = 0x00000008 // PermSYSOP https://github.com/ptt/pttbbs/blob/master/include/perm.h#L22 PermSYSOP = 000000040000 // PermBM https://github.com/ptt/pttbbs/blob/master/include/perm.h#L18 PermBM = 000000002000 // BoardHide https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L210 BoardHide = 0x00000010 BoardHeaderRecordLength = 256 )
const ( ////////// //pttstruch.h ////////// // IDLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L13 IDLength = 12 /* Length of bid/uid */ // IPV4Length https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L14 IPV4Length = 15 /* a.b.c.d form */ // PasswordInputLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L49 PasswordInputLength = 8 /* Length of valid input password length. For DES, set to 8. */ // PasswordLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L51 PasswordLength = 14 /* Length of encrypted passwd field */ // RegistrationLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L52 RegistrationLength = 38 /* Length of registration data */ // RealNameSize https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L62 RealNameSize = 20 /* Size of real-name field */ // NicknameSize https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L63 NicknameSize = 24 /* SIze of nick-name field */ // EmailSize https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L53 EmailSize = 50 /* Size of email field */ // AddressSize https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L79 AddressSize = 50 /* Size of address field */ // CareerSize https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L91 CareerSize = 40 /* Size of career field */ // PhoneSize https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L92 PhoneSize = 20 /* Size of phone field */ // PasswdVersion https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L55 PasswdVersion = 4194 /* passwd version */ // TitleLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L253 TitleLength = 64 /* Length of title */ // FileNameLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L254 FileNameLength = 28 /* Length of filename */ // MachineName https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L358 MachineNameLength = 27 /* Length of Machine Name */ // MaxFriend https://github.com/ptt/pttbbs/blob/master/include/config.h#L224 MaxFriend = 256 // MaxReject https://github.com/ptt/pttbbs/blob/master/include/config.h#L228 MaxReject = 32 // MaxMsgs https://github.com/ptt/pttbbs/blob/master/include/config.h#L232 MaxMsgs = 10 // ChatIDLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L408 ChatIDLength = 11 )
const ( ////////// //pttstruch.h: 292 ////////// // FileLocal https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L292 FileLocal = 0x01 /* local saved, non-mail */ // FileRead https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L293 FileRead = 0x01 /* already read, mail only */ // FileMarked https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L294 FileMarked = 0x02 /* non-mail + mail */ // FileDigest https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L295 FileDigest = 0x04 /* digest, non-mail */ // FileReplied https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L296 FileReplied = 0x04 /* replied, mail only */ // FileBottom https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L297 FileBottom = 0x08 /* push_bottom, non-mail */ // FileMulti https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L298 FileMulti = 0x08 /* multi send, mail only */ // FileSolved https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L299 FileSolved = 0x10 /* problem solved, sysop/BM non-mail only */ // FileHide https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L300 FileHide = 0x20 /* hide, in announce */ // FileBoardID https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L301 FileBoardID = 0x20 /* bid, in non-announce */ // FileBoardMaster https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L302 FileBoardMaster = 0x40 /* BM only, in announce */ // FileVote https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L303 FileVote = 0x40 /* for vote, in non-announce */ // FileAnonymous https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L304 FileAnonymous = 0x80 /* anonymous file */ )
const ( //////////// // uflags.h // (https://github.com/ptt/pttbbs/blob/master/include/uflags.h) //////////// UfFavNohilight uint32 = 0x00000001 /* false if hilight favorite */ UfFavAddnew uint32 = 0x00000002 /* true to add new board into one's fav */ // UfPager uint32 = 0x00000004 /* deprecated by cuser.pager: true if pager was OFF last session */ // UfCloak uint32 = 0x00000008 /* deprecated by cuser.invisible: true if cloak was ON last session */ UfFriend uint32 = 0x00000010 /* true if show friends only */ UfBrdsort uint32 = 0x00000020 /* true if the boards sorted alphabetical */ // UfMind uint32 = 0x00000100 /* deprecated: true if mind search mode open <-Heat */ UfDbcsAware uint32 = 0x00000200 /* true if DBCS-aware enabled */ UfDbcsNointresc uint32 = 0x00000400 /* no Escapes interupting DBCS characters */ UfDbscDropRepeat uint32 = 0x00000800 /* detect and drop repeated input from evil clients */ UfNoModmark uint32 = 0x00001000 /* true if modified files are NOT marked */ UfColoredModmark uint32 = 0x00002000 /* true if mod-mark is coloured */ // UfModmark??? uint32 = 0x00004000 /* reserved */ // UfModmark??? uint32 = 0x00008000 /* reserved */ UfDefbackup uint32 = 0x00010000 /* true if user defaults to backup */ UfNewAngelPager uint32 = 0x00020000 /* true if user (angel) wants the new pager */ UfRejOuttamail uint32 = 0x00040000 /* true if don't accept outside mails */ UfSecureLogin uint32 = 0x00080000 /* true if login from insecure (ex, telnet) connection will be rejected */ UfForeign uint32 = 0x00100000 /* true if a foreign */ UfLiveright uint32 = 0x00200000 /* true if get "liveright" already */ // UfCountry??? uint32 = 0x00400000 /* reserved */ // UfCountry??? uint32 = 0x00800000 /* reserved */ UfMenuLightbar uint32 = 0x01000000 /* true to use lightbar-based menu */ UfCursorASCII uint32 = 0x02000000 /* true to enable ASCII-safe cursor */ )
const ( PosOfFileHeaderFilename = 0 PosOfFileHeaderModified = PosOfFileHeaderFilename + FileNameLength PosOfFileHeaderRecommend = 1 + PosOfFileHeaderModified + 4 PosOfFileHeaderOwner = PosOfFileHeaderRecommend + 1 PosOfFileHeaderDate = PosOfFileHeaderOwner + IDLength + 2 PosOfFileHeaderTitle = PosOfFileHeaderDate + 6 PosOfFileHeaderUnionMulti = 1 + PosOfFileHeaderTitle + TitleLength + 1 PosOfFileHeaderFilemode = PosOfFileHeaderUnionMulti + 4 )
const ( PosOfPasswdVersion = 0 PosOfPasswdUserID = PosOfPasswdVersion + 4 PosOfPasswdRealName = PosOfPasswdUserID + IDLength + 1 PosOfPasswdNickname = PosOfPasswdRealName + RealNameSize PosOfPasswdPassword = PosOfPasswdNickname + NicknameSize PosOfPasswdUserFlag = 1 + PosOfPasswdPassword + PasswordLength PosOfPasswdUserLevel = 4 + PosOfPasswdUserFlag + 4 PosOfPasswdNumLoginDays = PosOfPasswdUserLevel + 4 PosOfPasswdNumPosts = PosOfPasswdNumLoginDays + 4 PosOfPasswdFirstLogin = PosOfPasswdNumPosts + 4 PosOfPasswdLastLogin = PosOfPasswdFirstLogin + 4 PosOfPasswdLastHost = PosOfPasswdLastLogin + 4 PosOfPasswdMoney = PosOfPasswdLastHost + IPV4Length + 1 PosOfPasswdEmail = 4 + PosOfPasswdMoney + 4 PosOfPasswdAddress = PosOfPasswdEmail + EmailSize PosOfPasswdJustify = PosOfPasswdAddress + AddressSize PosOfPasswdOver18 = 3 + PosOfPasswdJustify + RegistrationLength + 1 PosOfPasswdPagerUIType = PosOfPasswdOver18 + 1 PosOfPasswdPager = PosOfPasswdPagerUIType + 1 PosOfPasswdInvisible = PosOfPasswdPager + 1 PosOfPasswdExMailBox = 2 + PosOfPasswdInvisible + 1 PosOfPasswdCareer = 4 + PosOfPasswdExMailBox + 4 PosOfPasswdRole = 20 + 4 + 44 + PosOfPasswdCareer + CareerSize PosOfPasswdLastSeen = PosOfPasswdRole + 4 PosOfPasswdTimeSetAngel = PosOfPasswdLastSeen + 4 PosOfPasswdTimePlayAngel = PosOfPasswdTimeSetAngel + 4 PosOfPasswdLastSong = PosOfPasswdTimePlayAngel + 4 PosOfPasswdLoginView = PosOfPasswdLastSong + 4 PosOfPasswdLawCounter = 1 + 1 + PosOfPasswdLoginView + 4 PosOfPasswdFiveWin = PosOfPasswdLawCounter + 2 PosOfPasswdFiveLose = PosOfPasswdFiveWin + 2 PosOfPasswdFiveTie = PosOfPasswdFiveLose + 2 PosOfPasswdChcWin = PosOfPasswdFiveTie + 2 PosOfPasswdChcLose = PosOfPasswdChcWin + 2 PosOfPasswdChcTie = PosOfPasswdChcLose + 2 PosOfPasswdConn6Win = PosOfPasswdChcTie + 2 PosOfPasswdConn6Lose = PosOfPasswdConn6Win + 2 PosOfPasswdConn6Tie = PosOfPasswdConn6Lose + 2 PosOfPasswdGoWin = 2 + PosOfPasswdConn6Tie + 2 PosOfPasswdGoLose = PosOfPasswdGoWin + 2 PosOfPasswdGoTie = PosOfPasswdGoLose + 2 PosOfPasswdDarkWin = PosOfPasswdGoTie + 2 PosOfPasswdDarkLose = PosOfPasswdDarkWin + 2 PosOfPasswdUaVersion = PosOfPasswdDarkLose + 2 PosOfPasswdSignature = PosOfPasswdUaVersion + 1 PosOfPasswdBadPost = 1 + PosOfPasswdSignature + 1 PosOfPasswdDarkTie = PosOfPasswdBadPost + 1 PosOfPasswdMyAngel = PosOfPasswdDarkTie + 2 PosOfPasswdChessEloRating = 1 + PosOfPasswdMyAngel + IDLength + 1 PosOfPasswdWithMe = PosOfPasswdChessEloRating + 2 PosOfPasswdTimeRemoveBadPost = PosOfPasswdWithMe + 4 PosOfPasswdTimeViolateLaw = PosOfPasswdTimeRemoveBadPost + 4 )
const ( PosOfUserInfoUID = 0 PosOfUserInfoPID = PosOfUserInfoUID + 4 PosOfUserInfoSockAddr = PosOfUserInfoPID + 4 PosOfUserInfoUserLevel = PosOfUserInfoSockAddr + 4 PosOfUserInfoUserID = PosOfUserInfoUserLevel + 4 PosOfUserInfoNickname = PosOfUserInfoUserID + IDLength + 1 PosOfUserInfoFrom = PosOfUserInfoNickname + NicknameSize PosOfUserInfoFromIP = PosOfUserInfoFrom + MachineNameLength PosOfUserInfoDarkWin = PosOfUserInfoFromIP + 4 PosOfUserInfoDarkLose = PosOfUserInfoDarkWin + 2 PosOfUserInfoAngelPause = PosOfUserInfoDarkLose + 2 + 1 // gap_0 PosOfUserInfoDarkTie = PosOfUserInfoAngelPause + 1 PosOfUserInfoFriendTotal = PosOfUserInfoDarkTie + 2 PosOfUserInfoNumFriends = PosOfUserInfoFriendTotal + 4 PosOfUserInfoMyFriend = PosOfUserInfoNumFriends + 2 + 2 // _unused3 PosOfUserInfoFriendOnline = PosOfUserInfoMyFriend + MaxFriend*4 + 4 // gap_1 PosOfUserInfoReject = PosOfUserInfoFriendOnline + MaxFriend*4 + 4 // gap_2 PosOfUserInfoMsgCount = PosOfUserInfoReject + MaxReject*4 + 4 // gap_3 PosOfUserInfoMsgs = PosOfUserInfoMsgCount + 1 + 3 // _unused4 PosOfUserInfoBirth = PosOfUserInfoMsgs + MaxMsgs*100 + 100 // gap_4 and 100 is the size of msgque_t when run on my machine PosOfUserInfoActive = PosOfUserInfoBirth + 1 PosOfUserInfoInvisible = PosOfUserInfoActive + 1 PosOfUserInfoMode = PosOfUserInfoInvisible + 1 PosOfUserInfoPager = PosOfUserInfoMode + 1 PosOfUserInfoConn6Win = PosOfUserInfoPager + 1 + 1 // unused5 PosOfUserInfoLastAct = PosOfUserInfoConn6Win + 2 PosOfUserInfoAlerts = PosOfUserInfoLastAct + 4 PosOfUserInfoConn6Lose = PosOfUserInfoAlerts + 1 + 1 // unused_mind PosOfUserInfoSig = PosOfUserInfoConn6Lose + 2 + 1 // unused_mind2 PosOfUserInfoConn6Tie = PosOfUserInfoSig + 1 PosOfUserInfoDestUID = PosOfUserInfoConn6Tie + 2 PosOfUserInfoDestUIP = PosOfUserInfoDestUID + 4 PosOfUserInfoSockActive = PosOfUserInfoDestUIP + 4 PosOfUserInfoInChat = PosOfUserInfoSockActive + 1 PosOfUserInfoChatID = PosOfUserInfoInChat + 1 PosOfUserInfoLockMode = PosOfUserInfoChatID + ChatIDLength PosOfUserInfoTurn = PosOfUserInfoLockMode + 1 PosOfUserInfoMateID = PosOfUserInfoTurn + 1 PosOfUserInfoColor = PosOfUserInfoMateID + IDLength + 1 PosOfUserInfoFiveWin = PosOfUserInfoColor + 1 PosOfUserInfoFiveLose = PosOfUserInfoFiveWin + 2 PosOfUserInfoFiveTie = PosOfUserInfoFiveLose + 2 PosOfUserInfoChcWin = PosOfUserInfoFiveTie + 2 PosOfUserInfoChcLose = PosOfUserInfoChcWin + 2 PosOfUserInfoChcTie = PosOfUserInfoFiveLose + 2 PosOfUserInfoChessEloRating = PosOfUserInfoChcTie + 2 PosOfUserInfoGoWin = PosOfUserInfoChessEloRating + 2 PosOfUserInfoGoLose = PosOfUserInfoGoWin + 2 PosOfUserInfoGoTie = PosOfUserInfoGoLose + 2 PosOfUserInfoWithMe = PosOfUserInfoGoTie + 2 PosOfUserInfoBrcID = PosOfUserInfoWithMe + 4 PosOfUserInfoWBTime = PosOfUserInfoBrcID + 4 )
const (
// BoardTitleLength https://github.com/ptt/pttbbs/blob/master/include/pttstruct.h#L165
BoardTitleLength = 48
)
const ( // commmon.h: 232 // MaxRecommends max recommend count MaxRecommends = 100 )
const (
TIME4TBytes = 4 // Bytes for time4_t
)
const (
// UserIDLength is fixed to 12
UserIDLength = 12
)
Variables ¶
var ( ErrInvalidFavType = errors.New("invalid Favorite type") ErrIndexOutOfBound = errors.New("index out of range, file format invalid") )
var (
ErrInvalidLoginsBadFormat = errors.New("Invalid logins.bad line format")
)
Functions ¶
func AppendBoardHeaderFileRecord ¶
func AppendBoardHeaderFileRecord(filename string, newBoardHeader *BoardHeader) error
func AppendFileHeaderFileRecord ¶ added in v0.5.0
func AppendFileHeaderFileRecord(filename string, newFileHeader *FileHeader) error
func GetBoardArticleFilePath ¶
Get Directory article file path of board, `workDirectory` is BBSHome usually, `boardID` means which board, and filename is actual file in board, notice that, we will check is file exist or user has permission for open this file. eg, .DIR file, so please check filename before call this function.
func GetBoardArticlesDirectoryPath ¶
Get Directory normal file path of board
func GetBoardNameFilePath ¶
Get Directory digest file path of board
func GetBoardPath ¶
Get Board file path of system
func GetBoardTreasuresDirectoryPath ¶
func GetBoardTreasuresDirectoryPath(workDirectory string, boardID string, path []string) (string, error)
GetBoardTreasuresDirectoryPath return dir file path of specific board and path, `workDirectory` is BBSHome usually, `boardID` means which board and `path` is a slice figure out each directory, eg: `["M.971228479.A", "M.1035338027.A"]` in formosa BBS or `["D690", "D6C2", "D6D1"]` in pttbbs.
func GetLoginRecentPath ¶
Get Login Recent file path of user
func GetPasswdsPath ¶
Get Passwd file path of system
func GetUserDraftPath ¶ added in v0.5.0
Get Draft file path of user
func GetUserFavoritePath ¶
Get Favorite file path of user
func GetUserMailPath ¶
Get Directory digest file path of board, `workDirectory` is BBSHome usually, `userID` means which user, and filename is actual file in user, notice that, we will check is file exist or user has permission for open this file. eg, .DIR file, so please check filename before call this function.
func UpdateFileHeaderFileRecord ¶ added in v0.8.1
func UpdateFileHeaderFileRecord(filename string, index uint, fileHeader *FileHeader) error
Types ¶
type BoardHeader ¶
type BoardHeader struct { BrdName string Brdattr uint32 // uid[.] ChessCountry string VoteLimitPosts uint8 VoteLimitLogins uint8 BUpdate time.Time PostLimitPosts uint8 PostLimitLogins uint8 BVote uint8 VTime time.Time Level uint32 PermReload time.Time // Parent class id, first item is start from 1. Gid int32 Next []int32 FirstChild []int32 Parent int32 ChildCount int32 Nuser int32 PostExpire int32 EndGamble time.Time PostType string PostTypeF string FastRecommendPause uint8 VoteLimitBadPost uint8 PostLimitBadPost uint8 SRexpire time.Time // contains filtered or unexported fields }
func NewBoardHeader ¶ added in v0.3.0
func NewBoardHeader() *BoardHeader
func OpenBoardHeaderFile ¶
func OpenBoardHeaderFile(filename string) ([]*BoardHeader, error)
func UnmarshalBoardHeader ¶ added in v0.4.0
func UnmarshalBoardHeader(data []byte) (*BoardHeader, error)
func (*BoardHeader) BM ¶
func (b *BoardHeader) BM() []string
func (*BoardHeader) BoardID ¶ added in v0.3.0
func (b *BoardHeader) BoardID() string
func (*BoardHeader) ClassID ¶ added in v0.3.0
func (b *BoardHeader) ClassID() string
func (*BoardHeader) GetPostLimitBadPost ¶ added in v0.5.0
func (b *BoardHeader) GetPostLimitBadPost() uint8
func (*BoardHeader) GetPostLimitLogins ¶ added in v0.5.0
func (b *BoardHeader) GetPostLimitLogins() uint8
func (*BoardHeader) GetPostLimitPosts ¶ added in v0.5.0
func (b *BoardHeader) GetPostLimitPosts() uint8
func (*BoardHeader) IsAlignedComment ¶
func (b *BoardHeader) IsAlignedComment() bool
func (*BoardHeader) IsAngelAnonymous ¶
func (b *BoardHeader) IsAngelAnonymous() bool
func (*BoardHeader) IsAnonymous ¶
func (b *BoardHeader) IsAnonymous() bool
func (*BoardHeader) IsBMCount ¶
func (b *BoardHeader) IsBMCount() bool
func (*BoardHeader) IsBMMaskContent ¶
func (b *BoardHeader) IsBMMaskContent() bool
func (*BoardHeader) IsCPLog ¶
func (b *BoardHeader) IsCPLog() bool
func (*BoardHeader) IsClass ¶
func (b *BoardHeader) IsClass() bool
func (*BoardHeader) IsCooldown ¶
func (b *BoardHeader) IsCooldown() bool
func (*BoardHeader) IsDefaultAnonymous ¶
func (b *BoardHeader) IsDefaultAnonymous() bool
func (*BoardHeader) IsGroupBoard ¶
func (b *BoardHeader) IsGroupBoard() bool
func (*BoardHeader) IsGuestPost ¶
func (b *BoardHeader) IsGuestPost() bool
func (*BoardHeader) IsHide ¶
func (b *BoardHeader) IsHide() bool
func (*BoardHeader) IsIPLogRecommend ¶
func (b *BoardHeader) IsIPLogRecommend() bool
func (*BoardHeader) IsIsSymbolic ¶
func (b *BoardHeader) IsIsSymbolic() bool
func (*BoardHeader) IsNoBoo ¶
func (b *BoardHeader) IsNoBoo() bool
func (*BoardHeader) IsNoCount ¶
func (b *BoardHeader) IsNoCount() bool
func (*BoardHeader) IsNoCredit ¶
func (b *BoardHeader) IsNoCredit() bool
func (*BoardHeader) IsNoFastRecommend ¶
func (b *BoardHeader) IsNoFastRecommend() bool
func (*BoardHeader) IsNoRecommend ¶
func (b *BoardHeader) IsNoRecommend() bool
func (*BoardHeader) IsNoReply ¶
func (b *BoardHeader) IsNoReply() bool
func (*BoardHeader) IsNoSelfDeletePost ¶
func (b *BoardHeader) IsNoSelfDeletePost() bool
func (*BoardHeader) IsOver18 ¶
func (b *BoardHeader) IsOver18() bool
func (*BoardHeader) IsPostMask ¶
func (b *BoardHeader) IsPostMask() bool
func (*BoardHeader) IsRestrictedPost ¶
func (b *BoardHeader) IsRestrictedPost() bool
func (*BoardHeader) IsTop ¶
func (b *BoardHeader) IsTop() bool
func (*BoardHeader) IsVoteBoard ¶
func (b *BoardHeader) IsVoteBoard() bool
func (*BoardHeader) IsWarnEL ¶
func (b *BoardHeader) IsWarnEL() bool
func (*BoardHeader) MarshalBinary ¶
func (b *BoardHeader) MarshalBinary() ([]byte, error)
func (*BoardHeader) SetBoardID ¶ added in v0.3.0
func (b *BoardHeader) SetBoardID(newValue string)
func (*BoardHeader) SetTitle ¶ added in v0.3.0
func (b *BoardHeader) SetTitle(newValue string)
func (*BoardHeader) Title ¶
func (b *BoardHeader) Title() string
type Cache ¶ added in v0.3.0
type Cache struct { cache.Cache *MemoryMappingSetting // contains filtered or unexported fields }
Cache provides an IPC(inter-process communication) bridge with process-based pttbbs process, and shars the cache with board info, user info ...
func NewCache ¶ added in v0.3.0
func NewCache(connectionString string, settings *MemoryMappingSetting) (*Cache, error)
NewCache returns Cache (SHM) by connectionString, connectionString indicate the shm location with uri format eg. shmkey:1228 or file:/tmp/ramdisk/bbs.shm
func (*Cache) Money ¶ added in v0.3.0
Money returns the money user have with specific uid, uid start with 0
func (*Cache) UserID ¶ added in v0.3.0
UserID returns userId string with specific uid, such as "SYSOP", uid means the index in PASSWD file, start with 0.
func (*Cache) UserInfo ¶ added in v0.3.0
func (c *Cache) UserInfo(uid int) *UserInfoCache
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
func (*Connector) AddArticleRecordFileRecord ¶ added in v0.5.0
func (*Connector) AddBoardRecordFileRecord ¶ added in v0.3.0
AddBoardRecordFileRecord given record file name and new record, should append file record in that file.
func (*Connector) AppendBoardArticleFile ¶ added in v0.8.1
func (*Connector) CreateBoardArticleFilename ¶ added in v0.8.1
CreateBoardArticleFilename get available filename for board with boardID, it will test is this filename not exist And open a file to occupy this filename Please see fhdr_stamp in pttbbs fhdr_stamp.c also
func (*Connector) DeleteUserDraft ¶ added in v0.5.0
func (*Connector) GetBoardArticleFilePath ¶
func (*Connector) GetBoardArticleRecordsPath ¶
func (*Connector) GetBoardRecordsPath ¶
func (*Connector) GetBoardTreasureFilePath ¶
func (*Connector) GetBoardTreasureRecordsPath ¶
func (*Connector) GetUserDraftPath ¶ added in v0.5.0
func (*Connector) GetUserFavoriteRecordsPath ¶
func (*Connector) GetUserRecordsPath ¶
func (*Connector) NewArticleRecord ¶ added in v0.5.0
func (c *Connector) NewArticleRecord(filename, owner, date, title string) (bbs.ArticleRecord, error)
NewArticleRecord returns a new ArticleRecord given a filename, owner, date, title
func (*Connector) NewArticleRecordWithMap ¶ added in v0.8.1
func (*Connector) NewBoardRecord ¶ added in v0.3.0
func (*Connector) Open ¶
Open connect a file directory or SHMs, dataSourceName pointer to bbs home And it can append argument for SHM for example `file:///home/bbs/?UTMP=1993`
func (*Connector) ReadArticleRecordsFile ¶
func (*Connector) ReadBoardArticleFile ¶
ReadBoardArticleFile returns raw file of specific filename article.
func (*Connector) ReadBoardRecordFileRecord ¶ added in v0.3.0
ReadBoardRecordFileRecord return boardRecord brd on index in record file.
func (*Connector) ReadBoardRecordsFile ¶
func (*Connector) ReadUserDraft ¶ added in v0.6.0
func (*Connector) ReadUserFavoriteRecordsFile ¶
func (*Connector) ReadUserRecordsFile ¶
func (*Connector) RemoveBoardRecordFileRecord ¶ added in v0.3.0
RemoveBoardRecordFileRecord remove boardRecord brd on index in record file.
func (*Connector) UpdateArticleRecordFileRecord ¶ added in v0.8.1
func (*Connector) UpdateBoardRecordFileRecord ¶ added in v0.3.0
UpdateBoardRecordFileRecord update boardRecord brd on index in record file, index is start with 0
func (*Connector) WriteBoardArticleFile ¶ added in v0.8.1
type FavBoardItem ¶
type FavBoardItem struct { BoardID uint32 LastVisit time.Time Attr uint32 // contains filtered or unexported fields }
FavBoardItem represents a Board in FavFolder. FavBoardItem takes 12 bytes
func UnmarshalFavBoardItem ¶ added in v0.4.0
func UnmarshalFavBoardItem(data []byte, startIndex int) (*FavBoardItem, int, error)
UnmarshalFavBoardItem takes a []byte and parse it starting from startIndex, return FavBoardItem, end index and error
func (*FavBoardItem) MarshalBinary ¶
func (favbi *FavBoardItem) MarshalBinary() ([]byte, error)
type FavFile ¶
FavFile represents the entire fav file. Starts with 2 bytes of Version and at most 1 FavFolder.
func UnmarshalFavFile ¶ added in v0.4.0
UnmarshalFavFile parse data and return FavFile
func (*FavFile) MarshalBinary ¶
type FavFolder ¶
type FavFolder struct { NAlloc uint16 DataTail uint16 NBoards uint16 NLines uint8 NFolders uint8 LineID uint8 FolderID uint8 FavItems []*FavItem }
FavFolder represents a folder in .fav file. Each folder could contain NBoards of board, NLines of lines and NFolders of sub-folders.
func UnmarshalFavFolder ¶ added in v0.4.0
UnmarshalFavFolder takes a []byte, parse it starting with startIndex, return an instance of FavFolder, endIndex and error.
func (*FavFolder) MarshalBinary ¶
type FavFolderItem ¶
FavFolderItem represents a Folder in FavFolder. FavFolderItem takes 50 bytes
func UnmarshalFavFolderItem ¶ added in v0.4.0
func UnmarshalFavFolderItem(data []byte, startIndex int) (*FavFolderItem, int, error)
UnmarshalFavFolderItem takes a []byte and parse it starting from startIndex, return FavFolderItem, end index and error
func (*FavFolderItem) MarshalBinary ¶
func (favfi *FavFolderItem) MarshalBinary() ([]byte, error)
type FavItem ¶
type FavItem struct { FavType FavItemType FavAttr uint8 Item interface{} // This could be either FavBoardItem / FavFolderItem / FavLineItem }
FavItem represents 1 Item in FavFolder
func UnmarshalFavItem ¶ added in v0.4.0
UnmarshalFavItem parse data starting from startIndex and return FavItem. FavItem.Item might be either FavBoardItem, FavFolderItem or FavLineItem
func (*FavItem) GetBoard ¶
func (favi *FavItem) GetBoard() *FavBoardItem
GetBoard tries to cast Item to FavBoardItem; return nil if it is not
func (*FavItem) GetFolder ¶
func (favi *FavItem) GetFolder() *FavFolderItem
GetFolder tries to cast Item to FavFolderItem; return nil if it is not
func (*FavItem) GetLine ¶
func (favi *FavItem) GetLine() *FavLineItem
GetLine tries to cast Item to FavLineItem; return nil if it is not
func (*FavItem) MarshalBinary ¶
type FavItemType ¶
type FavItemType uint8
const ( FavItemTypeBoard FavItemType = 1 // FAVT_BOARD FavItemTypeFolder FavItemType = 2 // FAVT_FOLDER FavItemTypeLine FavItemType = 3 // FAVT_LINE )
type FavLineItem ¶
type FavLineItem struct {
LineID uint8
}
FavLineItem represents a Line in FavFolder. FavLineItem takes 1 byte
func UnmarshalFavLineItem ¶ added in v0.4.0
func UnmarshalFavLineItem(data []byte, startIndex int) (*FavLineItem, int, error)
UnmarshalFavLineItem takes a []byte and parse it starting from startIndex, return FavLineItem, end index and error
func (*FavLineItem) MarshalBinary ¶
func (favli *FavLineItem) MarshalBinary() ([]byte, error)
type FileHeader ¶
type FileHeader struct { AnnoUID int VoteLimits ReferRef uint // 至底公告? ReferFlag bool // 至底公告? Filemode uint8 // contains filtered or unexported fields }
FileHeader records article's metainfo
func NewFileHeader ¶ added in v0.5.0
func NewFileHeader() *FileHeader
func NewFileHeaderWithByte ¶
func NewFileHeaderWithByte(data []byte) (*FileHeader, error)
func OpenFileHeaderFile ¶
func OpenFileHeaderFile(filename string) ([]*FileHeader, error)
OpenFileHeaderFile function open a .DIR file in board directory. It returns slice of FileHeader.
func (*FileHeader) AddRecommend ¶ added in v0.6.0
func (f *FileHeader) AddRecommend(update int8)
func (*FileHeader) Date ¶
func (f *FileHeader) Date() string
func (*FileHeader) Filename ¶
func (f *FileHeader) Filename() string
func (*FileHeader) IsVotePost ¶
func (f *FileHeader) IsVotePost() bool
func (*FileHeader) MarshalToByte ¶
func (f *FileHeader) MarshalToByte() ([]byte, error)
func (*FileHeader) Modified ¶
func (f *FileHeader) Modified() time.Time
func (*FileHeader) Money ¶
func (f *FileHeader) Money() int
func (*FileHeader) Owner ¶
func (f *FileHeader) Owner() string
func (*FileHeader) Recommend ¶
func (f *FileHeader) Recommend() int
func (*FileHeader) SetDate ¶ added in v0.5.0
func (f *FileHeader) SetDate(newValue string)
func (*FileHeader) SetFilename ¶ added in v0.5.0
func (f *FileHeader) SetFilename(newValue string)
func (*FileHeader) SetModified ¶ added in v0.6.0
func (f *FileHeader) SetModified(newModified time.Time)
func (*FileHeader) SetOwner ¶ added in v0.5.0
func (f *FileHeader) SetOwner(newValue string)
func (*FileHeader) SetTitle ¶ added in v0.5.0
func (f *FileHeader) SetTitle(newValue string)
func (*FileHeader) Title ¶
func (f *FileHeader) Title() string
type LoginAttempt ¶
LoginAttempt represents an entry in logins.bad file to indicate a successful or failed login attempt for a UserID. Note that UserID could be empty if the logins.bad is under user dir.
func OpenBadLoginFile ¶
func OpenBadLoginFile(filename string) ([]*LoginAttempt, error)
OpenBadLoginFile opens logins.bad file and returns a slice of LoginAttempt. Note that depending on different format of logins.bad as descirbed above, each LoginAttempt might not have LoginAttempt.UserID field
func (*LoginAttempt) IsUnderBbsHome ¶
func (l *LoginAttempt) IsUnderBbsHome() bool
IsUnderBbsHome return true if this LoginAttempt was read from logins.bad from under BBSHOME. The difference between logins.bad between under BBSHOME and under User Dir is whether it contains UserID
func (*LoginAttempt) MarshalText ¶
func (l *LoginAttempt) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler to marshal receiver to text
func (*LoginAttempt) UnmarshalText ¶
func (l *LoginAttempt) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler to unmarshal text to the receiver
type LoginRecentRecord ¶
LoginRecentRecord records Login record, please see https://github.com/ptt/pttbbs/blob/446c2bc34867286a2a093615ea69501f32c127e4/mbbsd/mbbsd.c#L1123
func NewLoginRecentRecord ¶
func NewLoginRecentRecord(line string) (*LoginRecentRecord, error)
func OpenLoginRecentFile ¶
func OpenLoginRecentFile(filename string) ([]*LoginRecentRecord, error)
type MemoryMappingSetting ¶ added in v0.3.0
type MemoryMappingSetting struct { AlignmentBytes int // 1, 2, 4 or 8, 1 for no aligment MaxUsers int IDLen int UseCoolDown bool HashBits int }
MemoryMappingSetting provides parameters for calculating the memory position of
the relevant fields.
type MessageQueueCache ¶ added in v0.3.0
type MessageQueueCache []byte
MessageQueueCache is `msgque_t` in pttstruct.h, all of those object will be store in shared memory
type UserInfoCache ¶ added in v0.3.0
type UserInfoCache struct { SockAddr int32 UserLevel uint32 DarkChess GameScore AngelPause uint8 FriendTotal int32 NumFriends int16 MyFriend [MaxFriend]int32 FriendOnline [MaxFriend]uint32 Reject [MaxReject]int32 MsgCount uint8 Msgs [MaxMsgs]MessageQueueCache Birth bool // whether it's birthday today Active bool Invisible bool Mode uint8 Pager bool Conn6 GameScore LastAct time.Time Alerts uint8 // mail alert, passwd update ... Signature uint8 DestUID int32 DestUIP int32 SockActive uint8 InChat uint8 ChatID string LockMode uint8 Turn bool MateID string Color uint8 // game record Five GameScore ChineseChess GameScore ChessEloRating uint16 GoChess GameScore WithMe uint32 // contains filtered or unexported fields }
UserInfoCache is `userinfo_t` in pttstruct.h, all of those object will be store in shared memory
func OpenUserInfoCache ¶ added in v0.12.0
func OpenUserInfoCache(filename string) ([]*UserInfoCache, error)
function used for testing unmarshal and marshal function
func UnmarshalUserInfo ¶ added in v0.12.0
func UnmarshalUserInfo(data []byte) *UserInfoCache
func (*UserInfoCache) MarshalBinary ¶ added in v0.12.0
func (u *UserInfoCache) MarshalBinary() []byte
type Userec ¶
type Userec struct { Version uint32 // Magic Number UserLevel uint32 // 權限 Email string Address string Justify string Over18 bool PagerUIType uint8 Pager uint8 Invisible bool ExMailBox uint32 Career string Role uint32 LastSeen time.Time TimeSetAngel time.Time TimePlayAngel time.Time LastSong time.Time LoginView uint32 ViolateLaw uint16 Five GameScore ChineseChess GameScore Conn6 GameScore GoChess GameScore DarkChess GameScore UaVersion uint8 // User Agreement Version Signature uint8 BadPost uint8 MyAngel string ChessEloRating uint16 WithMe uint32 TimeRemoveBadPost time.Time TimeViolateLaw time.Time // contains filtered or unexported fields }
func OpenUserecFile ¶
func UnmarshalUserec ¶ added in v0.4.0
func (*Userec) HashedPassword ¶
func (*Userec) MarshalBinary ¶ added in v0.4.0
func (*Userec) Nickname ¶
Nickname return a string for user's nickname, this string may change depend on user's mood, return empty string if this bbs system do not support
func (*Userec) NumLoginDays ¶
NumLoginDays return how many days this have been login since account created.
func (*Userec) RealName ¶
RealName return a string for user's real name, this string may not be changed return empty string if this bbs system do not support
func (*Userec) UserFlag ¶
UserFlag return user setting. uint32, see https://github.com/ptt/pttbbs/blob/master/include/uflags.h
func (*Userec) VerifyPassword ¶
VerifyPassword will check user's password is OK. it will return null when OK and error when there are something wrong