folded inside package dns
This commit is contained in:
parent
1ea77385f3
commit
5ab8afe518
BIN
strconv/6.out
BIN
strconv/6.out
Binary file not shown.
|
@ -1,11 +0,0 @@
|
|||
# Copyright 2009 The Go Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
include $(GOROOT)/src/Make.inc
|
||||
|
||||
TARG=dns/strconv
|
||||
GOFILES=\
|
||||
strconv.go\
|
||||
|
||||
include $(GOROOT)/src/Make.pkg
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,15 +0,0 @@
|
|||
package main
|
||||
|
||||
import "dns/strconv"
|
||||
import "testing"
|
||||
import __regexp__ "regexp"
|
||||
|
||||
var tests = []testing.InternalTest{
|
||||
{"strconv.TestConversion", strconv.TestConversion},
|
||||
}
|
||||
var benchmarks = []testing.InternalBenchmark{}
|
||||
|
||||
func main() {
|
||||
testing.Main(__regexp__.MatchString, tests)
|
||||
testing.RunBenchmarks(__regexp__.MatchString, benchmarks)
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
package strconv
|
||||
|
||||
import (
|
||||
"unicode"
|
||||
conv "strconv"
|
||||
"dns"
|
||||
)
|
||||
|
||||
const (
|
||||
m = 60
|
||||
h = m * m
|
||||
d = 24 * h
|
||||
w = 7 * d
|
||||
)
|
||||
|
||||
// Convert a Ttl to a value. Supported value 'm' for minutes, 'h' for hours
|
||||
// 'w' for week and 'd' for days. Stuff like '1d1d' is legal and return the value of '2d'
|
||||
func StringToSeconds(ttl string) (sec uint32, ok bool) {
|
||||
num := ""
|
||||
for _, k := range ttl {
|
||||
if unicode.IsDigit(k) {
|
||||
num += string(k)
|
||||
} else {
|
||||
i, _ := conv.Atoi(num)
|
||||
switch k {
|
||||
case 'm':
|
||||
sec += uint32(i) * m
|
||||
case 'h':
|
||||
sec += uint32(i) * h
|
||||
case 'd':
|
||||
sec += uint32(i) * d
|
||||
case 'w':
|
||||
sec += uint32(i) * w
|
||||
default:
|
||||
return
|
||||
}
|
||||
num = ""
|
||||
}
|
||||
}
|
||||
i, _ := conv.Atoi(num)
|
||||
sec += uint32(i)
|
||||
return
|
||||
}
|
||||
|
||||
func SecondsToString(val uint32) (str string) {
|
||||
mod := val / w
|
||||
if mod > 0 {
|
||||
str += conv.Itoa(int(mod)) + "w"
|
||||
}
|
||||
val -= mod * w
|
||||
|
||||
mod = val / d
|
||||
if mod > 0 {
|
||||
str += conv.Itoa(int(mod)) + "d"
|
||||
}
|
||||
val -= mod * d
|
||||
|
||||
mod = val / h
|
||||
if mod > 0 {
|
||||
str += conv.Itoa(int(mod)) + "h"
|
||||
}
|
||||
val -= mod * h
|
||||
|
||||
mod = val / m
|
||||
if mod > 0 {
|
||||
str += conv.Itoa(int(mod)) + "m"
|
||||
}
|
||||
val -= mod * m
|
||||
|
||||
if val > 0 {
|
||||
str += conv.Itoa(int(val))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Read a string and convert it to the correct
|
||||
// Resource Record.
|
||||
func SetString(s string) dns.RR {
|
||||
|
||||
k := new(dns.RR_DNSKEY)
|
||||
return k
|
||||
}
|
Loading…
Reference in New Issue