package common

import (
	"os"
	"strconv"
)

var FILTER_PID_KEY = "FILTER_PID"

var INT_FILTER_PID = 0

func init() {
	filterPid, err := strconv.ParseInt(os.Getenv(FILTER_PID_KEY), 10, 64)
	if err == nil {
		INT_FILTER_PID = int(filterPid)
	}
}

func IsOpenFilter() bool {
	return INT_FILTER_PID != 0
}

func GetFilterPid() (int, bool) {
	return INT_FILTER_PID, INT_FILTER_PID == 0
}

func IsFilterPid(filterPid uint32) bool {
	return int(filterPid) == INT_FILTER_PID
}
