]> gitweb.factorcode.org Git - factor.git/commitdiff
extra: moving etc-hosts and resolv-conf to basis.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 18 Mar 2021 17:07:55 +0000 (10:07 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 18 Mar 2021 17:07:55 +0000 (10:07 -0700)
18 files changed:
basis/etc-hosts/authors.txt [new file with mode: 0644]
basis/etc-hosts/etc-hosts.factor [new file with mode: 0644]
basis/etc-hosts/summary.txt [new file with mode: 0644]
basis/etc-hosts/tags.txt [new file with mode: 0644]
basis/resolv-conf/authors.txt [new file with mode: 0644]
basis/resolv-conf/resolv-conf-tests.factor [new file with mode: 0644]
basis/resolv-conf/resolv-conf.factor [new file with mode: 0644]
basis/resolv-conf/resolv-conf.test [new file with mode: 0644]
basis/resolv-conf/tags.txt [new file with mode: 0644]
extra/etc-hosts/authors.txt [deleted file]
extra/etc-hosts/etc-hosts.factor [deleted file]
extra/etc-hosts/summary.txt [deleted file]
extra/etc-hosts/tags.txt [deleted file]
extra/resolv-conf/authors.txt [deleted file]
extra/resolv-conf/resolv-conf-tests.factor [deleted file]
extra/resolv-conf/resolv-conf.factor [deleted file]
extra/resolv-conf/resolv-conf.test [deleted file]
extra/resolv-conf/tags.txt [deleted file]

diff --git a/basis/etc-hosts/authors.txt b/basis/etc-hosts/authors.txt
new file mode 100644 (file)
index 0000000..e091bb8
--- /dev/null
@@ -0,0 +1 @@
+John Benediktsson
diff --git a/basis/etc-hosts/etc-hosts.factor b/basis/etc-hosts/etc-hosts.factor
new file mode 100644 (file)
index 0000000..4e102bb
--- /dev/null
@@ -0,0 +1,29 @@
+USING: arrays assocs environment hashtables io.encodings.utf8
+io.files io.pathnames kernel memoize sequences splitting system
+unicode ;
+
+IN: etc-hosts
+
+HOOK: hosts-path os ( -- path )
+
+M: windows hosts-path
+    "SystemRoot" os-env "System32/drivers/etc/hosts" append-path ;
+
+M: unix hosts-path "/etc/hosts" ;
+
+: parse-hosts ( path -- hosts )
+    utf8 file-lines
+    [ [ blank? ] trim ] map harvest
+    [ "#" head? ] reject
+    [
+        [ blank? ] split1-when
+        [ blank? ] split-when harvest
+    ] H{ } map>assoc ;
+
+MEMO: system-hosts ( -- hosts ) hosts-path parse-hosts ;
+
+: host>ips ( host -- ips )
+    system-hosts [ member? nip ] with assoc-filter keys ;
+
+: ip>hosts ( ip -- hosts )
+    system-hosts at ;
diff --git a/basis/etc-hosts/summary.txt b/basis/etc-hosts/summary.txt
new file mode 100644 (file)
index 0000000..0a595a2
--- /dev/null
@@ -0,0 +1 @@
+Parsing the /etc/hosts file
diff --git a/basis/etc-hosts/tags.txt b/basis/etc-hosts/tags.txt
new file mode 100644 (file)
index 0000000..9169944
--- /dev/null
@@ -0,0 +1 @@
+file formats
diff --git a/basis/resolv-conf/authors.txt b/basis/resolv-conf/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/resolv-conf/resolv-conf-tests.factor b/basis/resolv-conf/resolv-conf-tests.factor
new file mode 100644 (file)
index 0000000..59c52cf
--- /dev/null
@@ -0,0 +1,18 @@
+! Copyright (C) 2019 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: tools.test resolv-conf ;
+IN: resolv-conf.tests
+{
+    T{ resolv.conf
+        { nameserver V{ "127.0.0.53" } }
+        { domain V{ } }
+        { lookup V{ } }
+        { search V{ "localdomain" } }
+        { sortlist V{ } }
+        { options T{ options { edns0? t } } }
+    }
+} [
+    "nameserver 127.0.0.53
+    options edns0
+    search localdomain" string>resolv.conf
+] unit-test
\ No newline at end of file
diff --git a/basis/resolv-conf/resolv-conf.factor b/basis/resolv-conf/resolv-conf.factor
new file mode 100644 (file)
index 0000000..8a271e4
--- /dev/null
@@ -0,0 +1,103 @@
+! Copyright (C) 2010 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors combinators constructors io.encodings.utf8
+io.files kernel math math.parser sequences splitting
+unicode ;
+IN: resolv-conf
+
+TUPLE: network ip netmask ;
+CONSTRUCTOR: <network> network ( ip netmask -- network ) ;
+
+TUPLE: options
+debug?
+edns0?
+insecure1?
+insecure2?
+{ ndots integer initial: 1 }
+{ timeout integer initial: 5 }
+{ attempts integer initial: 2 }
+rotate? no-check-names? inet6? tcp? ;
+
+CONSTRUCTOR: <options> options ( -- options ) ;
+
+TUPLE: resolv.conf nameserver domain lookup search sortlist options ;
+
+CONSTRUCTOR: <resolv.conf> resolv.conf ( -- resolv.conf )
+    V{ } clone >>nameserver
+    V{ } clone >>domain
+    V{ } clone >>search
+    V{ } clone >>sortlist
+    V{ } clone >>lookup
+    <options> >>options ;
+
+<PRIVATE
+
+: trim-blanks ( string -- string' ) [ blank? ] trim ;
+
+: split-line ( resolv.conf string -- resolv.conf seq resolv.conf )
+    trim-blanks " " split
+    [ trim-blanks ] map harvest over ;
+
+: parse-nameserver ( resolv.conf string -- resolv.conf )
+    split-line nameserver>> push-all ;
+
+: parse-domain ( resolv.conf string -- resolv.conf )
+    split-line domain>> push-all ;
+
+: parse-lookup ( resolv.conf string -- resolv.conf )
+    split-line lookup>> push-all ;
+
+: parse-search ( resolv.conf string -- resolv.conf )
+    split-line search>> push-all ;
+
+: parse-sortlist ( resolv.conf string -- resolv.conf )
+    trim-blanks " " split
+    [ trim-blanks "/" split1 <network> ] map >>sortlist ;
+
+ERROR: unsupported-resolv.conf-option string ;
+
+: parse-integer ( string -- n )
+    trim-blanks ":" ?head drop trim-blanks string>number ;
+
+: parse-option ( resolv.conf string -- resolv.conf )
+    [ dup options>> ] dip trim-blanks {
+        { [ "debug" ?head ] [ drop t >>debug? ] }
+        { [ "ndots:" ?head ] [ parse-integer >>ndots ] }
+        { [ "timeout" ?head ] [ parse-integer >>timeout ] }
+        { [ "attempts" ?head ] [ parse-integer >>attempts ] }
+        { [ "rotate" ?head ] [ drop t >>rotate? ] }
+        { [ "no-check-names" ?head ] [ drop t >>no-check-names? ] }
+        { [ "inet6" ?head ] [ drop t >>inet6? ] }
+        { [ "edns0" ?head ] [ drop t >>edns0? ] }
+        [ unsupported-resolv.conf-option ]
+    } cond drop ;
+
+ERROR: unsupported-resolv.conf-line string ;
+
+: parse-resolv.conf-line ( resolv.conf string -- resolv.conf )
+    {
+        { [ "nameserver" ?head ] [ parse-nameserver ] }
+        { [ "domain" ?head ] [ parse-domain ] }
+        { [ "lookup" ?head ] [ parse-lookup ] }
+        { [ "search" ?head ] [ parse-search ] }
+        { [ "sortlist" ?head ] [ parse-sortlist ] }
+        { [ "options" ?head ] [ parse-option ] }
+        [ unsupported-resolv.conf-line ]
+    } cond ;
+
+PRIVATE>
+
+: lines>resolv.conf ( lines -- resolv.conf )
+    [ <resolv.conf> ] dip
+    [ [ blank? ] trim ] map harvest
+    [ "#" head? ] reject
+    [ parse-resolv.conf-line ] each ;
+
+: string>resolv.conf ( string -- resolv.conf )
+    string-lines lines>resolv.conf ;
+
+: path>resolv.conf ( path -- resolv.conf )
+    utf8 file-lines lines>resolv.conf ;
+
+: default-resolv.conf ( -- resolv.conf )
+    "/etc/resolv.conf" path>resolv.conf ;
diff --git a/basis/resolv-conf/resolv-conf.test b/basis/resolv-conf/resolv-conf.test
new file mode 100644 (file)
index 0000000..1b17c3a
--- /dev/null
@@ -0,0 +1,28 @@
+#
+# Mac OS X Notice
+#
+# This file is not used by the host name and address resolution
+# or the DNS query routing mechanisms used by most processes on
+# this Mac OS X system.
+ #  
+ # This file is automatically generated.
+ #
+ nameserver  8.8.8.8 
+ domain  hmm.lol.com  
+ search  a.com  b.com  c.com 
+
+sortlist 130.155.160.0/255.255.240.0 130.155.0.0 131.155.160.0/255.255.240.0 130.155.0.1
+
+ options   debug
+ options   ndots:10  
+ options   timeout:11 
+ options   attempts : 12 
+ options   rotate
+ options   no-check-names
+ options   inet6 
+
+
+
+
+
+
diff --git a/basis/resolv-conf/tags.txt b/basis/resolv-conf/tags.txt
new file mode 100644 (file)
index 0000000..78353b4
--- /dev/null
@@ -0,0 +1,3 @@
+os
+parsing
+file formats
diff --git a/extra/etc-hosts/authors.txt b/extra/etc-hosts/authors.txt
deleted file mode 100644 (file)
index e091bb8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-John Benediktsson
diff --git a/extra/etc-hosts/etc-hosts.factor b/extra/etc-hosts/etc-hosts.factor
deleted file mode 100644 (file)
index 4e102bb..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-USING: arrays assocs environment hashtables io.encodings.utf8
-io.files io.pathnames kernel memoize sequences splitting system
-unicode ;
-
-IN: etc-hosts
-
-HOOK: hosts-path os ( -- path )
-
-M: windows hosts-path
-    "SystemRoot" os-env "System32/drivers/etc/hosts" append-path ;
-
-M: unix hosts-path "/etc/hosts" ;
-
-: parse-hosts ( path -- hosts )
-    utf8 file-lines
-    [ [ blank? ] trim ] map harvest
-    [ "#" head? ] reject
-    [
-        [ blank? ] split1-when
-        [ blank? ] split-when harvest
-    ] H{ } map>assoc ;
-
-MEMO: system-hosts ( -- hosts ) hosts-path parse-hosts ;
-
-: host>ips ( host -- ips )
-    system-hosts [ member? nip ] with assoc-filter keys ;
-
-: ip>hosts ( ip -- hosts )
-    system-hosts at ;
diff --git a/extra/etc-hosts/summary.txt b/extra/etc-hosts/summary.txt
deleted file mode 100644 (file)
index 0a595a2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Parsing the /etc/hosts file
diff --git a/extra/etc-hosts/tags.txt b/extra/etc-hosts/tags.txt
deleted file mode 100644 (file)
index 9169944..0000000
+++ /dev/null
@@ -1 +0,0 @@
-file formats
diff --git a/extra/resolv-conf/authors.txt b/extra/resolv-conf/authors.txt
deleted file mode 100644 (file)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/resolv-conf/resolv-conf-tests.factor b/extra/resolv-conf/resolv-conf-tests.factor
deleted file mode 100644 (file)
index 59c52cf..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-! Copyright (C) 2019 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test resolv-conf ;
-IN: resolv-conf.tests
-{
-    T{ resolv.conf
-        { nameserver V{ "127.0.0.53" } }
-        { domain V{ } }
-        { lookup V{ } }
-        { search V{ "localdomain" } }
-        { sortlist V{ } }
-        { options T{ options { edns0? t } } }
-    }
-} [
-    "nameserver 127.0.0.53
-    options edns0
-    search localdomain" string>resolv.conf
-] unit-test
\ No newline at end of file
diff --git a/extra/resolv-conf/resolv-conf.factor b/extra/resolv-conf/resolv-conf.factor
deleted file mode 100644 (file)
index 8a271e4..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-! Copyright (C) 2010 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators constructors io.encodings.utf8
-io.files kernel math math.parser sequences splitting
-unicode ;
-IN: resolv-conf
-
-TUPLE: network ip netmask ;
-CONSTRUCTOR: <network> network ( ip netmask -- network ) ;
-
-TUPLE: options
-debug?
-edns0?
-insecure1?
-insecure2?
-{ ndots integer initial: 1 }
-{ timeout integer initial: 5 }
-{ attempts integer initial: 2 }
-rotate? no-check-names? inet6? tcp? ;
-
-CONSTRUCTOR: <options> options ( -- options ) ;
-
-TUPLE: resolv.conf nameserver domain lookup search sortlist options ;
-
-CONSTRUCTOR: <resolv.conf> resolv.conf ( -- resolv.conf )
-    V{ } clone >>nameserver
-    V{ } clone >>domain
-    V{ } clone >>search
-    V{ } clone >>sortlist
-    V{ } clone >>lookup
-    <options> >>options ;
-
-<PRIVATE
-
-: trim-blanks ( string -- string' ) [ blank? ] trim ;
-
-: split-line ( resolv.conf string -- resolv.conf seq resolv.conf )
-    trim-blanks " " split
-    [ trim-blanks ] map harvest over ;
-
-: parse-nameserver ( resolv.conf string -- resolv.conf )
-    split-line nameserver>> push-all ;
-
-: parse-domain ( resolv.conf string -- resolv.conf )
-    split-line domain>> push-all ;
-
-: parse-lookup ( resolv.conf string -- resolv.conf )
-    split-line lookup>> push-all ;
-
-: parse-search ( resolv.conf string -- resolv.conf )
-    split-line search>> push-all ;
-
-: parse-sortlist ( resolv.conf string -- resolv.conf )
-    trim-blanks " " split
-    [ trim-blanks "/" split1 <network> ] map >>sortlist ;
-
-ERROR: unsupported-resolv.conf-option string ;
-
-: parse-integer ( string -- n )
-    trim-blanks ":" ?head drop trim-blanks string>number ;
-
-: parse-option ( resolv.conf string -- resolv.conf )
-    [ dup options>> ] dip trim-blanks {
-        { [ "debug" ?head ] [ drop t >>debug? ] }
-        { [ "ndots:" ?head ] [ parse-integer >>ndots ] }
-        { [ "timeout" ?head ] [ parse-integer >>timeout ] }
-        { [ "attempts" ?head ] [ parse-integer >>attempts ] }
-        { [ "rotate" ?head ] [ drop t >>rotate? ] }
-        { [ "no-check-names" ?head ] [ drop t >>no-check-names? ] }
-        { [ "inet6" ?head ] [ drop t >>inet6? ] }
-        { [ "edns0" ?head ] [ drop t >>edns0? ] }
-        [ unsupported-resolv.conf-option ]
-    } cond drop ;
-
-ERROR: unsupported-resolv.conf-line string ;
-
-: parse-resolv.conf-line ( resolv.conf string -- resolv.conf )
-    {
-        { [ "nameserver" ?head ] [ parse-nameserver ] }
-        { [ "domain" ?head ] [ parse-domain ] }
-        { [ "lookup" ?head ] [ parse-lookup ] }
-        { [ "search" ?head ] [ parse-search ] }
-        { [ "sortlist" ?head ] [ parse-sortlist ] }
-        { [ "options" ?head ] [ parse-option ] }
-        [ unsupported-resolv.conf-line ]
-    } cond ;
-
-PRIVATE>
-
-: lines>resolv.conf ( lines -- resolv.conf )
-    [ <resolv.conf> ] dip
-    [ [ blank? ] trim ] map harvest
-    [ "#" head? ] reject
-    [ parse-resolv.conf-line ] each ;
-
-: string>resolv.conf ( string -- resolv.conf )
-    string-lines lines>resolv.conf ;
-
-: path>resolv.conf ( path -- resolv.conf )
-    utf8 file-lines lines>resolv.conf ;
-
-: default-resolv.conf ( -- resolv.conf )
-    "/etc/resolv.conf" path>resolv.conf ;
diff --git a/extra/resolv-conf/resolv-conf.test b/extra/resolv-conf/resolv-conf.test
deleted file mode 100644 (file)
index 1b17c3a..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Mac OS X Notice
-#
-# This file is not used by the host name and address resolution
-# or the DNS query routing mechanisms used by most processes on
-# this Mac OS X system.
- #  
- # This file is automatically generated.
- #
- nameserver  8.8.8.8 
- domain  hmm.lol.com  
- search  a.com  b.com  c.com 
-
-sortlist 130.155.160.0/255.255.240.0 130.155.0.0 131.155.160.0/255.255.240.0 130.155.0.1
-
- options   debug
- options   ndots:10  
- options   timeout:11 
- options   attempts : 12 
- options   rotate
- options   no-check-names
- options   inet6 
-
-
-
-
-
-
diff --git a/extra/resolv-conf/tags.txt b/extra/resolv-conf/tags.txt
deleted file mode 100644 (file)
index 78353b4..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-os
-parsing
-file formats