cmsys

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: GPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// https://github.com/ptt/pttbbs/blob/master/include/fnv_hash.h
	// commit: 6bdd36898bde207683a441cdffe2981e95de5b20
	FNV1_32_INIT Fnv32_t = 33554467
	FNV1_64_INIT Fnv64_t = 0xcbf29ce484222325

	FNV_32_PRIME Fnv32_t = 0x01000193
	FNV_64_PRIME Fnv64_t = 0x100000001b3
)
View Source
const (
	N_ITER_PTTLOCK = 10
)

Variables

View Source
var ESCAPE_FLAG = []uint8{}/* 256 elements not displayed */
View Source
var ErrPttLock = errors.New("unable to ptt-lock")
View Source
var ErrRecordNotFound = errors.New("not found")

Functions

func AppendRecord added in v0.11.1

func AppendRecord(filename string, data interface{}, theSize uintptr) (idx ptttype.SortIdx, err error)

func DBCSSafeTrim added in v0.12.0

func DBCSSafeTrim(str []byte) (newStr []byte)

func DeleteRecord added in v0.19.0

func DeleteRecord(filename string, index ptttype.SortIdxInStore, theSize uintptr) error

func FileExistsRecord added in v0.14.0

func FileExistsRecord(filename string, key []byte) bool

func FileFindRecord added in v0.14.0

func FileFindRecord(filename string, key []byte) (idx int)

FileFindRecord (starting from 1)

func FindRecordStartIdx added in v0.10.0

func FindRecordStartIdx(dirFilename string, total int, createTime types.Time4, filename *ptttype.Filename_t, isDesc bool) (startIdx ptttype.SortIdx, err error)

FindRecordStartIdx

startIdx should be 1-total. find record: if isDesc: search from the newest, until either find the filename,

or the record of the createTime

else: search from the oldest, until either find the filename,

or the record of the createTime

func GetHoroscope

func GetHoroscope(m int, d int) int

GetHoroscope

給日期求星座

Return:

1..12

func GetNumRecords

func GetNumRecords(filename string, size uintptr) int

func GetRecord added in v0.14.0

func GetRecord(dirFilename string, filename *ptttype.Filename_t, total int) (idx ptttype.SortIdx, fhdr *ptttype.FileHeaderRaw, err error)

func GetRecords added in v0.3.0

func GetRecords(boardID *ptttype.BoardID_t, filename string, startIdx ptttype.SortIdx, n int, isDesc bool) (summaries []*ptttype.ArticleSummaryRaw, err error)

func GoFlock added in v0.12.0

func GoFlock(fd uintptr, filename string) (err error)

GoFlock

Original Flock has no effect with multi-thread process. We use single lock for now.

func GoFlockExNb added in v0.14.0

func GoFlockExNb(fd uintptr, filename string) (err error)

GoFlock

Original Flock has no effect with multi-thread process. We use single lock for now.

func GoFunlock added in v0.12.0

func GoFunlock(fd uintptr, filename string) (err error)

GoFunlock

Original Flock has no effect with multi-thread process. We use single lock for now.

func GoPttLock added in v0.12.0

func GoPttLock(file *os.File, filename string, offset int64, theSize uintptr) (err error)

GoPttLock

Original PttLock has no effect with multi-thread process. We use single lock for now.

func GoPttUnlock added in v0.12.0

func GoPttUnlock(file *os.File, filename string, offset int64, theSize uintptr) (err error)

GoPttUnlock

Original PttLock has no effect with multi-thread process. We use single lock for now.

func IsLeapYear

func IsLeapYear(year int) bool

func LogFile added in v0.12.0

func LogFile(filename string, logFlag LogFlag, msg string) (err error)

func LogFilef added in v0.12.0

func LogFilef(filename string, logFlag LogFlag, msg string) (err error)

func StrcaseStartsWith added in v0.12.0

func StrcaseStartsWith(str []byte, prefix []byte) (isValid bool)

func StripAnsi added in v0.5.0

func StripAnsi(src []byte, flag StripAnsiFlag) (dst []byte)

func StripBlank added in v0.9.0

func StripBlank(theBytes []byte) []byte

func StripNoneBig5 added in v0.5.0

func StripNoneBig5(str_out []byte) (sanitizedStr []byte)

StringNoneBig5

https://github.com/ptt/pttbbs/issues/94 str is modified.

func SubstituteRecord added in v0.11.1

func SubstituteRecord(filename string, data interface{}, theSize uintptr, idxInStore int32) (err error)

func Trim added in v0.12.0

func Trim(str []byte) (newStr []byte)

Types

type DBCSStatus_t added in v0.12.0

type DBCSStatus_t int
const (
	DBCS_ASCII    DBCSStatus_t = 0
	DBCS_LEADING  DBCSStatus_t = 1
	DBCS_TRAILING DBCSStatus_t = 2
)

func DBCSNextStatus added in v0.12.0

func DBCSNextStatus(c byte, prevStatus DBCSStatus_t) (newStatus DBCSStatus_t)

func DBCSStatus added in v0.12.0

func DBCSStatus(str []byte, pos int) (status DBCSStatus_t)

type Fnv32_t added in v0.18.0

type Fnv32_t uint32

func StringHash

func StringHash(theBytes []byte) Fnv32_t

func StringHashWithHashBits

func StringHashWithHashBits(theBytes []byte) Fnv32_t

type Fnv64_t added in v0.18.0

type Fnv64_t uint64

func Fnv64Buf added in v0.18.0

func Fnv64Buf(buf []byte, theLen int, hval Fnv64_t) (newHVal Fnv64_t)

type LogFlag added in v0.12.0

type LogFlag int
const (
	LOG_CREAT LogFlag = 1
)

type StripAnsiFlag added in v0.5.0

type StripAnsiFlag int
const (
	STRIP_ANSI_ALL        StripAnsiFlag = iota
	STRIP_ANSI_ONLY_COLOR               // allow only colors (ESC [ .. m)
	STRIP_ANSI_NO_RELOAD                // allow all known (color+move)
)

Jump to

Keyboard shortcuts

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