X-Git-Url: http://www.average.org/gitweb/?p=pdns-pipe-nmc.git;a=blobdiff_plain;f=PowerDns.hs;h=9a2a4987443c9d052a40257f005a04dcd1aa8343;hp=cb685dd4e96fadfb9e83359568365e46c5d7ddde;hb=0d59aa176c8ca6665f59426a436671099a393d3f;hpb=9ef6b8b7e3a1eeb20cdde32541e6d2aa549ba3b1 diff --git a/PowerDns.hs b/PowerDns.hs index cb685dd..9a2a498 100644 --- a/PowerDns.hs +++ b/PowerDns.hs @@ -1,6 +1,7 @@ module PowerDns ( RRType(..) , PdnsRequest(..) , pdnsParse + , pdnsReport , pdnsOut ) where @@ -63,5 +64,16 @@ pdnsParse ver s = }) _ -> Left $ "Unparseable PDNS Request: " ++ s -pdnsOut :: RRType -> NmcDom -> String -pdnsOut _ d = show d +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 -> 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