Documentation ¶
Index ¶
- Constants
- Variables
- func AllAlnum(str string) bool
- func AllDig(str string) bool
- func DictEval(dict_name string, value string, recursive bool) string
- func DictLoadFileXt(dict_name string, path string) error
- func DictLoadFp(dict_name string, fd *os.File)
- func DictLookup(dict_name string, name string) string
- func DictRegister(dict_name string, dict_info *Dict)
- func DictUnregister(dict_name string)
- func DictUpdate(dict_name string, name string, value string) error
- func DirForest(path string, depth int) string
- func ExtPar(val string, parens string, flags int) (string, error)
- func GetLogger() *zap.Logger
- func IsHSpace(r rune) bool
- func LoggerConfig(decorators map[string]string)
- func MacExpand(result *strings.Builder, pattern string, flags int, filter *string, ...) int
- func MacParse(value string, action func(int, string, interface{}) int, context interface{}) int
- func MsgDPanic(msg string, kv ...any)
- func MsgDPanicf(format string, a ...any)
- func MsgDebug(msg string, kv ...any)
- func MsgDebugf(format string, a ...any)
- func MsgError(msg string, kv ...any)
- func MsgErrorf(format string, a ...any)
- func MsgFatal(msg string, kv ...any)
- func MsgFatalf(format string, a ...any)
- func MsgInfo(msg string, kv ...any)
- func MsgInfof(format string, a ...any)
- func MsgPanic(msg string, kv ...any)
- func MsgPanicf(format string, a ...any)
- func MsgWarn(msg string, kv ...any)
- func MsgWarnf(format string, a ...any)
- func MyFlock(fd int, lock_style int, operation int) int
- func MyStrTok(src string, sep string) []string
- func MyStrTokDQ(src string, sep string) []string
- func MyStrTokQ(src string, sep string, parens string) []string
- func SafeGetenv(name string) string
- func SetLogger(logger *zap.Logger)
- func SplitNameVal(buf string) (string, string, error)
- func Unsafe() bool
- func UpdateEnv(preserve_list []string)
- type Dict
- type DictOwner
- type DictUtf8Backup
- type LogicalLine
- type MacExpandContext
- type RuneScanner
- func (s *RuneScanner) Emit() string
- func (s *RuneScanner) End(sync bool)
- func (s *RuneScanner) Next() rune
- func (s *RuneScanner) Peek() rune
- func (s *RuneScanner) PosString() string
- func (s *RuneScanner) Push()
- func (s *RuneScanner) Reset()
- func (s *RuneScanner) Scan() rune
- func (s *RuneScanner) Skip(cmp func(rune) bool)
- func (s *RuneScanner) Span(cmp func(rune) bool)
- func (s *RuneScanner) String() string
- func (s *RuneScanner) Sync()
Constants ¶
const ( DICT_FLAG_NONE int = (0) DICT_FLAG_DUP_WARN int = (1 << 0) /* warn about dups if not supported */ DICT_FLAG_DUP_IGNORE int = (1 << 1) /* ignore dups if not supported */ DICT_FLAG_TRY0NULL int = (1 << 2) /* do not append 0 to key/value */ DICT_FLAG_TRY1NULL int = (1 << 3) /* append 0 to key/value */ DICT_FLAG_FIXED int = (1 << 4) /* fixed key map */ DICT_FLAG_PATTERN int = (1 << 5) /* keys are patterns */ DICT_FLAG_LOCK int = (1 << 6) /* use temp lock before access */ DICT_FLAG_DUP_REPLACE int = (1 << 7) /* replace dups if supported */ DICT_FLAG_SYNC_UPDATE int = (1 << 8) /* sync updates if supported */ DICT_FLAG_DEBUG int = (1 << 9) /* log access */ /*DICT_FLAG_FOLD_KEY int = (1<<10) /* lowercase the lookup key */ DICT_FLAG_NO_REGSUB int = (1 << 11) /* disallow regexp substitution */ DICT_FLAG_NO_PROXY int = (1 << 12) /* disallow proxy mapping */ DICT_FLAG_NO_UNAUTH int = (1 << 13) /* disallow unauthenticated data */ DICT_FLAG_FOLD_FIX int = (1 << 14) /* case-fold key with fixed-case map */ DICT_FLAG_FOLD_MUL int = (1 << 15) /* case-fold key with multi-case map */ DICT_FLAG_FOLD_ANY int = (DICT_FLAG_FOLD_FIX | DICT_FLAG_FOLD_MUL) DICT_FLAG_OPEN_LOCK int = (1 << 16) /* perm lock if not multi-writer safe */ DICT_FLAG_BULK_UPDATE int = (1 << 17) /* optimize for bulk updates */ DICT_FLAG_MULTI_WRITER int = (1 << 18) /* multi-writer safe map */ DICT_FLAG_UTF8_REQUEST int = (1 << 19) /* activate UTF-8 if possible */ DICT_FLAG_UTF8_ACTIVE int = (1 << 20) /* UTF-8 proxy layer is present */ DICT_FLAG_SRC_RHS_IS_FILE int = (1 << 21) /* Map source RHS is a file */ )
* See dict_open.c embedded manpage for flag definitions.
const ( DICT_ERR_NONE int = 0 /* no error */ DICT_ERR_RETRY int = (-1) /* soft error */ DICT_ERR_CONFIG int = (-2) /* configuration error */ )
* dict->error values. Errors must be negative; smtpd_check depends on this.
const ( DICT_SEQ_FUN_FIRST = 0 /* set cursor to first record */ DICT_SEQ_FUN_NEXT = 1 /* set cursor to next record */ )
* Sequence function types.
const ( EXTPAR_FLAG_NONE = (0) EXTPAR_FLAG_STRIP = (1 << 0) /* "{ text }" -> "text" */ EXTPAR_FLAG_EXTRACT = (1 << 1) /* hint from caller's caller */ )
const ( MAC_EXP_BVAL_TRUE = "true" MAC_EXP_BVAL_FALSE = "" )
const ( MAC_EXP_MODE_TEST = 0 MAC_EXP_MODE_USE = 1 )
const ( MAC_EXP_FLAG_NONE int = (0) MAC_EXP_FLAG_RECURSE int = (1 << 0) MAC_EXP_FLAG_APPEND int = (1 << 1) MAC_EXP_FLAG_SCAN int = (1 << 2) MAC_EXP_FLAG_PRINTABLE int = (1 << 3) )
const ( MAC_EXP_OP_RES_TRUE = 0 MAC_EXP_OP_RES_FALSE = 1 MAC_EXP_OP_RES_ERROR = 2 )
const ( MAC_EXP_OP_TOK_NONE = 0 /* Sentinel */ MAC_EXP_OP_TOK_EQ = 1 /* == */ MAC_EXP_OP_TOK_NE = 2 /* != */ MAC_EXP_OP_TOK_LT = 3 /* < */ MAC_EXP_OP_TOK_LE = 4 /* <= */ MAC_EXP_OP_TOK_GE = 5 /* >= */ MAC_EXP_OP_TOK_GT = 6 /* > */ )
* Token codes, public so tha they are available to mac_expand_add_relop()
const ( MAC_EXP_OP_STR_EQ = "==" MAC_EXP_OP_STR_NE = "!=" MAC_EXP_OP_STR_LT = "<" MAC_EXP_OP_STR_LE = "<=" MAC_EXP_OP_STR_GE = ">=" MAC_EXP_OP_STR_GT = ">" MAC_EXP_OP_STR_ANY = "\"" + MAC_EXP_OP_STR_EQ + "\" or \"" + MAC_EXP_OP_STR_NE + "\"" + "\" or \"" + MAC_EXP_OP_STR_LT + "\"" + "\" or \"" + MAC_EXP_OP_STR_LE + "\"" + "\" or \"" + MAC_EXP_OP_STR_GE + "\"" + "\" or \"" + MAC_EXP_OP_STR_GT + "\"" )
* Relational operators. The MAC_EXP_OP_TOK_* are defined in the header * file.
const ( MAC_PARSE_LITERAL int = 1 // The content of buf is literal text. MAC_PARSE_EXPR int = 2 // The content of buf is a macro expression. MAC_PARSE_VARNAME int = MAC_PARSE_EXPR // 2.1 compatibility )
const ( MAC_PARSE_OK int = 0 // No errors detected during macro parsing MAC_PARSE_ERROR int = (1 << 0) // A parsing error was detected. MAC_PARSE_UNDEF int = (1 << 1) // A macro was expanded but not defined. MAC_PARSE_USER int = 2 // start user definitions )
const ( MYFLOCK_STYLE_FLOCK int = 1 MYFLOCK_STYLE_FCNTL int = 2 )
* Lock styles.
const ( MYFLOCK_OP_NONE int = 0 MYFLOCK_OP_SHARED int = 1 << 1 MYFLOCK_OP_EXCLUSIVE int = 1 << 2 MYFLOCK_OP_NOWAIT int = 1 << 3 MYFLOCK_OP_BITS int = (MYFLOCK_OP_SHARED | MYFLOCK_OP_EXCLUSIVE | MYFLOCK_OP_NOWAIT) )
* Lock request types.
const ( CHARS_COMMA_SP string = ", \t\r\n" // list separator CHARS_SPACE string = " \t\r\n" // word separator CHARS_BRACE string = "{}" // grouping )
const DICT_FLAG_IMPL_MASK int = (DICT_FLAG_FIXED | DICT_FLAG_PATTERN | DICT_FLAG_MULTI_WRITER)
const DICT_FLAG_PARANOID int = (DICT_FLAG_NO_REGSUB | DICT_FLAG_NO_PROXY | DICT_FLAG_NO_UNAUTH)
* The subsets of flags that control how a map is used. These are relevant * mainly for proxymap support. Note: some categories overlap. * * DICT_FLAG_IMPL_MASK - flags that are set by the map implementation itself. * * DICT_FLAG_PARANOID - requestor flags that forbid the use of insecure map * types for security-sensitive operations. These flags are checked by the * map implementation itself upon open, lookup etc. requests. * * DICT_FLAG_RQST_MASK - all requestor flags, including paranoid flags, that * the requestor may change between open, lookup etc. requests. These * specify requestor properties, not map properties. * * DICT_FLAG_INST_MASK - none of the above flags. The requestor may not change * these flags between open, lookup, etc. requests (although a map may make * changes to its copy of some of these flags). The proxymap server opens * only one map instance for all client requests with the same values of * these flags, and the proxymap client uses its own saved copy of these * flags. DICT_FLAG_SRC_RHS_IS_FILE is an example of such a flag.
const DICT_FLAG_RQST_MASK int = (DICT_FLAG_FOLD_ANY | DICT_FLAG_LOCK | DICT_FLAG_DUP_REPLACE | DICT_FLAG_DUP_WARN | DICT_FLAG_DUP_IGNORE | DICT_FLAG_SYNC_UPDATE | DICT_FLAG_PARANOID | DICT_FLAG_UTF8_MASK)
const DICT_FLAG_UTF8_MASK int = (DICT_FLAG_UTF8_REQUEST)
const DICT_OWNER_TRUSTED int = (0) // ex: root-owned config file
const DICT_OWNER_UNKNOWN int = (-1) // ex: unauthenticated tcp, proxy
* Note that trust levels are not in numerical order.
const DICT_OWNER_UNTRUSTED int = (1) // ex: non-root config file
const DONT_GRIPE = 0
const DO_GRIPE = 1
const INTERNAL_LOCK int = MYFLOCK_STYLE_FLOCK
const MAC_EXP_WHITESPACE string = CHARS_SPACE
const VALID_HOSTNAME_LEN = 255 /* RFC 1035 */
const VALID_LABEL_LEN = 63 /* RFC 1035 */
Variables ¶
var DICT_TYPE_HT = "internal"
var MsgVerbose int = 0
Functions ¶
func DictLoadFileXt ¶
func DictLoadFp ¶
func DictLookup ¶
func DictRegister ¶
func DictUnregister ¶
func DictUnregister(dict_name string)
func LoggerConfig ¶
func MacParse ¶
MacParse locates macro references in string
MacParse breaks up its string argument into macro references and other text, and invokes the action routine for each item found. With each action routine call, the type argument indicates what was found, buf contains a copy of the text found, and context is passed on unmodified from the caller. The application is at liberty to clobber buf.
Values for type argument in action:
MAC_PARSE_LITERAL // We parsed non-macro literal text MAC_PARSE_EXPR // either a bare macro name without the preceding "$", // or all the text inside $() or ${}.
func MsgDPanicf ¶
func MyStrTokDQ ¶
func SafeGetenv ¶
SafeGetenv - read environment variable with guard
func SplitNameVal ¶
SplitNameVal takes a logical line from Readlline and expects text of the form "name = value" or "name =".
The buffer argument is broken up into name and value substrings.
Types ¶
type Dict ¶
type Dict struct { Type string /* for diagnostics */ Name string /* for diagnostics */ Flags int /* see below */ Lookup func(string) (string, error) Update func(string, string) error Delete func(string) error Sequence func(int, *string, *string) Lock func(int) int Close func() LockType int /* for read/write lock */ LockFd int /* for read/write lock */ StatFd int /* change detection */ ModTime time.Time /* mod time at open */ Owner DictOwner /* provenance */ Error int /* last operation only */ }
func DictFindForUpdate ¶
func DictHandle ¶
type DictUtf8Backup ¶
type LogicalLine ¶
func (*LogicalLine) Readllines ¶
func (ll *LogicalLine) Readllines() (string, error)
type MacExpandContext ¶
type MacExpandContext struct { Result *strings.Builder Flags int Filter *string Lookup func(string, int, interface{}) (string, error) Context interface{} Status int Level int }
func (*MacExpandContext) String ¶
func (m *MacExpandContext) String() string
type RuneScanner ¶
func NewRuneScanner ¶
func NewRuneScanner(str string) *RuneScanner
func (*RuneScanner) Emit ¶
func (s *RuneScanner) Emit() string
func (*RuneScanner) End ¶
func (s *RuneScanner) End(sync bool)
func (*RuneScanner) Next ¶
func (s *RuneScanner) Next() rune
func (*RuneScanner) Peek ¶
func (s *RuneScanner) Peek() rune
func (*RuneScanner) PosString ¶
func (s *RuneScanner) PosString() string
func (*RuneScanner) Push ¶
func (s *RuneScanner) Push()
func (*RuneScanner) Reset ¶
func (s *RuneScanner) Reset()
func (*RuneScanner) Scan ¶
func (s *RuneScanner) Scan() rune
func (*RuneScanner) Skip ¶
func (s *RuneScanner) Skip(cmp func(rune) bool)
func (*RuneScanner) Span ¶
func (s *RuneScanner) Span(cmp func(rune) bool)
func (*RuneScanner) String ¶
func (s *RuneScanner) String() string
func (*RuneScanner) Sync ¶
func (s *RuneScanner) Sync()