modernc.org/xdmcp@v1.0.17/xdmcp.go (about) 1 // Copyright 2021 The Xdmcp-Go Authors. All rights reserved. 2 // Use of the source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:generate go run generator.go 6 7 // Package xdmcp is the X Display Manager Control Protocol library. 8 // 9 // The API si currently empty. 10 // 11 // Installation 12 // 13 // $ go get modernc.org/xdmpc 14 // 15 // Linking using ccgo 16 // 17 // $ ccgo foo.c -lmodernc.org/xdmcp/lib 18 // 19 // Documentation 20 // 21 // http://godoc.org/modernc.org/xdmcp 22 // 23 // Builders 24 // 25 // https://modern-c.appspot.com/-/builder/?importpath=modernc.org%2fxdmcp 26 package xdmcp // import "modernc.org/xdmcp" 27 28 import ( 29 "fmt" 30 "os" 31 "runtime" 32 "strings" 33 ) 34 35 func origin(skip int) string { 36 pc, fn, fl, _ := runtime.Caller(skip) 37 f := runtime.FuncForPC(pc) 38 var fns string 39 if f != nil { 40 fns = f.Name() 41 if x := strings.LastIndex(fns, "."); x > 0 { 42 fns = fns[x+1:] 43 } 44 } 45 return fmt.Sprintf("%s:%d:%s", fn, fl, fns) 46 } 47 48 func todo(s string, args ...interface{}) string { 49 switch { 50 case s == "": 51 s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...) 52 default: 53 s = fmt.Sprintf(s, args...) 54 } 55 r := fmt.Sprintf("%s: TODO %s", origin(2), s) //TODOOK 56 fmt.Fprintf(os.Stdout, "%s\n", r) 57 os.Stdout.Sync() 58 return r 59 } 60 61 func trc(s string, args ...interface{}) string { 62 switch { 63 case s == "": 64 s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...) 65 default: 66 s = fmt.Sprintf(s, args...) 67 } 68 r := fmt.Sprintf("%s: TRC %s", origin(2), s) 69 fmt.Fprintf(os.Stdout, "%s\n", r) 70 os.Stdout.Sync() 71 return r 72 }