folded inside package dns

This commit is contained in:
Miek Gieben 2011-01-15 13:35:49 +01:00
parent 1ea77385f3
commit 5ab8afe518
8 changed files with 0 additions and 108 deletions

Binary file not shown.

View File

@ -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.

View File

@ -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)
}

View File

@ -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
}