fav

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

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_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")
	ErrTooMuchDepth      = errors.New("too much depth")

	ErrInvalidLevelIdx = errors.New("invalid level-idx")
)

Functions

This section is empty.

Types

type Fav

type Fav struct {
	FavNum int
	Depth  int

	Root   *Fav
	Parent *Fav

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

	Favh []*FavType
}

Fav

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 NewFav

func NewFav(parent *Fav, root *Fav, depth int) (f *Fav, err error)

func ReadFavrec

func ReadFavrec(file io.ReadSeeker, parent *Fav, root *Fav, depth int) (favrec *Fav, err error)

ReadFavrec

We need to: 1. read version because calling ReadFavrec 2. run root.SetFavTypeFavIdx(0)

because ReadFavrec is a recursive-call, and the above 2 happens only in the 1st-call.

func (*Fav) AddBoard

func (f *Fav) AddBoard(bid ptttype.Bid) (idx int, favType *FavType, err error)

func (*Fav) AddFolder

func (f *Fav) AddFolder(title string) (idx int, favType *FavType, err error)

func (*Fav) AddLine

func (f *Fav) AddLine() (idx int, favType *FavType, err error)

func (*Fav) CleanParentAndRoot

func (f *Fav) CleanParentAndRoot()

func (*Fav) DecreaseFavNum

func (f *Fav) DecreaseFavNum()

func (*Fav) DeleteFavNum added in v0.31.1

func (f *Fav) DeleteFavNum(favNum int)

func (*Fav) DeleteIdx added in v0.31.1

func (f *Fav) DeleteIdx(idx int) (err error)

func (*Fav) GetBoard

func (f *Fav) GetBoard(bid ptttype.Bid) (idx int, favType *FavType, err error)

func (*Fav) GetFavItem

func (f *Fav) GetFavItem(theID int, theType pttbbsfav.FavT) (idx int, favType *FavType)

func (*Fav) Increase

func (f *Fav) Increase(theType pttbbsfav.FavT, fp interface{})

func (*Fav) IncreaseFavNum

func (f *Fav) IncreaseFavNum()

func (*Fav) LocateFav added in v0.31.0

func (f *Fav) LocateFav(levelIdxList []string) (newFav *Fav, err error)

LocateFav

Locate the fav based on levelIdxList. Requiring that all the fav / subFav are with Folder type.

There will be 1 levelIdx in levelIdxList if referring to f itself. Ex. if referring to f as root, then levelIdxList is []string{""}

func (*Fav) PreAppend

func (f *Fav) PreAppend(theType pttbbsfav.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 (*Fav) SetFavTypeFavIdx

func (f *Fav) SetFavTypeFavIdx(startFavIdx int) (newFavIdx int)

func (*Fav) WriteFavrec

func (f *Fav) WriteFavrec(file io.Writer) (err error)

type FavBoard

type FavBoard struct {
	Bid       ptttype.Bid    `bson:"bid"`
	LastVisit int32          `bson:"-"` /* UNUSED */
	Attr      pttbbsfav.Favh `bson:"-"`
}

type FavFolder

type FavFolder struct {
	Fid        pttbbsfav.Fid `bson:"fid"`
	Title      string        `bson:"title"`
	ThisFolder *Fav          `bson:"folder"`
}

type FavLine

type FavLine struct {
	Lid pttbbsfav.Lid `bson:"lid"`
}

type FavType

type FavType struct {
	FavIdx  int
	TheType pttbbsfav.FavT
	Attr    pttbbsfav.Favh
	Fp      interface{}
}

func (*FavType) CastBoard

func (ft *FavType) CastBoard() *FavBoard

func (*FavType) CastFolder

func (ft *FavType) CastFolder() *FavFolder

func (*FavType) CastLine

func (ft *FavType) CastLine() *FavLine

func (*FavType) GetID

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

Jump to

Keyboard shortcuts

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