fav

package
v0.14.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2021 License: GPL-3.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const (
	FAV_MAXDEPTH      = 5
	MAX_FAV           = 1024
	MAX_LINE          = 64
	MAX_FOLDER        = 64
	NEW_FAV_THRESHOLD = 12
)
View Source
const (
	FAV   = ".fav"
	FAV4  = ".fav4"
	FAVNB = ".favnb"
)
View Source
const (
	FAV_VERSION int16 = 3363
)
View Source
const SIZE_OF_FAV4_BOARD = unsafe.Sizeof(Fav4Board{})
View Source
const SIZE_OF_FAV4_FOLDER = unsafe.Sizeof(Fav4Folder{})
View Source
const SIZE_OF_FAV_BOARD = unsafe.Sizeof(FavBoard{})
View Source
const SIZE_OF_FAV_FOLDER = unsafe.Sizeof(FavFolder{})
View Source
const SIZE_OF_FAV_LINE = unsafe.Sizeof(FavLine{})

Variables

View Source
var (
	ErrInvalidFavBoard   = errors.New("invalid fav-board")
	ErrInvalidFavLine    = errors.New("invalid fav-line")
	ErrInvalidFavFolder  = errors.New("invalid fav-folder")
	ErrInvalidFavType    = errors.New("invalid fav-type")
	ErrInvalidFavRecord  = errors.New("invalid fav-record")
	ErrInvalidFav4Record = errors.New("invalid fav4-record")
	ErrOutdatedFav       = errors.New("outdated fav")
	ErrTooManyFavs       = errors.New("too many favs")
	ErrTooManyLines      = errors.New("too many lines")
	ErrTooManyFolders    = errors.New("too many folders")
)

Functions

This section is empty.

Types

type Fav4Board

type Fav4Board struct {
	Bid       ptttype.Bid
	LastVisit int32
	Attr      Favh
}

type Fav4Folder

type Fav4Folder struct {
	Fid        Fid
	Title      ptttype.BoardTitle_t
	ThisFolder int32
}

type FavBoard

type FavBoard struct {
	Bid       ptttype.Bid
	LastVisit int32 /* UNUSED */
	Attr      Favh
}

type FavFolder

type FavFolder struct {
	Fid        Fid
	Title      ptttype.BoardTitle_t
	ThisFolder *FavRaw
}

type FavLine

type FavLine struct {
	Lid Lid
}

type FavRaw

type FavRaw struct {
	MTime  types.Time4
	FavNum int16

	Root *FavRaw

	NBoards  int16 /* number of the boards */
	NLines   int8  /* number of the lines */
	NFolders int8  /* number of the folders */
	LineID   Lid   /* current max line id */
	FolderID Fid   /* current max folder id */

	Favh []*FavType
}

FavRaw

It's with it's own serialize method and does not directly copy by struct. We can add MTime in FavRaw. The content of FavFolder

func Load

func Load(userID *ptttype.UserID_t) (favrec *FavRaw, err error)

Load

Load fav from file.

func NewFavRaw

func NewFavRaw(root *FavRaw) (favRaw *FavRaw)

func ReadFavrec

func ReadFavrec(file *os.File) (favrec *FavRaw, err error)

func TryFav4Load

func TryFav4Load(userID *ptttype.UserID_t, filename string) (favrec *FavRaw, err error)

func (*FavRaw) AddBoard

func (f *FavRaw) AddBoard(bid ptttype.Bid) (favType *FavType, err error)

func (*FavRaw) AddFolder

func (f *FavRaw) AddFolder() (favType *FavType, err error)

func (*FavRaw) AddLine

func (f *FavRaw) AddLine() (favType *FavType, err error)

func (*FavRaw) CleanRoot

func (f *FavRaw) CleanRoot()

func (*FavRaw) GetBoard

func (f *FavRaw) GetBoard(bid ptttype.Bid) (favType *FavType, err error)

func (*FavRaw) GetFavItem

func (f *FavRaw) GetFavItem(theID int, theType FavT) (favType *FavType)

func (*FavRaw) Increase

func (f *FavRaw) Increase(theType FavT, fp interface{})

func (*FavRaw) PreAppend

func (f *FavRaw) PreAppend(theType FavT, fp interface{}) (favType *FavType, err error)

PreAppend

https://github.com/ptt/pttbbs/blob/master/mbbsd/fav.c#L804 Although it is named PreAppend, actually it appends to DataTail

func (*FavRaw) Save

func (f *FavRaw) Save(userID *ptttype.UserID_t) (*FavRaw, error)

Save

save fav to file. XXX use rename to reduce the probability of race-condition.

func (*FavRaw) WriteFavrec

func (f *FavRaw) WriteFavrec(file *os.File) error

type FavT

type FavT int8
const (
	FAVT_BOARD  FavT = 1
	FAVT_FOLDER FavT = 2
	FAVT_LINE   FavT = 3
)

func (FavT) GetFav4TypeSize

func (theType FavT) GetFav4TypeSize() uintptr

func (FavT) GetTypeSize

func (theType FavT) GetTypeSize() uintptr

func (FavT) IsValidFavType

func (theType FavT) IsValidFavType() bool

func (FavT) String

func (t FavT) String() string

type FavType

type FavType struct {
	TheType FavT
	Attr    Favh
	Fp      interface{}
}

func (*FavType) GetID

func (ft *FavType) GetID() (theID int)

type Favh

type Favh int8
const (
	FAVH_FAV     Favh = 1
	FAVH_TAG     Favh = 2
	FAVH_UNREAD  Favh = 4
	FAVH_ADM_TAG Favh = 8
)

type Fid

type Fid int8

type Lid

type Lid int8

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL