]> gitweb.factorcode.org Git - factor-unmaintained.git/blobdiff - io/sockets/headers/bsd/bsd.factor
headers: moving to io.sockets.headers to match IN: declaration.
[factor-unmaintained.git] / io / sockets / headers / bsd / bsd.factor
diff --git a/io/sockets/headers/bsd/bsd.factor b/io/sockets/headers/bsd/bsd.factor
new file mode 100644 (file)
index 0000000..06634c2
--- /dev/null
@@ -0,0 +1,22 @@
+! Copyright (C) 2007 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien alien.c-types alien.syntax byte-arrays io
+kernel math prettyprint ;
+IN: io.sockets.headers.bsd
+
+C-STRUCT: bpfh
+    { "timeval" "timestamp" }
+    { "ulong" "caplen" }
+    { "ulong" "datalen" }
+    { "ushort" "hdrlen" } ;
+
+: bpfh. ( bpfh -- )
+    [
+        bpfh-timestamp "Timestamp: " write
+        "timeval" heap-size memory>byte-array .
+    ] keep
+    [ bpfh-caplen "caplen: " write . ] keep
+    [ bpfh-datalen "datalen: " write . ] keep
+    [ bpfh-hdrlen "hdrlen: " write . ] keep
+    drop ;
+