package cmsys

import "sync"

type (
	Fnv64_t uint64
	Fnv32_t uint32
)

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
)

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)
)

var ESCAPE_FLAG = []uint8{
	/*  0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	/* 10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	/* 20 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	/* 30 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, /* 0~9 ;= */
	/* 40 */ 0, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, /* ABCDHIJK */
	/* 50 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	/* 60 */ 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 2, 2, 0, 0, /* fhlm */
	/* 70 */ 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* su */
	/* 80 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	/* 90 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	/* A0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	/* B0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	/* C0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	/* D0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	/* E0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	/* F0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}

const (
	N_ITER_PTTLOCK = 10
)

type LogFlag int

const (
	LOG_CREAT LogFlag = 1
)

type DBCSStatus_t int

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

var (
	lock      sync.Mutex
	lockFDMap = map[string]*sync.Mutex{}
)
