]> www.average.org Git - pdns-pipe-nmc.git/blobdiff - PowerDns.hs
move most formatting to PowerDns
[pdns-pipe-nmc.git] / PowerDns.hs
index 1c1e420c6e13c0c61d25e1dc98537933f802bad0..9a2a4987443c9d052a40257f005a04dcd1aa8343 100644 (file)
@@ -1,6 +1,7 @@
 module PowerDns ( RRType(..)
                 , PdnsRequest(..)
                 , pdnsParse
+                , pdnsReport
                 , pdnsOut
                 ) where
 
@@ -63,8 +64,16 @@ pdnsParse ver s =
                                             })
       _                         -> Left $ "Unparseable PDNS Request: " ++ s
 
-pdnsOut :: Int -> RRType -> Either String NmcDom -> String
-pdnsOut ver rrtype edom =
+pdnsReport :: String -> String
+pdnsReport err =
+  "LOG\tError: " ++ err ++ "\nFAIL\n"
+
+pdnsOut :: Int -> String -> RRType -> Either String NmcDom -> String
+pdnsOut ver id rrtype edom =
   case edom of
-    Left  err -> "LOG Error: " ++ err ++ "\nFAIL\n"
-    Right dom -> "DATA\n" ++ (show dom) ++ "\nEND\n" --FIXME
+    Left  err -> pdnsReport err
+    Right dom -> pdnsAmend ver id rrtype dom "END\n"
+
+pdnsAmend :: Int -> String -> RRType -> NmcDom -> String -> String
+pdnsAmend ver id rrtype dom accum =
+  "DATA\t" ++ (show dom) ++ "\n" ++ accum --FIXME