"log"
	"os"
	"path/filepath"
	"strings"
	"text/template"
	"time"
)

var (
	cfgfile   = flag.String("config", "", "config file (default is path/config.json)")
	help      = flag.BoolP("help", "h", false, "show this help")
	source    = flag.StringP("source", "s", "", "filesystem path to read files relative from")
	watchMode = flag.BoolP("watch", "w", false, "watch filesystem for changes and recreate as needed")
	server    = flag.BoolP("server", "S", false, "run a (very) simple web server")
	port      = flag.String("port", "1313", "port to run web server on, default :1313")
	interval  = flag.Int64P("interval", "i", 1000, "pooling interval for watching")
	rebuild   = flag.BoolP("rebuild", "r", false, "rebuild entire book on restart")
)

type Process struct {
	// Process is done
	Done chan bool
	// Source directory for the book
	Source string
	// Started
	Started bool

	// Contains the statistics for all the pages
	ConfigFileInfo     *os.FileInfo
	PageLayoutFileInfo *os.FileInfo
	IndexFileInfo      *os.FileInfo
Exemplo n.º 2
0
	// For pretty printing.
	numberWidth int
	printOne    bool

	// For getFileStatus.
	errNoStat = errors.New("No stat.")

	// Our cli args
	printLines      = flag.BoolP("lines", "l", false, "")
	printWords      = flag.BoolP("words", "w", false, "")
	printChars      = flag.BoolP("chars", "m", false, "")
	printBytes      = flag.BoolP("bytes", "c", false, "")
	printLineLength = flag.BoolP("max-line-length", "L", false, "")
	filesFrom       = flag.String("files0-from", "", "")
	tabWidth        = flag.Int64P("tab", "t", 8, "")
	constVersion    = flag.BoolP("unicode-version", "u", false, "")
	version         = flag.BoolP("version", "v", false, "")

	// fatal.Fatal helper
	//fatal = log.New(os.Stderr, "", log.Lshortfile)
	fatal = log.New(os.Stderr, "", 0)
)

type fstatus struct {
	failed error
	stat   os.FileInfo
}

func count(s []byte, delim byte) int64 {
	count := int64(0)
Exemplo n.º 3
0
    -u, --uppercase    use upper case hex letters.
    -v, --version      show version.`

	Version = `xxd v2.0 2014-17-01 by Felix Geisendörfer and Eric Lagergren`
)

// cli flags
var (
	autoskip   = flag.BoolP("autoskip", "a", false, "toggle autoskip (* replaces nul lines")
	bars       = flag.BoolP("bars", "B", false, "print |ascii| instead of ascii")
	binary     = flag.BoolP("binary", "b", false, "binary dump, incompatible with -ps, -i, -r")
	columns    = flag.IntP("cols", "c", -1, "format <cols> octets per line")
	ebcdic     = flag.BoolP("ebcdic", "E", false, "use EBCDIC instead of ASCII")
	group      = flag.IntP("group", "g", -1, "num of octets per group")
	cfmt       = flag.BoolP("include", "i", false, "output in C include format")
	length     = flag.Int64P("len", "l", -1, "stop after len octets")
	postscript = flag.BoolP("ps", "p", false, "output in postscript plain hd style")
	reverse    = flag.BoolP("reverse", "r", false, "convert hex to binary")
	offset     = flag.Int("off", 0, "revert with offset")
	seek       = flag.StringP("seek", "s", "", "start at seek bytes abs")
	upper      = flag.BoolP("uppercase", "u", false, "use uppercase hex letters")
	version    = flag.BoolP("version", "v", false, "print version")
)

// constants used in xxd()
const (
	ebcdicOffset = 0x40
)

// dumpType enum
const (
Exemplo n.º 4
0
	"os"
	"os/signal"
	"os/user"
	"strconv"
	"strings"
	"syscall"
)

// The command line flags available
var (
	// Log related flags
	logToStderr  = pflag.BoolP("logtostderr", "e", true, "log to stderr instead of to files")
	logThreshold = pflag.StringP("logthreshold", "o", "INFO", "Log events at or above this severity are logged to standard error as well as to files. Possible values: INFO, WARNING, ERROR and FATAL")
	logdir       = pflag.StringP("logpath", "l", "./logs", "The log files will be written in this directory/path")

	flushInterval = pflag.Int64P("flushinterval", "f", 59, "The interval between the PUT of batches of mac-addresses")
	iface         = pflag.StringP("interface", "i", "mon0", "The capture interface to listen on")
	pcap          = pflag.StringP("pcap", "p", "", "Use a pcap file instead of live capturing")
	server        = pflag.StringP("server", "s", "http://localhost:3000/sessions.json", "Server to PUT macs to")
	authToken     = pflag.StringP("token", "t", "", "API-token. (Required)")
	printResponse = pflag.BoolP("printresponse", "r", false, "Print response from backend")
	hitCount      uint64
)

func init() {
	pflag.Parse()

	// glog Logging options
	flag.Set("logtostderr", strconv.FormatBool(*logToStderr))
	flag.Set("log_dir", *logdir)
	flag.Set("stderrthreshold", *logThreshold)
Exemplo n.º 5
0
	"os"
	"regexp"
	"runtime"
	"time"
)

const (
	version string = "0.0.1"
)

var (
	downloaded []int64
	boards     string = "a|b|c|d|e|f|g|gif|h|hr|k|m|o|p|r|s|t|u|v|vg|w|wg|i|ic|r9k|cm|hm|y|3|adv|an|cgl|ck|co|diy|fa|fit|hc|int|jp|lit|mlp|mu|n|po|pol|sci|soc|sp|tg|toy|trv|tv|vp|wsg|x|q"

	// Options
	minWidth     *int64         = flag.Int64P("min-width", "w", 0, "Minimum width of images")
	minHeight    *int64         = flag.Int64P("min-height", "h", 0, "Minimum height of images")
	refresh      *time.Duration = flag.DurationP("refresh", "r", time.Second*30, "Refresh rate (min 30s)")
	orignalNames *bool          = flag.BoolP("original-names", "o", false, "Save images under original filenames")
	showVersion  *bool          = flag.BoolP("version", "v", false, "Show version")
)

type Post struct {
	No             int64
	Resto          int64
	Sticky         bool
	Closed         bool
	Now            string
	Time           int64
	Name           string
	Trip           string
Exemplo n.º 6
0
// The number of bytes to compare during each random sample comparison.
var sampleSize = 32

var userSource1 = ""
var userSource2 = ""

// setup a resultsummary object to print later
var globalResultSummary = new(resultSummary)

// ------------------------------------------------------------------------ //

var verbose = flag.BoolP("verbose", "v", false, "Print what is being done")
var machine = flag.BoolP("machine", "m", false, "Output summary in machine-readable format")
var oneFilesystem = flag.BoolP("one-filesystem", "x", false, "Stay on one filesystem (in <original>)")
var sampleCount = flag.Int64P("samples", "s", 0, "Comparison sample count [default: 0]")
var help = flag.BoolP("help", "h", false, "Display this screen")

// ------------------------------------------------------------------------ //

func visit(relative string) {

	original := filepath.Join(userSource1, relative)
	backup := filepath.Join(userSource2, relative)

	if *verbose {
		fmt.Printf("DEBUG: Comparing [%s] to [%s] \n", original, backup)
	}

	//	if *ignoreDir != original ||
	// Make sure both directories exist