[Fencommits] fenserve: another broken buggy version

Benja Fallenstein benja.fallenstein at gmail.com
Thu Mar 22 19:49:31 EET 2007


Sat Mar 17 16:34:45 EET 2007  Benja Fallenstein <benja.fallenstein at gmail.com>
  * another broken buggy version
diff -rN -u old-fenserve/FenServe.hs new-fenserve/FenServe.hs
--- old-fenserve/FenServe.hs	2007-03-22 19:49:30.000000000 +0200
+++ new-fenserve/FenServe.hs	2007-03-22 19:49:31.000000000 +0200
@@ -38,6 +38,7 @@
 
 import Network.URI (uriToString)
 
+import System.Glib.UTFString (newUTFString, peekUTFString)
 import System.IO.Unsafe (unsafePerformIO)
 
 fs                 =     "http://fenfire.org/2007/fenserve#"
@@ -137,22 +138,29 @@
 bID (IRI ('b':'l':'k':':':s)) = takeWhile (/= '#') s
   
 readGraph :: (BlockId, Pool) -> Graph
-readGraph (bid, pool) = raptorToGraph triples namespaces (bURI bid) where
+readGraph (bid, pool) = setGraphURI (bURI bid) $ read $ fromUTF $ pool Map.! bid
+{-raptorToGraph triples namespaces (bURI bid) where
     (triples, namespaces) = 
-        unsafePerformIO $ Raptor.bytesToTriples "turtle" (pool Map.! bid) (bURI bid)
+        unsafePerformIO $ Raptor.bytesToTriples "turtle" (pool Map.! bid) (bURI bid)-}
         
 writeGraph :: Graph -> Pool -> (BlockId, Pool)
-writeGraph graph pool = addBlock body pool where
-    (triples, namespaces) = graphToRaptor graph
-    body = unsafePerformIO $ Raptor.triplesToBytes triples namespaces ""
+writeGraph graph pool = addBlock {-body-} (toUTF $ show graph) pool where
+{-    (triples, namespaces) = graphToRaptor graph
+    body = unsafePerformIO $ Raptor.triplesToBytes triples namespaces ""-}
     
+toUTF :: String -> ByteString
+toUTF s = unsafePerformIO $ newUTFString s >>= ByteString.copyCString
+
+fromUTF :: ByteString -> String
+fromUTF s = unsafePerformIO $ ByteString.useAsCString s peekUTFString
+
 getURI :: [String] -> (BlockId, Pool) -> ByteString
 getURI [x] (bid,pool) = f entries where
     graph = readGraph (bid,pool); node = IRI $ bURI bid ++ "#dir"
     Dir _ entries = fromRDF graph node
-    f (FileEntry n r : _ ) | n == x = unsafePerformIO $ do print r; print $ Map.keys pool; return $ ByteString.pack [33] --pool Map.! bID r
+    f (FileEntry n r : _ ) | n == x = unsafePerformIO $ return $ toUTF (show r ++ "\n" ++ show (Map.keys pool)) --pool Map.! bID r
     f (_             : es) = f es
-    f []                   = ByteString.pack [34]
+    f []                   = toUTF "not found"
 getURI (x:xs) (bid,pool) = f entries where
     graph = readGraph (bid,pool); node = IRI $ bURI bid ++ "#dir"
     Dir _ entries = fromRDF graph node
diff -rN -u old-fenserve/fenserve.cabal new-fenserve/fenserve.cabal
--- old-fenserve/fenserve.cabal	2007-03-22 19:49:30.000000000 +0200
+++ new-fenserve/fenserve.cabal	2007-03-22 19:49:30.000000000 +0200
@@ -4,7 +4,7 @@
 License-file:   LICENSE
 Author:         Benja Fallenstein
 Maintainer:     fenfire-dev at nongnu.org
-Build-Depends:  base, mtl, network, HAppS, fenfire
+Build-Depends:  base, mtl, network, HAppS, fenfire, glib
 
 Executable:     fenserve
 Main-Is:        FenServe.hs




More information about the Fencommits mailing list